Naum
2011-08-04 10:21:21
This is just something which has been lying on my hard drive for the past 6 odd months.
It basically simulates a projectile flight path (draws it on a canvas) but comes with a neat form in which you can change some of the settings using the slider or scrollbar at the bottom: Initial (horizontal) velocity, angle of projection [IN DEGREES] and "Drag Factor". The Drag factor is basically a way of controlling a constant resistance which slows the projectile mid flight, it's further explained on the form :).
I've tried to comment it so you can understand the code, all the program uses are the two kinematic equations: s= ut + 0.5at^2 and v^2 = u^2 + 2as albeit re-arrangements of the two.
This was originally made in SCAR, but I've (tried) to port it to simba, projectile drawing is quicker (less laggy) in scar although this isn't a dire problem.
Extra info, such as flight time, max height and final velocity are also displayed if anyone is interested.
The script was going to have the option of using the co-efficient of restitution to simulate the projectile bouncing on the ground, however I cba to implement it plus the canvas isn't that big.
One last thing; some, if not many, of the settings you may try will "launch" the projectile off the canvas (e.g 60m/s at 45 degrees). lol. If you are interested to see how this would look like - you should just reduce the const Scale to something like 1.1.
Enjoy, tested on scar 3.25 BETA and the latest simba
SCAR:
SIMBA (tweaked a bit):
It basically simulates a projectile flight path (draws it on a canvas) but comes with a neat form in which you can change some of the settings using the slider or scrollbar at the bottom: Initial (horizontal) velocity, angle of projection [IN DEGREES] and "Drag Factor". The Drag factor is basically a way of controlling a constant resistance which slows the projectile mid flight, it's further explained on the form :).
I've tried to comment it so you can understand the code, all the program uses are the two kinematic equations: s= ut + 0.5at^2 and v^2 = u^2 + 2as albeit re-arrangements of the two.
This was originally made in SCAR, but I've (tried) to port it to simba, projectile drawing is quicker (less laggy) in scar although this isn't a dire problem.
Extra info, such as flight time, max height and final velocity are also displayed if anyone is interested.
The script was going to have the option of using the co-efficient of restitution to simulate the projectile bouncing on the ground, however I cba to implement it plus the canvas isn't that big.
One last thing; some, if not many, of the settings you may try will "launch" the projectile off the canvas (e.g 60m/s at 45 degrees). lol. If you are interested to see how this would look like - you should just reduce the const Scale to something like 1.1.
Enjoy, tested on scar 3.25 BETA and the latest simba
SCAR:
program New;
Const Scale = 3.5;
TimeInc = 100; //How many points to plot for vertical
Type
VelocityComponent = Record
H, V : Extended;
End;
var
// Form variables.
frmDesign : TForm;
GroupBox1 : TGroupBox;
Label1 : TLabel;
Label2 : TLabel;
Label3 : TLabel;
Edit1 : TEdit;
Timer1 : TTimer;
ScrollBar1 : TScrollBar;
Edit2 : TEdit;
ScrollBar2 : TScrollBar;
Edit3 : TEdit;
ScrollBar3 : TScrollBar;
Button1 : TButton;
CheckBox1 : TCheckBox;
GroupBox2 : TGroupBox;
Memo1 : TMemo;
Button2 : TButton;
GroupBox3 : TGroupBox;
Button3 : TButton;
Image1 : TImage;
Var
U : VelocityComponent; {U = initial velocity}
A : Extended; {A = Acceleration (9.81ms^-2)}
V : VelocityComponent; {V = final velocity}
Hs, Vs : Extended; {Hs - Horizontal Displacement, Vs - Vertical Displacement}
Time : Extended;
DragFactor : Integer;
Procedure DoProjectile;
Begin
U.H := StrToInt(Edit1.Text) * Cos(Radians(StrToFloat(Edit2.Text) + 0.0));
U.V := StrToInt(Edit1.Text) * Sin(Radians(StrToFloat(Edit2.Text) + 0.0));
DragFactor := StrToInt(Edit3.Text);
A := 9.81; //taking downwards as positive, only relevent in the vertical plane
{Time for total flight as this can pass through H, V dimensions}
Time := (U.V / (A/2)); {using s=ut+0.5*at^2}
{Range of Projectile (Hs)}
Hs := (U.H * Time); {using same equation, since A = 0 then the horizontal eq is just s=ut}
{Vs highest point when velocity = 0}
Vs := ((U.V*U.V) / (A*2)) {re-arrangement of v^2 = u^2 +2as}
{ WriteLn(Vs);
WriteLn(Hs);
WriteLn(Time); }
End;
Procedure OnTimer(Sender : TObject);
Begin
Edit1.Text := IntToStr(ScrollBar1.Position);
Edit2.Text := IntToStr(ScrollBar2.Position);
Edit3.Text := FloatToStr((ScrollBar3.Position) + 0.0);
End;
Procedure Draw(Sender : TObject);
Var I, II : Integer;
Coords : TPointArray;
TimeX : Extended;
VeloX, VeloY, DragX, DragY, FinalMag, MaxHeight : Extended;
Begin
Memo1.Clear;
Memo1.Lines.Add('Max Height Reached:');
Memo1.Lines.Add('');
Memo1.Lines.Add('Time Taken for Flight:');
Memo1.Lines.Add('');
Memo1.Lines.Add('Final Velocity:');
Image1.Canvas.Pen.Color := clBlack;
Image1.Canvas.Brush.Color := clBlack;
Image1.Canvas.Pen.Width := 1;
DoProjectile;
Repeat
TimeX := TimeX + (Time/TimeInc);
Inc(I);
SetLength(Coords, I)
VeloX := (U.H-DragX);
VeloY := (U.V-DragY);
DragX := DragX + (0.02 * DragFactor);
DragY := DragY + (0.01 * DragFactor);
Coords[I- 1].X := Round((VeloX* TimeX) * Scale);
Coords[I- 1].Y := Round(183 - ((VeloY*TimeX) + (0.5*-A*Sqr(TimeX))) * Scale); {s=ut+0.5at^2}
{ WriteLn(Coords[I- 1].X)
WriteLn(Coords[I- 1].Y); }
Until(TimeX >= Time);
FinalMag := Sqrt(Sqr(VeloX) + Sqr(VeloY)); {final velocity (maginitude)}
MaxHeight := (Sqr(VeloY) / (2 * A)) {when v = 0 in v^2 = u^2 + 2as}
Memo1.Lines.Insert(1, Format('%.5f', [MaxHeight]) + ' meters'); {max height}
Memo1.Lines.Insert(4, Format('%.5f', [Time]) + ' seconds'); {Time taken}
Memo1.Lines.Insert(7, Format('%.5f', [FinalMag]) + ' ms^-1'); {final velocity}
{ For I := 0 To High(Coords) Do ignore
Begin
Coords[I].Y := 183 - Round((-(1/ Hs) * (Sqr(I+ 0.0) - Hs * I)) * Scale);
WriteLn(Coords[I].Y);
End;
For II := 0 To High(Coords) Do
Begin
Coords[II].X := U.H*TimeX;
// WriteLn(Coords[II].X);
End; }
Image1.Canvas.MoveTo(Coords[0].X, Coords[0].Y);
For I := 0 To High(Coords) Do
Begin
Image1.Canvas.LineTo(Coords[I].X, Coords[I].Y);
Image1.Canvas.MoveTo(Coords[I].X, Coords[I].Y);
Wait(1);
FrmDesign.Refresh;
End;
//Image1.Canvas.PolyLine(Coords);
// Image1.Canvas.Arc(0, 183, Round(Hs/2)*10, 193 - Round(Vs)*10, Round(Hs)*10, 183, 0, 150);
frmDesign.Refresh;
End;
Procedure ClearCanvas(Sender : TObject);
Begin
Image1.Canvas.Brush.Color := clBtnface;
Image1.Canvas.Pen.Color := ClGreen;
Image1.Canvas.Pen.Width := 2;
Image1.Canvas.Rectangle(1, -1, 452, 185);
FrmDesign.Refresh;
End;
procedure Form;
begin
frmDesign := CreateForm;
frmDesign.Left := 270;
frmDesign.Top := 130;
frmDesign.Width := 657;
frmDesign.Height := 403;
frmDesign.Caption := 'Projectile Motion';
frmDesign.Color := clBtnFace;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.PixelsPerInch := 96;
Timer1 := TTimer.Create(FrmDesign);
Timer1.Interval := 50;
Timer1.Enabled := True;
Timer1.OnTimer := @OnTimer;
GroupBox1 := TGroupBox.Create(frmDesign);
GroupBox1.Parent := frmDesign;
GroupBox1.Left := 8;
GroupBox1.Top := 8;
GroupBox1.Width := 625;
GroupBox1.Height := 105;
GroupBox1.Caption :=
'Projectile Motion Control Settings - (Initial Velocity of Projec' +
'tile, Angle of Projection, Drag Factor of Projectile)'
GroupBox1.TabOrder := 0;
GroupBox1.Font.Size := 9;
Label1 := TLabel.Create(GroupBox1);
Label1.Parent := GroupBox1;
Label1.Left := 16;
Label1.Top := 24;
Label1.Width := 101;
Label1.Height := 13;
Label1.Caption := 'Initial Velocity (ms^-1)';
Label2 := TLabel.Create(GroupBox1);
Label2.Parent := GroupBox1;
Label2.Left := 136;
Label2.Top := 24;
Label2.Width := 138;
Label2.Height := 13;
Label2.Caption := 'Angle of Projection (Degrees)';
Label3 := TLabel.Create(GroupBox1);
Label3.Parent := GroupBox1;
Label3.Left := 296;
Label3.Top := 24;
Label3.Width := 251;
Label3.Height := 13;
Label3.Caption := '"Drag Factor": 0 - Negligible, 10 - Severe';
ScrollBar1 := TScrollBar.Create(GroupBox1);
ScrollBar1.Parent := GroupBox1;
ScrollBar1.Left := 16;
ScrollBar1.Top := 80;
ScrollBar1.Width := 89;
ScrollBar1.Height := 17;
ScrollBar1.Max := 60;
ScrollBar1.Position := 35;
ScrollBar1.PageSize := 0;
ScrollBar1.TabOrder := 0;
Edit1 := TEdit.Create(GroupBox1);
Edit1.Parent := GroupBox1;
Edit1.Left := 16;
Edit1.Top := 48;
Edit1.Width := 65;
Edit1.Height := 21;
Edit1.TabOrder := 1;
Edit1.Text := '35';
Edit1.ReadOnly := True;
Edit2 := TEdit.Create(GroupBox1);
Edit2.Parent := GroupBox1;
Edit2.Left := 136;
Edit2.Top := 48;
Edit2.Width := 65;
Edit2.Height := 21;
Edit2.TabOrder := 2;
Edit2.Text := '60';
Edit2.ReadOnly := True;
ScrollBar2 := TScrollBar.Create(GroupBox1);
ScrollBar2.Parent := GroupBox1;
ScrollBar2.Left := 136;
ScrollBar2.Top := 80;
ScrollBar2.Width := 81;
ScrollBar2.Height := 17;
ScrollBar2.Max := 90;
ScrollBar2.PageSize := 0;
ScrollBar2.TabOrder := 3;
ScrollBar2.Position := 60;
Edit3 := TEdit.Create(GroupBox1);
Edit3.Parent := GroupBox1;
Edit3.Left := 296;
Edit3.Top := 48;
Edit3.Width := 57;
Edit3.Height := 21;
Edit3.TabOrder := 4;
Edit3.Text := '0.4';
Edit3.ReadOnly := True;
ScrollBar3 := TScrollBar.Create(GroupBox1);
ScrollBar3.Parent := GroupBox1;
ScrollBar3.Left := 296;
ScrollBar3.Top := 80;
ScrollBar3.Width := 97;
ScrollBar3.Height := 17;
ScrollBar3.Max := 10;
ScrollBar3.PageSize := 0;
ScrollBar3.TabOrder := 5;
ScrollBar3.Position := 0;
Button1 := TButton.Create(GroupBox1);
Button1.Parent := GroupBox1;
Button1.Left := 456;
Button1.Top := 56;
Button1.Width := 153;
Button1.Height := 41;
Button1.Caption := 'Go!';
Button1.OnClick := @Draw;
GroupBox2 := TGroupBox.Create(frmDesign);
GroupBox2.Parent := frmDesign;
GroupBox2.Left := 480;
GroupBox2.Top := 120;
GroupBox2.Width := 153;
GroupBox2.Height := 203;
GroupBox2.Caption := ' Extra Information';
GroupBox2.TabOrder := 1;
Memo1 := TMemo.Create(GroupBox2);
Memo1.Parent := GroupBox2;
Memo1.Left := 16;
Memo1.Top := 24;
Memo1.Width := 121;
Memo1.Height := 161;
Memo1.Lines.Add('Max Height Reached:');
Memo1.Lines.Add('');
Memo1.Lines.Add('Time Taken for Flight:');
Memo1.Lines.Add('');
Memo1.Lines.Add('Final Velocity:');
Memo1.TabOrder := 0;
GroupBox3 := TGroupBox.Create(frmDesign);
GroupBox3.Parent := frmDesign;
GroupBox3.Left := 8;
GroupBox3.Top := 120;
GroupBox3.Width := 465;
GroupBox3.Height := 233;
GroupBox3.SendToBack;
GroupBox3.Caption := 'Diagram of Projectile Flight: ';
GroupBox3.TabOrder := 2;
GroupBox3.Font.Size := 11;
Image1 := TImage.Create(frmDesign);
Image1.Parent := frmDesign;
Image1.Left := 13;
Image1.Top := 135;
Image1.Enabled := True;
Image1.Width := 450;
Image1.Height := 185;
Image1.Visible := True;
Image1.OnClick := @Draw;
Image1.Canvas.Brush.Color := clBtnface;
Image1.Canvas.Pen.Color := ClGreen;
Image1.Canvas.Pen.Width := 2;
Image1.Canvas.Rectangle(1, -1, 452, 185);
Button3 := TButton.Create(GroupBox3);
Button3.Parent := GroupBox3;
Button3.Left := 368;
Button3.Top := 208;
Button3.Width := 91;
Button3.Height := 17;
Button3.Caption := 'Clear Canvas';
Button3.TabOrder := 0;
Button3.Font.Size := 8;
Button3.OnClick := @ClearCanvas;
end;
procedure SafeForm;
var
v : TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('Form', v);
end;
procedure ShowFormModal;
begin
frmDesign.ShowModal;
end;
procedure SafeShowFormModal;
var
v : TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('ShowFormModal', v);
end;
procedure MainForm;
begin
SafeForm;
SafeShowFormModal;
FreeForm(frmDesign);
end;
begin
ClearDebug;
MainForm;
end.SIMBA (tweaked a bit):
program New;
Const Scale = 3.5;
TimeInc = 50; //How many points to plot for vertical
Type
VelocityComponent = Record
H, V : Extended;
End;
var
// Form variables.
frmDesign : TForm;
GroupBox1 : TGroupBox;
Label1 : TLabel;
Label2 : TLabel;
Label3 : TLabel;
Edit1 : TEdit;
Timer1 : TTimer;
ScrollBar1 : TScrollBar;
Edit2 : TEdit;
ScrollBar2 : TScrollBar;
Edit3 : TEdit;
ScrollBar3 : TScrollBar;
Button1 : TButton;
CheckBox1 : TCheckBox;
GroupBox2 : TGroupBox;
Memo1 : TMemo;
Button2 : TButton;
GroupBox3 : TGroupBox;
Button3 : TButton;
Image1 : TImage;
Var
U : VelocityComponent; {U = initiansl velocity}
A : Extended; {A = Acceleration (9.8ms^-2)}
V : VelocityComponent; {V = final velocity}
Hs, Vs : Extended; {Hs - Horizontal Displacement, Vs - Vertical Displacement}
Time : Extended;
DragFactor : Integer;
Procedure DoProjectile;
Begin
U.H := StrToInt(Edit1.Text) * Cos(Radians(StrToFloat(Edit2.Text) + 0.0));
U.V := StrToInt(Edit1.Text) * Sin(Radians(StrToFloat(Edit2.Text) + 0.0));
DragFactor := StrToInt(Edit3.Text);
A := 9.81; //taking downwards as positive, only relevent in the vertical plane
{Time for total flight as this can pass through H, V dimensions}
Time := (U.V / (A/2)); {using s=ut+0.5*at^2}
{Range of Projectile (Hs)}
Hs := (U.H * Time); {using same equation, since A = 0 then the horizontal eq is just s=ut}
{Vs highest point when velocity = 0}
Vs := ((U.V*U.V) / (A*2)) {re-arrangement of v^2 = u^2 +2as}
{ WriteLn(Vs);
WriteLn(Hs);
WriteLn(Time); }
End;
Procedure OnTimer(Sender : TObject);
Begin
Edit1.Text := IntToStr(ScrollBar1.Position);
Edit2.Text := IntToStr(ScrollBar2.Position);
Edit3.Text := FloatToStr((ScrollBar3.Position) + 0.0);
End;
Procedure Draw(Sender : TObject);
Var I, II : Integer;
Coords : TPointArray;
TimeX : Extended;
VeloX, VeloY, DragX, DragY, FinalMag, MaxHeight : Extended;
Begin
Memo1.Clear;
Memo1.Lines.Add('Max Height Reached:');
Memo1.Lines.Add('');
Memo1.Lines.Add('Time Taken for Flight:');
Memo1.Lines.Add('');
Memo1.Lines.Add('Final Velocity:');
Image1.Canvas.Pen.Color := clBlack;
Image1.Canvas.Brush.Color := clBlack;
Image1.Canvas.Pen.Width := 1;
DoProjectile;
Repeat
TimeX := TimeX + (Time/TimeInc);
Inc(I);
SetLength(Coords, I)
VeloX := (U.H-DragX);
VeloY := (U.V-DragY);
DragX := DragX + (0.02 * DragFactor);
DragY := DragY + (0.01 * DragFactor);
Coords[I- 1].X := Round((VeloX* TimeX) * Scale);
Coords[I- 1].Y := Round(183 - ((VeloY*TimeX) + (0.5*-A*Sqr(TimeX))) * Scale); {s=ut+0.5at^2}
{ WriteLn(Coords[I- 1].X)
WriteLn(Coords[I- 1].Y); }
Until(TimeX >= Time);
FinalMag := Sqrt(Sqr(VeloX) + Sqr(VeloY)); {final velocity (maginitude)}
MaxHeight := (Sqr(VeloY) / (2 * A)) {when v = 0 in v^2 = u^2 + 2as}
Memo1.Lines.Insert(1, Format('%.5f', [MaxHeight]) + ' meters'); {max height}
Memo1.Lines.Insert(4, Format('%.5f', [Time]) + ' seconds'); {Time taken}
Memo1.Lines.Insert(7, Format('%.5f', [FinalMag]) + ' ms^-1'); {final velocity}
{ For I := 0 To High(Coords) Do ignore
Begin
Coords[I].Y := 183 - Round((-(1/ Hs) * (Sqr(I+ 0.0) - Hs * I)) * Scale);
WriteLn(Coords[I].Y);
End;
For II := 0 To High(Coords) Do
Begin
Coords[II].X := U.H*TimeX;
// WriteLn(Coords[II].X);
End; }
Image1.Canvas.MoveTo(Coords[0].X, Coords[0].Y);
For I := 0 To High(Coords) Do
Begin
Image1.Canvas.LineTo(Coords[I].X, Coords[I].Y);
Image1.Canvas.MoveTo(Coords[I].X, Coords[I].Y);
FrmDesign.Refresh;
End;
//Image1.Canvas.PolyLine(Coords);
// Image1.Canvas.Arc(0, 183, Round(Hs/2)*10, 193 - Round(Vs)*10, Round(Hs)*10, 183, 0, 150);
frmDesign.Refresh;
End;
Procedure ClearCanvas(Sender : TObject);
Begin
Image1.Canvas.Brush.Color := clBtnface;
Image1.Canvas.Pen.Color := ClGreen;
Image1.Canvas.Pen.Width := 2;
Image1.Canvas.Rectangle(1, -1, 452, 185);
FrmDesign.Refresh;
End;
procedure Form;
begin
frmDesign := TForm.Create(nil);
frmDesign.Left := 270;
frmDesign.Top := 130;
frmDesign.Width := 657;
frmDesign.Height := 403;
frmDesign.Caption := 'Projectile Motion';
frmDesign.Color := clBtnFace;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.PixelsPerInch := 96;
Timer1 := TTimer.Create(FrmDesign);
Timer1.Interval := 50;
Timer1.Enabled := True;
Timer1.OnTimer := @OnTimer;
GroupBox1 := TGroupBox.Create(frmDesign);
GroupBox1.Parent := frmDesign;
GroupBox1.Left := 8;
GroupBox1.Top := 8;
GroupBox1.Width := 625;
GroupBox1.Height := 125;
GroupBox1.Caption :=
'Projectile Motion Control Settings - (Initial Velocity of Projec' +
'tile, Angle of Projection, Drag Factor of Projectile)'
GroupBox1.TabOrder := 0;
GroupBox1.Font.Size := 9;
Label1 := TLabel.Create(GroupBox1);
Label1.Parent := GroupBox1;
Label1.Left := 16;
Label1.Top := 24;
Label1.Width := 101;
Label1.Height := 13;
Label1.Caption := 'Initial Velocity (ms^-1)';
Label2 := TLabel.Create(GroupBox1);
Label2.Parent := GroupBox1;
Label2.Left := 136;
Label2.Top := 24;
Label2.Width := 138;
Label2.Height := 13;
Label2.Caption := 'Angle of Projection (Degrees)';
Label3 := TLabel.Create(GroupBox1);
Label3.Parent := GroupBox1;
Label3.Left := 296;
Label3.Top := 24;
Label3.Width := 251;
Label3.Height := 13;
Label3.Caption := '"Drag Factor": 0 - Negligible, 10 - Severe';
ScrollBar1 := TScrollBar.Create(GroupBox1);
ScrollBar1.Parent := GroupBox1;
ScrollBar1.Left := 16;
ScrollBar1.Top := 80;
ScrollBar1.Width := 89;
ScrollBar1.Height := 17;
ScrollBar1.Max := 60;
ScrollBar1.Position := 35;
//ScrollBar1.PageSize := 0;
ScrollBar1.TabOrder := 0;
Edit1 := TEdit.Create(GroupBox1);
Edit1.Parent := GroupBox1;
Edit1.Left := 16;
Edit1.Top := 48;
Edit1.Width := 65;
Edit1.Height := 21;
Edit1.TabOrder := 1;
Edit1.Text := '35';
Edit1.ReadOnly := True;
Edit2 := TEdit.Create(GroupBox1);
Edit2.Parent := GroupBox1;
Edit2.Left := 136;
Edit2.Top := 48;
Edit2.Width := 65;
Edit2.Height := 21;
Edit2.TabOrder := 2;
Edit2.Text := '60';
Edit2.ReadOnly := True;
ScrollBar2 := TScrollBar.Create(GroupBox1);
ScrollBar2.Parent := GroupBox1;
ScrollBar2.Left := 136;
ScrollBar2.Top := 80;
ScrollBar2.Width := 81;
ScrollBar2.Height := 17;
ScrollBar2.Max := 90;
//ScrollBar2.PageSize := 0;
ScrollBar2.TabOrder := 3;
ScrollBar2.Position := 60;
Edit3 := TEdit.Create(GroupBox1);
Edit3.Parent := GroupBox1;
Edit3.Left := 296;
Edit3.Top := 48;
Edit3.Width := 57;
Edit3.Height := 21;
Edit3.TabOrder := 4;
Edit3.Text := '0.4';
Edit3.ReadOnly := True;
ScrollBar3 := TScrollBar.Create(GroupBox1);
ScrollBar3.Parent := GroupBox1;
ScrollBar3.Left := 296;
ScrollBar3.Top := 80;
ScrollBar3.Width := 97;
ScrollBar3.Height := 17;
ScrollBar3.Max := 10;
//ScrollBar3.PageSize := 0;
ScrollBar3.TabOrder := 5;
ScrollBar3.Position := 0;
Button1 := TButton.Create(GroupBox1);
Button1.Parent := GroupBox1;
Button1.Left := 456;
Button1.Top := 56;
Button1.Width := 153;
Button1.Height := 41;
Button1.Caption := 'Go!';
Button1.OnClick := @Draw;
GroupBox2 := TGroupBox.Create(frmDesign);
GroupBox2.Parent := frmDesign;
GroupBox2.Left := 480;
GroupBox2.Top := 140;
GroupBox2.Width := 153;
GroupBox2.Height := 223;
GroupBox2.Caption := ' Extra Information';
GroupBox2.TabOrder := 1;
Memo1 := TMemo.Create(GroupBox2);
Memo1.Parent := GroupBox2;
Memo1.Left := 16;
Memo1.Top := 24;
Memo1.Width := 121;
Memo1.Height := 161;
Memo1.Lines.Add('Max Height Reached:');
Memo1.Lines.Add('');
Memo1.Lines.Add('Time Taken for Flight:');
Memo1.Lines.Add('');
Memo1.Lines.Add('Final Velocity:');
Memo1.TabOrder := 0;
GroupBox3 := TGroupBox.Create(frmDesign);
GroupBox3.Parent := frmDesign;
GroupBox3.Left := 8;
GroupBox3.Top := 135;
GroupBox3.Width := 465;
GroupBox3.Height := 243;
GroupBox3.SendToBack;
GroupBox3.Caption := 'Diagram of Projectile Flight: ';
GroupBox3.TabOrder := 2;
GroupBox3.Font.Size := 11;
Image1 := TImage.Create(frmDesign);
Image1.Parent := frmDesign;
Image1.Left := 13;
Image1.Top := 160;
Image1.Enabled := True;
Image1.Width := 450;
Image1.Height := 185;
Image1.Visible := True;
Image1.OnClick := @Draw;
Image1.Canvas.Brush.Color := clBtnface;
Image1.Canvas.Pen.Color := ClGreen;
Image1.Canvas.Pen.Width := 2;
Image1.Canvas.Rectangle(1, -1, 452, 185);
Button3 := TButton.Create(GroupBox3);
Button3.Parent := GroupBox3;
Button3.Left := 368;
Button3.Top := 208;
Button3.Width := 91;
Button3.Height := 17;
Button3.Caption := 'Clear Canvas';
Button3.TabOrder := 0;
Button3.Font.Size := 8;
Button3.OnClick := @ClearCanvas;
end;
procedure SafeForm;
var
v : TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('Form', v);
end;
procedure ShowFormModal;
begin
frmDesign.ShowModal;
end;
procedure SafeShowFormModal;
var
v : TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('ShowFormModal', v);
end;
procedure MainForm;
begin
SafeForm;
SafeShowFormModal;
FrmDesign.Free;
end;
begin
ClearDebug;
MainForm;
end.