http://waode-sabaria.blogspot.com/2012/12/menggambar-kubus-menggunakan-delphi-7.html
Untuk Listingnya lihat saja di bawah ini.
_______________________________________________________________________________
unit LimasWaOde;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
txtsisi: TEdit;
txtx1: TEdit;
txty1: TEdit;
cmdgambar: TButton;
cmdkeluar: TButton;
procedure FormCreate(Sender: TObject);
procedure cmdkeluarClick(Sender: TObject);
procedure cmdgambarClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
sisi, x0, x1, x2, x3, x4, x5, y0, y1, y2, y3, y4, y5 : integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
with Form1 do
begin
Canvas.Brush.Style := bsCross;
Canvas.Brush.Color := clYellow;
Canvas.MoveTo(0, round(Height div 2));
Canvas.LineTo(Width, round(Height div 2));
Canvas.MoveTo(round(Width div 2), 0);
Canvas.LineTo(round(Width div 2), round(Height div 2));
end;
end;
procedure TForm1.cmdkeluarClick(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.cmdgambarClick(Sender: TObject);
begin
x0 := Form1.Width div 2;
y0 := Form1.Height div 2;
x1:= StrToInt(txtx1.Text);
y1 := StrToInt(txty1.Text);
sisi := StrToInt(txtsisi.Text);
x2 := x1 + sisi;
x3:= x2 + round(sisi/4);
x4:= x1 + round(sisi/4);
x5 := x1 + round(sisi/4);
y2 := y1;
y3 := y2 + sisi;
y4 := y3;
y5 := 2 * sisi;
with Form1 do
begin
Refresh;
Canvas.Polygon([point(round(x0+x1), round(y0-y1)), point(round(x0+x2), round(y0-y2)), point(round(x0+x3), round(y0-y3)), point(round(x0+x4), round(y0-y4))]);
Canvas.MoveTo(round(x0+x1), round(y0-y1));
Canvas.LineTo(round(x0+x5), round(y0-y5));
Canvas.MoveTo(round(x0+x2), round(y0-y2));
Canvas.LineTo(round(x0+x5), round(y0-y5));
Canvas.MoveTo(round(x0+x3), round(y0-y3));
Canvas.LineTo(round(x0+x5), round(y0-y5));
Canvas.MoveTo(round(x0+x4), round(y0-y4));
Canvas.LineTo(round(x0+x5), round(y0-y5));
end;
end;
end.
____________________________________________________________________________
selamat mencoba, semoga berhasil :-)
------------------------------------------------------ab@---------------------------------------------------------
Tidak ada komentar:
Posting Komentar