procedure DrawGradient(
const Canvas: TCanvas; Color1, Color2: TColor; Rect: TRect);
var
Y, R, G, B: Integer;
RColor1, GColor1, BColor1: Integer;
RColor2, GColor2, BColor2: Integer;
begin
Color1:=ColorToRGB(Color1);
Color2:=ColorToRGB(Color2);
RColor1:=GetRValue(Color1);
GColor1:=GetGValue(Color1);
BColor1:=GetBValue(Color1);
RColor2:=GetRValue(Color2);
GColor2:=GetGValue(Color2);
BColor2:=GetBValue(Color2);
Canvas.Pen.Width:=1;
Canvas.Pen.Style:=psInsideFrame;
for Y:=Rect.Top
to Rect.Bottom-1
do
begin
R:=Round(RColor1 + ((RColor2 - RColor1) * Y / (Rect.Bottom - Rect.Top)));
G:=Round(GColor1 + ((GColor2 - GColor1) * Y / (Rect.Bottom - Rect.Top)));
B:=Round(BColor1 + ((BColor2 - BColor1) * Y / (Rect.Bottom - Rect.Top)));
Canvas.Brush.Color:=
RGB(R, G, B);
Canvas.FillRect(Classes.Rect(Rect.Left, Y, Rect.Right, Y+1));
end;
end;