Program membuat Garis dengan DELPHI

Tampilan Program

Listing Program

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
close
end;

procedure TForm1.Button2Click(Sender: TObject);
var
dx,dy,fstep,f,x1,x2,y1,y2:integer;
deltax,deltay,x,y:real;
begin
x1:=strtoint(edit1.Text);
y1:=strtoint(edit2.Text);
x2:=strtoint(edit3.Text);
y2:=strtoint(edit4.Text);

dx:=(x2-x1);
dy:=(y2-y1);
if (abs(dx)>abs(dy)) then fstep:=abs(dx)
else fstep:=abs(dy);
deltax:= dx/fstep;
deltay:= dy/fstep;
x:=x1;y:=y1;
canvas.Pixels[trunc(x),trunc(y)]:=clblue;
for f :=0 to fstep-1 do
begin
x:=x+deltax;
y:=y+deltay;
canvas.Pixels[trunc(x),trunc(y)]:=clblue;
end;
end;

end.

Sumber : google.com

Advertisements

One comment on “Program membuat Garis dengan DELPHI

  1. Pingback: Delphi Prism | The Complete .NET Development Solution | Lire

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s