You really should benchmark your code before you make statements like that
sync on
sync rate 0
Start = timer()
for i=1 to 100
FilledCircle( 320, 240, 100 )
next
Finish1 = timer() - Start
sync off
wait key
sync on
cls
Start = timer()
for i=1 to 100
filled_circle( 320, 240, 100, 0.55 )
next
Finish2 = timer() - Start
print "Mine : "; Finish1
print "Yours : "; Finish2
sync off
wait key
end
function FilledCircle( CX as integer, CY as integer, R as integer )
local x as integer
local y as integer
local i as integer
local s as integer
` Precalculate the square of the radius - this is the hypotenuse
i=R*R
` Calculate the size of the central square
s=R*0.70710678 : ` this number is sin(45)
` Draw it
box CX-s, CY-s, CX+s+1, CY+s+1
s=s+1
` Loop through the bit we have not yet drawn
for y=s to R
x=sqrt( i-(y*y) )
` Draw top and bottom
box CX-x, CY-y, CX+x+1, CY-y+1
box CX-x, CY+y, CX+x+1, CY+y+1
` Draw left and right
box CX-y, CY-x, CX-y+1, CY+x+1
box CX+y, CY-x, CX+y+1, CY+x+1
next y
endfunction
function filled_circle(middlex,middley,rad,steps#)
lock pixels
ang#=0
repeat
ang#=ang#+steps#
x#=(sin(ang#)*rad)
y#=(cos(ang#)*rad)
line -x#+middlex,y#+middley,x#+middlex+1.0,y#+middley+1.0
until ang#>=180
unlock pixels
endfunction
On my aging laptop, your code runs in 815ms, while mine runs in 56ms. The step size of 0.55 was chosen to give a perfectly filled circle at that radius, just so that I was comparing like-for-like.
I also applied a fix to your line command - the last pixel isn't drawn when using line, so you have to add 1. I also removed the '*0.9' that made the circle flattened