|
|
| - Klik dua kali pada Form dan ketikkan perintah di bawah ini:
procedure TForm3.FormCreate(Sender: TObject);
begin
x0:=ClientWidth div 2;
y0:=ClientHeight div 2;
- Klik Events pilih OnPaint, lalu ketikkan perintah dibawah ini:
procedure TForm3.FormPaint(Sender: TObject);
var
x,y:integer;
begin
for x:=0 to ClientWidth do
canvas.Pixels[x,ClientHeight div 2]:=clblue;
for y:=0 to ClientHeight do
canvas.Pixels[ClientWidth div 2,y]:=clblue;
- Klik dua kali pada Botton 1, lalu ketikkan perintah dibawah ini:
procedure TForm3.Button1Click(Sender: TObject);
begin
a:=StrToInt(edit1.Text);
b:=StrToInt(edit2.Text);
r:=StrToInt(edit3.Text);
repeat
radian:=sudut/180*3.14;
x:=r*cos(radian);
y:=r*sin(radian);
Canvas.Pixels[trunc(x0+(x+a)),trunc(y0 +(y+b))]:= clRed;
Canvas.Pixels[trunc(x0+(x+a)),trunc(y0 +(-y+b))]:= clBlue;
Canvas.Pixels[trunc(x0+( -x+a)),trunc(y0+(y+b))]:= clPurple;
Canvas.Pixels[trunc(x0+( -x+a)),trunc(y0+(-y+b))]:= clNavy;
Canvas.Pixels[trunc(x0+(y+a)),trunc(y0 +(x+b))]:= clBlack;
Canvas.Pixels[trunc(x0+(y+a)),trunc(y0 +(-x+b))]:= clGreen;
Canvas.Pixels[trunc(x0+( -y+a)),trunc(y0+(x+b))]:= clYellow;
Canvas.Pixels[trunc(x0+( -y+a)),trunc(y0+(-x+b))]:= clTeal;
sudut:=sudut+0.5;
until sudut>=45;
end;
- Lalu Jalankan programnya (F9) Hasilnya seperti dibawah ini:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Tidak ada komentar:
Posting Komentar