procedure Gradient(Canvas: TCanvas; Width,Height: Integer; BeginColor,EndColor: TColor);
var
RGBValue:
array[0..2]
of Byte;
RGBDiff:
array[0..2]
of Integer;
Rect: TRect;
i: Integer;
R, G, B: Byte;
begin
RGBValue[0] := GetRValue(ColorToRGB(BeginColor));
RGBValue[1] := GetGValue(ColorToRGB(BeginColor));
RGBValue[2] := GetBValue(ColorToRGB(BeginColor));
RGBDiff[0] := GetRValue(ColorToRGB(EndColor)) - RGBValue[0];
RGBDiff[1] := GetGValue(ColorToRGB(EndColor)) - RGBValue[1];
RGBDiff[2] := GetBValue(ColorToRGB(EndColor)) - RGBValue[2];
Canvas.Pen.Style := psSolid;
Canvas.Pen.Mode := pmCopy;
Rect.Top := 0;
Rect.Bottom := Height;
for i := 0
to 255
do
begin
Rect.Left := MulDiv(i, Width, 255);
Rect.Right := MulDiv(i + 1, Width, 255);
R := RGBValue[0] + MulDiv(i, RGBDiff[0], 255 - 1);
G := RGBValue[1] + MulDiv(i, RGBDiff[1], 255 - 1);
B := RGBValue[2] + MulDiv(i, RGBDiff[2], 255 - 1);
Canvas.Brush.Color :=
RGB(R, G, B);
Canvas.FillRect(Rect);
end;
end;