Program berikut dibuat dengan menggunakan Free Pascal…
Isinya mengenai Pembentukan lingkaran melalui dua buah titik yang dinniputkan oleh User..
didalamnya sudah berisi translasi, penskalaan dan rotasi…
Semoga program ini bermanfaat………..

uses graph,crt;
var x1,x2,y1,y2,xtrans,ytrans:integer;
step,k,skala,xpst,ypst,r:integer;
dx,dy:real;
xm,ym,x,y,derajat:real;
pilih:char;
procedure init;
var gd, gm : integer;
begin
gm:=detect; gd:=0;
InitGraph(gd,gm,’C:\TP\bgi’);
if GraphResult <> grOk then


begin
Writeln(‘Graph driver ‘,gd,’ graph mode ‘,gm,’ not supported’);
Halt(1);
end;
end;
procedure destroy;
begin
closegraph;
end;
procedure input;
begin
writeln(‘program pembangkitan lingkaran’);
writeln(‘==============================’);
writeln;
write(‘masukkan nilai x1:’);
readln(x1);
write(‘masukkan nilai y1:’);
readln(y1);
write(‘masukkan jari-jari:’);readln(r);
end;
procedure circlePlotPoints(xCenter,yCenter,x,y:integer);
begin
putPixel(xCenter+x, yCenter+y,30);
putPixel(xCenter-x, yCenter+y,30);
putPixel(xCenter+x, yCenter-y,30);
putPixel(xCenter-x, yCenter-y,30);
putPixel(xCenter+y, yCenter+x,30);
putPixel(xCenter-y, yCenter+x,30);
putPixel(xCenter+y, yCenter-x,30);
putPixel(xCenter-y, yCenter-x,30);
end;
procedure lingkaran (xCenter,yCenter,radius:integer);
var
x,y,p:integer;
begin
x:=0;
y:=radius;
p:=1-radius;
circlePlotpoints(xCenter,yCenter,x,y);
while x<y do
begin
x:=x+1;;
if p<0 then
p:=p+(2*x+1)
else
begin
y:=y-1;
p:=p+(2*(x-y)+1);
end;
circlePlotPoints(xCenter,yCenter,x,y);
end;

end;
procedure translingkaran(xstart,ystart,xtrans,ytrans,r:integer);
var
xstartout,ystartout:integer;
begin
xstartout:=xstart+xtrans;
ystartout:=ystart+ytrans;
lingkaran(xstart,ystart,r);
lingkaran(xstartout,ystartout,r);
end;
procedure skalalingkaran(xstart,ystart,scale,r:integer);
var
xstartout,ystartout,r2:integer;
begin
xstartout:=xstart;
ystartout:=ystart;
r2:=r*scale;
lingkaran(xstart,ystart,r);
lingkaran(xstartout,ystartout,r2);
end;
procedure rotasigaris(xstart,ystart,xtengah,ytengah:integer;angle:real;r:integer);
var xstartout,ystartout,xendout,yendout:integer;
begin
xstartout:=round((xtengah+((xstart-xtengah)*cos(angle)))-((ystart-ytengah)*sin(angle)));
ystartout:=round((ytengah+((xstart-xtengah)*sin(angle)))-((ystart-ytengah)*cos(angle)));
lingkaran(xstart,ystart,r);
lingkaran(xstartout,ystartout,r);
end;
begin
clrscr;
input;
writeln(‘****Menu Pilihan***’);
writeln(‘[1]. Pembentukan Lingkaran’);
writeln(‘[2]. Translasi’);
writeln(‘[3]. Penskalaan’);
writeln(‘[4]. Rotasi lingkaran’);
write(‘masukkan pilihan anda:’);readln(pilih);
case pilih of
‘1’:
begin
init;
lingkaran(x1,y1,r);
readln;
closegraph;
end;
‘2’:
begin
write(‘masukkan xtrans:’);readln(xtrans);
write(‘masukkan ytrans:’);readln(ytrans);
init;
translingkaran(x1,y1,xtrans,ytrans,r);
readln;
closegraph;
end;
‘3’:
begin
write(‘masukkan skala:’);readln(skala);
init;
skalalingkaran(x1,y1,skala,r);
readln;
closegraph;
end;
‘4’:
begin
write(‘masukkan x pusat:’);readln(xpst);
write(‘masukkan y pusat:’);readln(ypst);
write(‘masukkan derajat:’);readln(derajat);
init;
rotasigaris(x1,y1,xpst,ypst,derajat,r);
readln;
closegraph;
end;
end;
end.