1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
Button1: TButton;
Button2: TButton;
Timer1: TTimer;
procedure PaintBox1Paint(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Var Couleur:array[1..4] of Tcolor;
listeCouleur:TStringList;
procedure TForm1.PaintBox1Paint(Sender: TObject);
var L,H : integer;
begin
L:=PaintBox1.Width div 2;
H:=PaintBox1.Height div 2;
with PaintBox1.canvas do
begin
brush.color:=Couleur[1];
rectangle(0,0,L,H);
brush.color:=Couleur[2];
rectangle(0,H,L,H*2);
brush.color:=Couleur[3];
rectangle(L,H,L*2,H*2);
brush.color:=Couleur[4];
rectangle(L,0,L*2,H);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
listeCouleur.Insert(0,listeCouleur.Strings[3]);
listeCouleur.Delete(4);
Couleur[1]:=strtoint(listeCouleur.Strings[0]);
Couleur[2]:=strtoint(listeCouleur.Strings[1]);
Couleur[3]:=strtoint(listeCouleur.Strings[2]);
Couleur[4]:=strtoint(listeCouleur.Strings[3]);
paintbox1.Invalidate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
listeCouleur:=TStringList.Create;
listeCouleur.add(inttostr(clred));
listeCouleur.add(inttostr(clyellow));
listeCouleur.add(inttostr(cllime));
listeCouleur.add(inttostr(clblue));
paintbox1.Invalidate;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Button1Click(nil);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Timer1.Enabled:=not(Timer1.Enabled);
end;
end. |
Partager