kali ini saya ingin membagikan sedikit ilmu yang saya dapat selama pelajaran. yaitu coding membuat gambar bulan dan bintang menggunakan delphi.
var
Form1: TForm1;
x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,x7,y7,x8,y8,x9,y9,x10,y10,x11,y11,x12,y12,tx,ty:integer;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
with paintbox1 do
begin
//buton serong kanan atas
tx:= 10 ;
x1 := x1-tx;
x2 := x2-tx;
x3 := x3-tx;
x4 := x4-tx;
x5 := x5-tx;
x6 := x6-tx;
x7 := x7-tx;
x8 := x8-tx;
x9 := x9-tx;
x10 := x10-tx;
x11 := x11-tx;
x12 := x12-tx;
y1 := y1-tx;
y2 := y2-tx;
y3 := y3-tx;
y4 := y4-tx;
y5 := y5-tx;
y6 := y6-tx;
y7 := y7-tx;
y8 := y8-tx;
y9 := y9-tx;
y10 := y10-tx;
y11 := y11-tx;
y12 := y12-tx;
paintbox1.refresh;
canvas.Brush.Color:=clred;
canvas.Ellipse(x1,y1,x2,y2);
canvas.Brush.Color:=clblue;
canvas.Polygon([point(x3,y3),point(x4,y4),point(x5,y5),point(x6,y6),point(x7,y7),point(x8,y8),point(x9,y9),point(x10,y10),point(x11,y11),point(x12,y12)]);
end;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
with paintbox1 do
begin
//buton Atas
tx:= 10 ;
y3 := y3-tx;
y4 := y4-tx;
y5 := y5-tx;
y6 := y6-tx;
y7 := y7-tx;
y8 := y8-tx;
y9 := y9-tx;
y10 := y10-tx;
y11 := y11-tx;
y12 := y12-tx;
y1 := y1-tx;
y2 := y2-tx;
paintbox1.refresh;
canvas.Brush.Color:=clred;
canvas.Ellipse(x1,y1,x2,y2);
canvas.Brush.Color:=clblue;
canvas.Polygon([point(x3,y3),point(x4,y4),point(x5,y5),point(x6,y6),point(x7,y7),point(x8,y8),point(x9,y9),point(x10,y10),point(x11,y11),point(x12,y12)]);
end;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
with paintbox1 do
begin
//buton serong kanan atas
tx:= 10 ;
x1 := x1+tx;
x2 := x2+tx;
x3 := x3+tx;
x4 := x4+tx;
x5 := x5+tx;
x6 := x6+tx;
x7 := x7+tx;
x8 := x8+tx;
x9 := x9+tx;
x10 := x10+tx;
x11 := x11+tx;
x12 := x12+tx;
y1 := y1-tx;
y2 := y2-tx;
y3 := y3-tx;
y4 := y4-tx;
y5 := y5-tx;
y6 := y6-tx;
y7 := y7-tx;
y8 := y8-tx;
y9 := y9-tx;
y10 := y10-tx;
y11 := y11-tx;
y12 := y12-tx;
paintbox1.refresh;
canvas.Brush.Color:=clred;
canvas.Ellipse(x1,y1,x2,y2);
canvas.Brush.Color:=clblue;
canvas.Polygon([point(x3,y3),point(x4,y4),point(x5,y5),point(x6,y6),point(x7,y7),point(x8,y8),point(x9,y9),point(x10,y10),point(x11,y11),point(x12,y12)]);
end;
end;
procedure TForm1.BitBtn4Click(Sender: TObject);
begin
with paintbox1 do
begin
//buton kiri
tx:= 10 ;
x3 := x3-tx;
x4 := x4-tx;
x5 := x5-tx;
x6 := x6-tx;
x7 := x7-tx;
x8 := x8-tx;
x9 := x9-tx;
x10 := x10-tx;
x11 := x11-tx;
x12 := x12-tx;
x1 := x1-tx;
x2 := x2-tx;
paintbox1.refresh;
canvas.Brush.Color:=clRed;
canvas.Ellipse(x1,y1,x2,y2);
canvas.Brush.Color:=clblue;
canvas.Polygon([point(x3,y3),point(x4,y4),point(x5,y5),point(x6,y6),point(x7,y7),point(x8,y8),point(x9,y9),point(x10,y10),point(x11,y11),point(x12,y12)]);
end;
end;
procedure TForm1.BitBtn5Click(Sender: TObject);
begin
with paintbox1 do
begin
//buton kanan
tx:= 10 ;
x3 := x3+tx;
x4 := x4+tx;
x5 := x5+tx;
x6 := x6+tx;
x7 := x7+tx;
x8 := x8+tx;
x9 := x9+tx;
x10 := x10+tx;
x11 := x11+tx;
x12 := x12+tx;
x1 := x1+tx;
x2 := x2+tx;
paintbox1.refresh;
canvas.Brush.Color:=clRed;
canvas.Ellipse(x1,y1,x2,y2);
canvas.Brush.Color:=clblue;
canvas.Polygon([point(x3,y3),point(x4,y4),point(x5,y5),point(x6,y6),point(x7,y7),point(x8,y8),point(x9,y9),point(x10,y10),point(x11,y11),point(x12,y12)]);
end;
end;
procedure TForm1.BitBtn6Click(Sender: TObject);
begin
with paintbox1 do
begin
//buton serong kanan bawah
tx:= 10 ;
x1 := x1-tx;
x2 := x2-tx;
x3 := x3-tx;
x4 := x4-tx;
x5 := x5-tx;
x6 := x6-tx;
x7 := x7-tx;
x8 := x8-tx;
x9 := x9-tx;
x10 := x10-tx;
x11 := x11-tx;
x12 := x12-tx;
y1 := y1+tx;
y2 := y2+tx;
y3 := y3+tx;
y4 := y4+tx;
y5 := y5+tx;
y6 := y6+tx;
y7 := y7+tx;
y8 := y8+tx;
y9 := y9+tx;
y10 := y10+tx;
y11 := y11+tx;
y12 := y12+tx;
paintbox1.refresh;
canvas.Brush.Color:=clred;
canvas.Ellipse(x1,y1,x2,y2);
canvas.Brush.Color:=clblue;
canvas.Polygon([point(x3,y3),point(x4,y4),point(x5,y5),point(x6,y6),point(x7,y7),point(x8,y8),point(x9,y9),point(x10,y10),point(x11,y11),point(x12,y12)]);
end;
end;
procedure TForm1.BitBtn7Click(Sender: TObject);
begin
with paintbox1 do
begin
//buton bawah
tx:= 10 ;
y3 := y3+tx;
y4 := y4+tx;
y5 := y5+tx;
y6 := y6+tx;
y7 := y7+tx;
y8 := y8+tx;
y9 := y9+tx;
y10 := y10+tx;
y11 := y11+tx;
y12 := y12+tx;
y1 := y1+tx;
y2 := y2+tx;
paintbox1.refresh;
canvas.Brush.Color:=clred;
canvas.Ellipse(x1,y1,x2,y2);
canvas.Brush.Color:=clblue;
canvas.Polygon([point(x3,y3),point(x4,y4),point(x5,y5),point(x6,y6),point(x7,y7),point(x8,y8),point(x9,y9),point(x10,y10),point(x11,y11),point(x12,y12)]);
end;
end;
procedure TForm1.BitBtn8Click(Sender: TObject);
begin
with paintbox1 do
begin
//buton serong kanan bawah
tx:= 10 ;
x1 := x1+tx;
x2 := x2+tx;
x3 := x3+tx;
x4 := x4+tx;
x5 := x5+tx;
x6 := x6+tx;
x7 := x7+tx;
x8 := x8+tx;
x9 := x9+tx;
x10 := x10+tx;
x11 := x11+tx;
x12 := x12+tx;
y1 := y1+tx;
y2 := y2+tx;
y3 := y3+tx;
y4 := y4+tx;
y5 := y5+tx;
y6 := y6+tx;
y7 := y7+tx;
y8 := y8+tx;
y9 := y9+tx;
y10 := y10+tx;
y11 := y11+tx;
y12 := y12+tx;
paintbox1.refresh;
canvas.Brush.Color:=clRed;
canvas.Ellipse(x1,y1,x2,y2);
canvas.Brush.Color:=clblue;
canvas.Polygon([point(x3,y3),point(x4,y4),point(x5,y5),point(x6,y6),point(x7,y7),point(x8,y8),point(x9,y9),point(x10,y10),point(x11,y11),point(x12,y12)]);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with paintbox1 do
begin
//button proses
x1 := 100 ;
y1 := 100 ;
x2 := 300 ;
y2 := 300 ;
x3 := 200 ;
y3 := 100 ;
x4 := 170 ;
y4 := 170 ;
x5 := 110 ;
y5 := 170 ;
x6 := 160 ;
y6 := 210 ;
x7 := 130 ;
y7 := 270 ;
x8 := 195;
y8 := 230;
x9:= 270;
y9:= 270;
x10:=230;
y10:=210;
x11:=290;
y11:=170;
x12:=225;
y12:=170 ;
paintbox1.Refresh;
canvas.Brush.Color:=clRed;
canvas.Ellipse(x1,y1,x2,y2);
canvas.Brush.Color:=clblue;
canvas.Polygon([point(x3,y3),point(x4,y4),point(x5,y5),point(x6,y6),point(x7,y7),point(x8,y8),point(x9,y9),point(x10,y10),point(x11,y11),point(x12,y12)]);
end;
end;
end.
Saturday, 17 September 2016
Delphi
0 Response to "Membuat Gambar Bulan dan Bintang dengan Delphi7"
Post a Comment