unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
btclose: TButton;
btatas: TButton;
btkiri: TButton;
btkanan: TButton;
btbawah: TButton;
btptr2: TButton;
btptr1: TButton;
btz1: TButton;
btz2: TButton;
btdef: TButton;
Image1: TImage;
procedure btatasClick(Sender: TObject);
procedure btbawahClick(Sender: TObject);
procedure btcloseClick(Sender: TObject);
procedure btdefClick(Sender: TObject);
procedure btkananClick(Sender: TObject);
procedure btkiriClick(Sender: TObject);
procedure btptr1Click(Sender: TObject);
procedure btptr2Click(Sender: TObject);
procedure btz1Click(Sender: TObject);
procedure btz2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
type
elemen=record
x,y:integer;
end;
var
Form1: TForm1;
objek: array[1..13] of elemen;
Tempobjek : array[1..13] of elemen;
sdt : real;
n, m, i : Integer;
implementation
{ TForm1 }
procedure TForm1.btcloseClick(Sender: TObject);
begin
Close;
end;
procedure TForm1.btdefClick(Sender: TObject);
begin
FormActivate(Sender);
end;
procedure TForm1.btkananClick(Sender: TObject);
begin
for i:=1 to 12 do
objek[i].x:=objek[i].x+5;
FormShow(Sender);
end;
procedure TForm1.btkiriClick(Sender: TObject);
begin
for i:=1 to 12 do
objek[i].x:=objek[i].x-5;
FormShow(Sender);
end;
procedure TForm1.btptr1Click(Sender: TObject);
begin
for i := 1 to 12 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].x:=Tempobjek[i].x;
objek[i].y:=Tempobjek[i].y;
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.btptr2Click(Sender: TObject);
begin
for i := 1 to 12 do
begin
n := objek[3].x;
m := objek[3].y;
objek[i].x:=objek[i].x-n;
objek[i].y:=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.btz1Click(Sender: TObject);
begin
for i:=1 to 12 do
Begin
objek[i].y:=objek[i].y * 2;
objek[i].x:=objek[i].x * 2;
end;
FormShow(Sender);
end;
procedure TForm1.btz2Click(Sender: TObject);
begin
for i:=1 to 12 do
Begin
objek[i].y:=objek[i].y div 2;
objek[i].x:=objek[i].x div 2;
end;
FormShow(Sender);
end;
procedure TForm1.btatasClick(Sender: TObject);
begin
for i:=1 to 12 do
objek[i].y:=objek[i].y-5;
FormShow(Sender);
end;
procedure TForm1.btbawahClick(Sender: TObject);
begin
for i:=1 to 12 do
objek[i].y:=objek[i].y+5;
FormShow(Sender);
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
objek[1].x := 250; objek[1].y := 150;
objek[2].x := 300; objek[2].y := 250;
objek[3].x := 200; objek[3].y := 250;
objek[4].x := 275; objek[4].y := 125;
objek[5].x := 325; objek[5].y := 225;
objek[6].x := 225; objek[6].y := 225;
objek[7].x := 250; objek[7].y := 150;
objek[8].x := 275; objek[8].y := 125;
objek[9].x := 300; objek[9].y := 250;
objek[10].x := 325; objek[10].y := 225;
objek[11].x := 200; objek[11].y := 250;
objek[12].x := 225; objek[12].y := 225;
//objek[13].x := 50; objek[13].y := 50;
//objek[14].x := 75; objek[14].y := 125;
//objek[15].x := 100; objek[15].y := 50;
//objek[16].x := 125; objek[16].y := 125;
FormShow(Sender);
end;
procedure TForm1.FormShow(Sender: TObject);
var
i: integer;
begin
Image1.Canvas.Rectangle(0,0,Image1.Width,Image1.Height);
Image1.Canvas.MoveTo(objek[3].x,objek[3].y);
for i:=1 to 3 do
begin
Image1.Canvas.LineTo(objek[i].x,objek[i].y);
end;
Image1.Canvas.MoveTo(objek[6].x,objek[6].y);
for i:=4 to 6 do
begin
Image1.Canvas.LineTo(objek[i].x,objek[i].y);
end;
Image1.Canvas.MoveTo(objek[8].x,objek[8].y);
for i:=7 to 8 do
begin
Image1.Canvas.LineTo(objek[i].x,objek[i].y);
end;
Image1.Canvas.MoveTo(objek[10].x,objek[10].y);
for i:=9 to 10 do
begin
Image1.Canvas.LineTo(objek[i].x,objek[i].y);
end;
Image1.Canvas.MoveTo(objek[12].x,objek[12].y);
for i :=11 to 12 do
begin
Image1.Canvas.LineTo(objek[i].x,objek[i].y);
end;
// Image1.Canvas.MoveTo(objek[16].x,objek[16].y);
// for i := 15 to 16 do
// begin
// Image1.Canvas.LineTo(objek[i].x,objek[i].y);
// end;
end;
initialization
{$I unit1.lrs}
end.