var
Y,iBlue: Integer;
begin
iBlue:=30;
for Y:=0 to Image1.Height do
begin
Image1.Canvas.Pen.Color:=RGB(0,0,iBlue);
Inc(iBlue);
Image1.Canvas.MoveTo(0,Y);
Image1.Canvas.LineTo(Image1.Width,Y);
end;
end;
以下是窗口渐变,原理一样:
procedure TForm1.FormPaint(Sender: TObject);
var I:word;
dy,y:real;
begin
dy:=clientheight/256;
y:=0;
for I:=255 downto 0 do
begin
canvas.brush.color:=$00000000+I*$10000;
canvas.fillrect(rect(0,round,clientwidth,round(y+dy)));
y:=y+dy;
end;
end;