unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ExtCtrls, Buttons, StdCtrls;
type
{ TForm1 }
Elemen=record
x,y: integer;
end;
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Image1: TImage;
Panel1: TPanel;
Panel2: TPanel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure GroupBox1Click(Sender: TObject);
procedure Panel1Click(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
Objek : array [1..5] of elemen;
x,y,i : integer;
implementation
{ TForm1 }
procedure TForm1.GroupBox1Click(Sender: TObject);
begin
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
Objek[1].x := 50; Objek[1].y := 100;
Objek[2].x := 150; Objek[2].y := 100;
Objek[3].x := 150; Objek[3].y := 50;
Objek[4].x := 50; Objek[4].y := 50;
FormShow (Sender);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Image1.Canvas.Rectangle(0,0,Image1.Width,Image1.Height);
Image1.Canvas.MoveTo(Objek[4].x,Objek[4].y);
for i:= 1 to 4 do
Image1.Canvas.LineTo(Objek[i].x,Objek[i].y);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
for i:=1 to 4 do
Objek[i].y:=Objek[i].y-4;
FormShow (Sender);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
for i:=1 to 4 do
Objek[i].x:=Objek[i].x+4;
FormShow (Sender)
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
for i:=1 to 4 do
Objek[i].y:=Objek[i].y+4 ;
FormShow (Sender);
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
for i:=1 to 5 do
Objek[i].x:=Objek[i].x-4;
FormShow (Sender);
end;
procedure TForm1.Button5Click(Sender: TObject);
var
Tempobjek: array[1..5] of elemen;
Sdt: real;
begin
for i:=1 to 4 do
begin
Objek[i].x:=Objek[i].x-Image1.Width div 2;
Objek[i].y:=Objek[i].y-Image1.Height div 2;
Sdt:=10*pi/180;
Tempobjek[i].x:=round(Objek[i].x*cos(Sdt)-Objek[i].y*sin(Sdt));
Tempobjek[i].y:=round(Objek[i].x*sin(Sdt)-Objek[i].y*cos(Sdt));
Objek[i]:=Tempobjek[i];
Objek[i].x:=Objek[i].x+Image1.Width div 2;
Objek[i].y:=Objek[i].y+Image1.Height div 2;
end;
FormShow (Sender);
end;
procedure TForm1.Button6Click(Sender: TObject);
var
TempObjek: array[1..5] of elemen;
n,m : integer;
Sdt : real;
begin
for i:= 1 to 4 do
begin
n:= Objek[1].x;
m:= Objek[1].y;
Objek[i].x:=Objek[i].x-n;
Objek[i].x:=Objek[i].y-m;
Sdt:=10*pi/180;
TempObjek[i].x:=round(Objek[i].x*cos(Sdt)-Objek[i].y*sin(Sdt));
TempObjek[i].y:=round(Objek[i].x*sin(Sdt)-Objek[i].y*cos(Sdt));
Objek[i]:=TempObjek[i];
Objek[i].x:=Objek[i].x+n;
Objek[i].y:=Objek[i].y+m;
end;
FormShow(Sender);
end;
procedure TForm1.Panel1Click(Sender: TObject);
begin
end;
procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
end;
initialization
{$I unit1.lrs}
end.