RosettaCodeData/Task/Bitmap-Midpoint-circle-algo.../BASIC256/bitmap-midpoint-circle-algo...

40 lines
650 B
Plaintext

fastgraphics
clg
color red
call DrawCircle(150,100,100)
refresh
color blue
call DrawCircle(200,200,50)
refresh
#Function DrawCircle
#1st param = X-coord of center
#2nd param = Y-coord of center
#3rd param = radius
Function DrawCircle(x0,y0,radius)
x=radius
y=0
decisionOver2=1-x
while x>=y
plot( x + x0, y + y0)
plot( y + x0, x + y0)
plot(-x + x0, y + y0)
plot(-y + x0, x + y0)
plot(-x + x0, -y + y0)
plot(-y + x0, -x + y0)
plot( x + x0, -y + y0)
plot( y + x0, -x + y0)
y++
if decisionOver2<=0 then
decisionOver2+=2*y+1
else
x--
decisionOver2+=2*(y-x)+1
end if
end while
return 0
End Function