Bonjour,
Je vous propose un petit bout de code amusant pour dessiner cette animation :
je vous propose en petit jeu de présenter vos formules mathématiques permettant de donner d'autres effets sympa
voici le code placé dans un TPaintBox.OnPaint et animé par un Timer
le projet complet sous Delphi XE8 (mais il devrait fonctionner avec n'importe quelle version aux uses près)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 procedure TForm1.PaintBox1Paint(Sender: TObject); var t: Cardinal; d: Cardinal; i: Integer; r: TRect; x,y: Integer; w: Integer; cs, sn: Single; c: Integer; begin t := GetTickCount; if FTicks = 0 then begin d := 0; FTicks := t; end else begin d := (t - FTicks) mod 4000; end; with PaintBox1.Canvas do begin Brush.Color := Self.Color; FillRect(PaintBox1.ClientRect); x := PaintBox1.Width div 2; y := PaintBox1.Height div 2; w := 2 * x div 3; for i := 0 to 7 do begin c := 255 - 64 + Round(32 * Cos(PI * i / 4)); Brush.Color := RGB(c, c, c); SinCos(PI * ((1 + i/4) * Cos(PI * d / 4000)), cs, sn); r.Left := x + Round(w * cs) - 2; r.Top := y + Round(w * sn) - 2; r.Right := r.Left + 4; r.Bottom := r.Top + 4; FillRect(r); end; end; end;
Wait.zip
Partager