绘制窗体渐变背景的函数,三个参数分别代表起始颜色,终止颜色,绘制方向
procedure TForm1.Draw(StartColor:TColor;EndColor:TColor;Direction:Integer);
var
i:Integer;
Dct:TRect;
c1,c2,c3:byte;
begin
if Direction=0 then
begin
for i:=0 to self.Width-1 do
begin
c1:=GetRValue(StartColor)+Trunc(i*(GetRValue(EndColor)-GetRValue(StartColor))/(self.Width-1));
c2:=GetGValue(StartColor)+Trunc(i*(GetGValue(EndColor)-GetGValue(StartColor))/(self.Width-1));
c3:=GetBValue(StartColor)+Trunc(i*(GetBValue(EndColor)-GetBValue(StartColor))/(self.Width-1));
Canvas.Brush.Color:=RGB(c1,c2,c3);
//每次画矩形的画刷颜色
Dct:=Rect(i,0,i+1,self.Height);
//每次刷绘的矩形区域
Canvas.FillRect(Dct);
//填充颜色
end;
end
else
begin
for i:=0 to self.Height-1 do
begin
c1:=GetRValue(StartColor)+Trunc(i*(GetRValue(EndColor)-GetRValue(StartColor))/(self.Height-1));
c2:=GetGValue(StartColor)+Trunc(i*(GetGValue(EndColor)-GetGValue(StartColor))/(self.Height-1));
c3:=GetBValue(StartColor)+Trunc(i*(GetBValue(EndColor)-GetBValue(StartColor))/(self.Height-1));
Canvas.Brush.Color:=RGB(c1,c2,c3);
//每次画矩形的画刷颜色
Dct:=Rect(0,i,self.Width,i+1);
//每次刷绘的矩形区域
Canvas.FillRect(Dct);
//填充颜色
end;
end;
end;

最新文章

  1. 解决SprngMVC中ResponseBody注解中文乱码
  2. Cocos2d-x 3.2 学习笔记(六)Layer
  3. 为什么是 n(n+1)/2 ?
  4. 在Eclipse中使用JSHint检查JavaScript
  5. Java IO总结之缓冲读入文件
  6. (三)ubuntu学习前传—uboot常见环境变量
  7. 巩固一下C语言中的指针
  8. OpenGL7-1-快速绘制接口(使用高效的函数接口进行绘制)
  9. Laravel Homestead安装教程
  10. Python学习笔记_02:使用Tkinter连接MySQL数据库实现登陆注册功能
  11. K:正则表达式之基础简介
  12. 01_MyBatis EHCache集成及所需jar包,ehcache.xml配置文件参数配置及mapper中的参数配置
  13. ruby-attr_accessor使用
  14. 51nod 省选联测 R2
  15. Github+HEXO FATAL bad indentation of a mapping entry at line 84
  16. PHP中递归的实现(附例子)
  17. ReultSet有什么作用和使用
  18. mysql 定时备份任务
  19. 手机Gmail上用Exchange协议配置收发QQ邮箱
  20. 深入浅出MongoDB应用实战开发

热门文章

  1. 安卓8.0真机运行appium1.4遇到的问题:运行自动化脚本,手机自动安装 settings.apk和unclock.apk,执行脚本时提示安装UnicodeIME-debug.apk失败,怎么关掉自动安装?
  2. 批量新增数据(BuckCopy)
  3. jQuery的属性、遍历和HTML操作
  4. iscroll refresh无效解决办法
  5. 【Shiro】一、Apache Shiro简介
  6. android API版本对应的系统版本及Android获取手机和系统版本等信息的代码
  7. error LNK2019: 无法解析的外部符号 "__declspec(dllimport) long __stdcall RtlGetVersion(struct _OSVERSIONINFOW
  8. 拾遗:Go 基础
  9. CSS3:FlexBox的详解
  10. JDK8新特性之函数式接口