-
Notifications
You must be signed in to change notification settings - Fork 0
/
UMainForm.pas
127 lines (112 loc) · 2.86 KB
/
UMainForm.pas
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// UMainForm.pas - Demonstrate Projectile Motion Equation Main Form
// https://ardeshirv.github.io/Projectile/
// Copyright© 2002-2003 [email protected], Licensed under GPLv3+
unit UMainForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls, XPMan, UAbout;
type
TfrmMainForm = class(TForm)
lblV: TLabel;
Timer: TTimer;
lblVValue: TLabel;
lblDegree: TLabel;
VChanger: TTrackBar;
ButtonExit: TButton;
ButtonAbout: TButton;
lblDegreeValue: TLabel;
XPManifest: TXPManifest;
DegreeChanger: TTrackBar;
PanelOutput: TPanel;
Image: TImage;
procedure FormCreate(Sender: TObject);
procedure TimerTimer(Sender: TObject);
procedure ButtonExitClick(Sender: TObject);
procedure ButtonAboutClick(Sender: TObject);
procedure DegreeChangerChange(Sender: TObject);
private
bln: Boolean;
intTR: Integer;
procedure Clear;
end;
var
frmMainForm: TfrmMainForm;
const
PI_DIV_180 = 0.017453292519943295769236907684886;
implementation
{$R *.dfm}
procedure TfrmMainForm.Clear;
var
rect: TRect;
old, brh: TBrush;
begin
brh := TBrush.Create;
rect.Left := 0;
rect.Top := 0;
rect.Right := Image.Width;
rect.Bottom := Image.Height;
brh.Color := RGB(255,255,255);
old := Image.Canvas.Brush;
Image.Canvas.Brush := brh;
Image.Canvas.FillRect(rect);
Image.Canvas.Brush := old;
brh.Free;
end;
procedure TfrmMainForm.FormCreate(Sender: TObject);
begin
Clear;
intTR := 0;
bln := false;
DegreeChangerChange(Sender);
end;
procedure TfrmMainForm.TimerTimer(Sender: TObject);
var
rect :TRect;
inj :integer;
cosinus :double;
old, brh :TBrush;
begin
clear;
if bln then
begin
intTR := 0;
bln := false;
end;
inj := intTR;
rect.Left := intTR;
brh := TBrush.Create;
cosinus := Cos(PI_DIV_180 * DegreeChanger.Position);
rect.Top := Image.Height - trunc((-9.8 * inj * inj)
/ (2 * VChanger.Position * VChanger.Position * cosinus * cosinus)
+ inj * (sin(PI_DIV_180 * DegreeChanger.Position) / cosinus)) - 10;
rect.Right := intTR + 10;
rect.Bottom := rect.Top + 10;
brh.Color := RGB(0, 0, 255);
old := Image.Canvas.Brush;
Image.Canvas.Brush := brh;
Image.Canvas.Ellipse(rect);
Image.Canvas.Brush := old;
brh.Free;
inc(intTR, 5);
if (intTR >= Image.Width) or (rect.Top >= Image.Height + 20) then
intTR := 0;
end;
procedure TfrmMainForm.DegreeChangerChange(Sender: TObject);
begin
bln := true;
lblVValue.Caption := inttostr(VChanger.Position) + '(m/s)';
lblDegreeValue.Caption := inttostr(DegreeChanger.Position) + ' Degree';
end;
procedure TfrmMainForm.ButtonAboutClick(Sender: TObject);
var AboutBox: TAboutBox;
begin
AboutBox := TAboutBox.Create(self);
AboutBox.ShowModal;
AboutBox.Free;
end;
procedure TfrmMainForm.ButtonExitClick(Sender: TObject);
begin
Close;
end;
end.