Среда программирования:
Embarcadero® Delphi® XE Version 15.0
unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; type TForm1 = class(TForm) Timer1: TTimer; Image1: TImage; procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); private { Private declarations } Procedure RotateRect; public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.FormCreate(Sender: TObject); begin DoubleBuffered := true; end; procedure TForm1.RotateRect; Const N = 55; DT = 20; SD = 0; Const IC : Integer = 250; ID : ShortInt = -1; Var Col : TColor; RC, GC, BC : Integer; // Составляющие цвета Pnt : Array [1..4] of TPoint; mx, my : Integer; d : ShortInt; i : Integer; begin With Image1 do begin Pnt[1].x := SD; Pnt[1].y := SD; Pnt[2].x := Width - SD; Pnt[2].y := SD; Pnt[3].x := Width - SD; Pnt[3].y := Height - SD; Pnt[4].x := SD; Pnt[4].y := Height - SD; GC :=0; RC := 0; BC := IC; d := id; Col := RGB( BC, GC, BC); Canvas.Pen.Color := Col; Canvas.Brush.Color := Col; Canvas.Polygon( Pnt); For i:=1 to N do begin mx := Pnt[1].x; my := Pnt[1].y; Pnt[1].x := Pnt[1].x + (Pnt[2].x - Pnt[1].x) div DT; Pnt[1].y := Pnt[1].y + (Pnt[2].y - Pnt[1].y) div DT; Pnt[2].x := Pnt[2].x + (Pnt[3].x - Pnt[2].x) div DT; Pnt[2].y := Pnt[2].y + (Pnt[3].y - Pnt[2].y) div DT; Pnt[3].x := Pnt[3].x + (Pnt[4].x - Pnt[3].x) div DT; Pnt[3].y := Pnt[3].y + (Pnt[4].y - Pnt[3].y) div DT; Pnt[4].x := Pnt[4].x + (mx - Pnt[4].x) div DT; Pnt[4].y := Pnt[4].y + (my - Pnt[4].y) div DT; if BC >= 255 then d := -1; if BC <= 0 then d := 1; BC := BC + d * 5; Col := RGB( BC, GC, BC); Canvas.Pen.Color := Col; Canvas.Brush.Color := Col; Canvas.Polygon( Pnt); end; if IC >= 255 then begin Id := 1; end; if IC <= 0 then begin Id := -1; end; IC := IC - id * 5; end; end; procedure TForm1.Timer1Timer(Sender: TObject); begin RotateRect; end; end.
Прикрепленный файл | Размер |
---|---|
Исходные коды и исполняемый файл | 215.1 кб |