type
TFormTest =
class(TForm)
Button1: TButton;
procedure FormPaint(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
FSteps: integer;
end;
...
procedure TFormTest.FormPaint(Sender: TObject);
const
IncPerStep = 10;
var
RBig, RSmall: TRect;
R, G, B: byte;
InitialColor: TColor;
begin
RBig := Rect(0, 0, ClientWidth, ClientHeight);
RSmall := Rect(50, 50, 100, 100);
InitialColor := $00404040;
//dunkelgrau
Canvas.Brush.Color := InitialColor;
Canvas.FillRect(RBig);
//Farbe zerlegen
R := GetRValue(InitialColor);
G := GetGValue(InitialColor);
B := GetBValue(InitialColor);
//Grünanteil erhöhen, wenn möglich
if integer(G + FSteps * IncPerStep) <= MAXBYTE
then
inc(G, FSteps * IncPerStep)
else
G := MAXBYTE;
Canvas.Brush.Color :=
RGB(R, G, B);
Canvas.FillRect(RSmall);
end;
procedure TFormTest.Button1Click(Sender: TObject);
begin
inc(FSteps);
invalidate;
end;