绘制窗体渐变背景的函数[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;
未经允许不得转载:亿券答案网 » 绘制窗体渐变背景的函数[delphi]
相关推荐
- 已知函数f(x)=10g2(2x+m)的定义域为[2,+∞),则f(10)等于( ) (A)3+log23(B)1+2
- 已知函数f(x)=10g2(2x+m)的定义域为[2,+∞),则f(10)等于( ) (A)3+log23(B)1+2
- 生产函数Q=3L+500,以下说法正确的是()
- 短期生产函数
- 供给函数
- 计算题:某国家消费函数的斜率为0.9,如减税9亿元,试计算该国家可能增加总储蓄的数额。
- 短期生产函数
- 下列函数中,为奇函数的是( ) (A)y=㏒3x(B)y=3x(C)y=3×2(D)y=3sinx
- 函数y-=ƒ(x)满足ƒ(1)=2ƒ″(1)=0,且当x<1时,ƒ″(x)<0;当x>1时,ƒ″(x)
- 生产函数Q=3L+500,以下说法正确的是()