Shape1.Brush.Color := StarColors[currentColorIndex];
Shape1.Left := (ClientWidth - Shape1.Width) div 2;
Shape1.Top := (ClientHeight - Shape1.Height) div 2;
ChangeBorderColorButton := TButton.Create(Self);
ChangeBorderColorButton.Parent := Self;
ChangeBorderColorButton.Caption := 'Change Border Color';
ChangeBorderColorButton.Left := 10;
ChangeBorderColorButton.Top := 10;
ChangeBorderColorButton.OnClick := @ChangeBorderColorButtonClick;
ChangeStarColorButton := TButton.Create(Self);
ChangeStarColorButton.Parent := Self;
ChangeStarColorButton.Caption := 'Change Star Color';
ChangeStarColorButton.Left := 10;
ChangeStarColorButton.Top := 40;
ChangeStarColorButton.OnClick := @ChangeStarColorButtonClick;
end;
procedure TForm1.Shape1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Inc(currentColorIndex);
if currentColorIndex >= Length(StarColors) then
currentColorIndex := 0;
Shape1.Brush.Color := StarColors[currentColorIndex];
end;
procedure TForm1.Shape1Paint(Sender: TObject);
begin
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
scaleFactor := scaleFactor + scaleFactorDelta;
if (scaleFactor < 0.5) or (scaleFactor > 2.0) then
scaleFactorDelta := -scaleFactorDelta;
Shape1.Shape := stStar;
Shape1.Height := Round(50 * scaleFactor);
Shape1.Width := Round(50 * scaleFactor);
Shape1.Height := Round(Shape1.Height * 2);
Shape1.Width := Round(Shape1.Width * 2);
Inc(rotationAngle, 5);
Shape1.Brush.Color := StarColors[currentColorIndex];
Shape1.Left := (ClientWidth - Shape1.Width) div 2;
Shape1.Top := (ClientHeight - Shape1.Height) div 2;
end;