Sorry, that flood fill stuff might be overkill for makeing solid circles. Also, your program could crash with a stack overflow on a larger circle.
I thought that filled circle routine in the codebase was just a little too fancy for my taste so I wrote this:
` leftmouse = yellow circle radius 30
` rightmouse = red circle radius 15
do
mc=mouseclick()
xp=mousex()
yp=mousey()
cp=rgb(255,255,0)*(mc=1)+rgb(255,0,0)*(mc=2)
rp=30*(mc=1)+15*(mc=2)
if mc=1 or mc=2
solid_circle(xp,yp,rp,cp)
endif
loop
function solid_circle(x,y,radius,color)
ink color,0
for i=x-radius to x+radius
pa=sqrt((radius*radius)-((x-i)*(x-i)))
line i,y-pa,i,y+pa
next i
endfunction
Edit: The codebase one is about ten times faster though.
Here is one with both routines, (mine=leftclick, codebase=rightclick), have fun.
` leftmouse = yellow circle radius 30 - Dabbler
` rightmouse = red circle radius 15 - codebase
set text opaque
do
mc=mouseclick()
xp=mousex()
yp=mousey()
cp=rgb(255,255,0)*(mc=1)+rgb(255,0,0)*(mc=2)
rp=30*(mc=1)+15*(mc=2)
if mc=1 or mc=2
if mc=1
solid_circle(xp,yp,rp,cp)
endif
if mc=2
FilledCircle(xp,yp,rp,cp)
endif
`repeat
`until mouseclick()=0
endif
loop
function solid_circle(x,y,radius,color)
ink color,0
for i=x-radius to x+radius
pa=sqrt((radius*radius)-((x-i)*(x-i)))
line i,y-pa,i,y+pa
next i
endfunction
function FilledCircle( CX as integer, CY as integer, R as integer,c )
local x as integer
local y as integer
local i as integer
local s as integer
`not in original
ink c,0
` 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
Whatever...