// Erstellt ein Farbverlauf von links nach rechts
procedure DrawGradientV(Canvas: TCanvas; Color1, Color2: TColor; Rect: TRect);
var
Y, R, G, B: Integer;
begin
for Y := Rect.Left
to Rect.Right
do begin
R := Round(GetRValue(Color1) + ((GetRValue(Color2) - GetRValue(Color1)) *
Y / (Rect.Right - Rect.Left)));
G := Round(GetGValue(Color1) + ((GetGValue(Color2) - GetGValue(Color1)) *
Y / (Rect.Right - Rect.Left)));
B := Round(GetBValue(Color1) + ((GetBValue(Color2) - GetBValue(Color1)) *
Y / (Rect.Right - Rect.Left)));
Canvas.Pen.Color :=
RGB(R, G, B);
Canvas.Pen.Width := 1;
Canvas.Pen.Style := psInsideFrame;
Canvas.MoveTo(Y, Rect.Top);
Canvas.LineTo(Y, Rect.Bottom);
end;
end;
// Erstellt ein Farbverlauf von oben nach unten
procedure DrawGradientH(Canvas: TCanvas; Color1, Color2: TColor; Rect: TRect);
var
X, R, G, B: Integer;
begin
for X := Rect.Top
to Rect.Bottom
do begin
R := Round(GetRValue(Color1) + ((GetRValue(Color2) - GetRValue(Color1)) *
X / (Rect.Bottom - Rect.Top)));
G := Round(GetGValue(Color1) + ((GetGValue(Color2) - GetGValue(Color1)) *
X / (Rect.Bottom - Rect.Top)));
B := Round(GetBValue(Color1) + ((GetBValue(Color2) - GetBValue(Color1)) *
X / (Rect.Bottom - Rect.Top)));
Canvas.Pen.Color :=
RGB(R, G, B);
Canvas.Pen.Width := 1;
Canvas.Pen.Style := psInsideFrame;
Canvas.MoveTo(Rect.Left, X);
Canvas.LineTo(Rect.Right, X);
end;
end;
procedure TForm3.FormPaint(Sender: TObject);
begin
DrawGradientH(Canvas, $00AF8000, $00FFD680, Rect(0, 0, Width, Height));
end;