unit Unit1;
interface uses
Windows,
Messages,
SysUtils,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
ExtCtrls,
StdCtrls;
{
object Form1: TForm1
Left = 184
Top = 122
AutoScroll = False
Caption = 'Form1'
ClientHeight = 365
ClientWidth = 565
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 64
Top = 14
Width = 11
Height = 13
Caption = 'px'
end
object Label2: TLabel
Left = 64
Top = 39
Width = 13
Height = 13
Caption = 'ms'
end
object PaintBox1: TPaintBox
Left = 84
Top = 0
Width = 481
Height = 365
Align = alRight
Anchors = [akLeft, akTop, akRight, akBottom]
OnPaint = PaintBox1Paint
end
object Edit1: TEdit
Left = 4
Top = 9
Width = 60
Height = 21
TabOrder = 0
Text = '32'
OnChange = Edit1Change
end
object Edit2: TEdit
Left = 4
Top = 35
Width = 60
Height = 21
TabOrder = 1
Text = '3000'
OnChange = Edit2Change
end
object Timer1: TTimer
Interval = 20
OnTimer = Timer1Timer
Left = 5
Top = 63
end
end
}
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
PaintBox1: TPaintBox;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Edit2Change(Sender: TObject);
procedure PaintBox1Paint(Sender: TObject);
private
Cycle,Radius:Integer;
Angle:Double;
protected
procedure WmGetMinMaxInfo(var Msg:TWMGetMinMaxInfo);message WM_GETMINMAXINFO;
public
end;
var Form1:TForm1;
implementation uses
Math;
{$R *.DFM}
procedure TForm1.WmGetMinMaxInfo(var Msg:TWMGetMinMaxInfo);//message WM_GETMINMAXINFO;
begin
Msg.MinMaxInfo.ptMinTrackSize:=Point(300,230);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Angle:=Angle+2*Pi*Timer1.Interval/Cycle;
PaintBox1.Invalidate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1Change(Sender);
Edit2Change(Sender);
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
try
Radius:=StrToInt(Edit1.Text);
except
end;
end;
procedure TForm1.Edit2Change(Sender: TObject);
begin
try
Cycle:=StrToInt(Edit2.Text);
except
end;
end;
procedure TForm1.PaintBox1Paint(Sender: TObject);
var W,H,R,X,Y,dx,dy:Integer;
begin
W:=PaintBox1.Width-2;
X:=(W)shr(1);
H:=PaintBox1.Height-2;
Y:=(H)shr(1);
R:=((min(W,H))shr(1))-Radius;
PaintBox1.Canvas.Brush.Style:=bsClear;
PaintBox1.Canvas.Pen.Style:=psSolid;
PaintBox1.Canvas.Pen.Color:=clGray;
PaintBox1.Canvas.Ellipse(X-R,Y-R,X+R,Y+R);
dy:=Round(Y+R*sin(Angle));
dx:=Round(X+R*cos(Angle));
PaintBox1.Canvas.Pen.Style:=psClear;
PaintBox1.Canvas.Brush.Style:=bsSolid;
PaintBox1.Canvas.Brush.Color:=clNavy;
PaintBox1.Canvas.Ellipse(dx-Radius,dy-Radius,dx+Radius,dy+Radius);
end;
end.