绘制窗体渐变背景的函数[delphi]
绘制窗体渐变背景的函数,三个参数分别代表起始颜色,终止颜色,绘制方向
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;
最新文章
- 解决SprngMVC中ResponseBody注解中文乱码
- Cocos2d-x 3.2 学习笔记(六)Layer
- 为什么是 n(n+1)/2 ?
- 在Eclipse中使用JSHint检查JavaScript
- Java IO总结之缓冲读入文件
- (三)ubuntu学习前传—uboot常见环境变量
- 巩固一下C语言中的指针
- OpenGL7-1-快速绘制接口(使用高效的函数接口进行绘制)
- Laravel Homestead安装教程
- Python学习笔记_02:使用Tkinter连接MySQL数据库实现登陆注册功能
- K:正则表达式之基础简介
- 01_MyBatis EHCache集成及所需jar包,ehcache.xml配置文件参数配置及mapper中的参数配置
- ruby-attr_accessor使用
- 51nod 省选联测 R2
- Github+HEXO FATAL bad indentation of a mapping entry at line 84
- PHP中递归的实现(附例子)
- ReultSet有什么作用和使用
- mysql 定时备份任务
- 手机Gmail上用Exchange协议配置收发QQ邮箱
- 深入浅出MongoDB应用实战开发
热门文章
- 安卓8.0真机运行appium1.4遇到的问题:运行自动化脚本,手机自动安装 settings.apk和unclock.apk,执行脚本时提示安装UnicodeIME-debug.apk失败,怎么关掉自动安装?
- 批量新增数据(BuckCopy)
- jQuery的属性、遍历和HTML操作
- iscroll refresh无效解决办法
- 【Shiro】一、Apache Shiro简介
- android API版本对应的系统版本及Android获取手机和系统版本等信息的代码
- error LNK2019: 无法解析的外部符号 ";__declspec(dllimport) long __stdcall RtlGetVersion(struct _OSVERSIONINFOW
- 拾遗:Go 基础
- CSS3:FlexBox的详解
- JDK8新特性之函数式接口