| Код | unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls;
type TForm1 = class(TForm) Timer1: TTimer; procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure FormPaint(Sender: TObject); private { Private declarations } public { Public declarations } procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND; end;
var Form1: TForm1;
implementation
{$R *.dfm}
var p : array[0..2] of TPoint = ((x: -20; y: -30), (x: 20; y: -30), (x: 20; y: 30));
r : TRect = (Left: 0; Top: 0; Right: 100; Bottom: 100); a : integer;
procedure TForm1.FormCreate(Sender: TObject); begin a := 0; end;
procedure TForm1.Timer1Timer(Sender: TObject); begin InvalidateRect(Handle, @r, true); end;
procedure TForm1.FormPaint(Sender: TObject); var i : integer; p2 : array[0..2] of TPoint; s, c : double; begin ValidateRect(Canvas.Handle, @r); PatBlt(Canvas.Handle, 0, 0, 100, 100, WHITENESS); a := (a + 10) mod 360; s := sin(a * Pi / 180); c := cos(a * Pi / 180); for i := 0 to 2 do begin p2[i].X := 50 + Round(p[i].X * c + p[i].Y * s); p2[i].Y := 50 + Round(p[i].X * s - p[i].Y * c); end;
Canvas.MoveTo(p2[2].X, p2[2].Y); for i := 0 to 2 do Canvas.LineTo(p2[i].X, p2[i].Y); end;
procedure TForm1.WMEraseBkgnd(var Message: TWMEraseBkgnd); begin inherited; // Message.Result := 0; end;
|
|