- Buatlah tampilan Seperti di bawah ini:
- Codingnya:
var
Form1: TForm1;
x0,y0,r:integer;
x,y:real;
procedure TForm1.FormCreate(Sender: TObject);
begin
x0:=ClientWidth div 2;
y0:=ClientHeight div 2;
end;
end.
procedure TForm1.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
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
x:=0;
repeat
y:=sqrt(sqr(r)-sqr(x));
canvas.Pixels[Trunc(x0+x),Trunc(y0-y)]:=clred;
canvas.Pixels[Trunc(x0+x),Trunc(y0+y)]:=clblue;
canvas.Pixels[Trunc(x0-x),Trunc(y0-y)]:=clSkyBlue;
canvas.Pixels[Trunc(x0-x),Trunc(y0+y)]:=clGray;
canvas.Pixels[Trunc(x0+y),Trunc(y0-x)]:=clYellow;
canvas.Pixels[Trunc(x0+y),Trunc(y0+x)]:=clNavy;
canvas.Pixels[Trunc(x0-y),Trunc(y0-x)]:=clPurple;
canvas.Pixels[Trunc(x0-y),Trunc(y0+x)]:=clMaroon;
x:=x+0.5;
until x>=0.707*r;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
// code untuk Ulang//
Form1.Refresh;
edit1.Text := '';
edit1.SetFocus;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
// code untuk Exit//
close;
Selamat Mencoba.................
Tidak ada komentar:
Posting Komentar