procedure GradHorizontal(Canvas:TCanvas;Rect:TRect;FromColor,ToColor:TColor);
var
X:integer;
dr,dg,db:Extended;
C1,C2:TColor;
r1,r2,g1,g2,b1,b2:Byte;
R,G,B:Byte;
i:integer;
begin
try
C1 := FromColor;
R1 := GetRValue(C1);
G1 := GetGValue(C1);
B1 := GetBValue(C1);
C2 := ToColor;
R2 := GetRValue(C2);
G2 := GetGValue(C2);
B2 := GetBValue(C2);
dr := (R2-R1) / Rect.Right-Rect.Left;
dg := (G2-G1) / Rect.Right-Rect.Left;
db := (B2-B1) / Rect.Right-Rect.Left;
i := 0;
for X := Rect.Left to Rect.Right-1 do begin
R := R1+Ceil(dr*i);
G := G1+Ceil(dg*i);
B := B1+Ceil(db*i);
Canvas.Pen.Color := RGB(R,G,B);
Canvas.MoveTo(X,Rect.Top);
Canvas.LineTo(X,Rect.Bottom);
inc(i);
end;
except
end;
end;
procedure GradVertical(Canvas:TCanvas;Rect:TRect;FromColor,ToColor:TColor);
var
Y:integer;
dr,dg,db:Extended;
C1,C2:TColor;
r1,r2,g1,g2,b1,b2:Byte;
R,G,B:Byte;
i:integer;
begin
try
C1 := FromColor;
R1 := GetRValue(C1);
G1 := GetGValue(C1);
B1 := GetBValue(C1);
C2 := ToColor;
R2 := GetRValue(C2);
G2 := GetGValue(C2);
B2 := GetBValue(C2);
dr := (R2-R1) / Rect.Bottom-Rect.Top;
dg := (G2-G1) / Rect.Bottom-Rect.Top;
db := (B2-B1) / Rect.Bottom-Rect.Top;
i := 0;
for Y := Rect.Top to Rect.Bottom-1 do begin
R := R1+Ceil(dr*i);
G := G1+Ceil(dg*i);
B := B1+Ceil(db*i);
Canvas.Pen.Color := RGB(R,G,B);
Canvas.MoveTo(Rect.Left,Y);
Canvas.LineTo(Rect.Right,Y);
inc(i);
end;
except
end;
end;
|