sync on
sync rate 0
 
create bitmap 1,640,480
set current bitmap 0
 
dim pbox(640,480)
 
do
	cls 0
	if leftkey() = 1 then x=x-1
	if rightkey() = 1 then x=x+1
	sbfillcircle(200+x,200,100)
 
	sync
loop
 
function SBFillCircle( CX, CY, R )
	set current bitmap 1
	   sR = R*R
   	for i = 0 to R
	      h = sqrt( sR - i*i )
   	   gbox(CX - i, CY - h, CX + i, CY + h)
	   next i
	cls 0
		for lpy = CY - R to CY + R
		for lpx = CX - R to CX + R
			if pbox(lpx,lpy) = 1 then dot lpx,lpy
			pbox(lpx,lpy) = 0
		next lpx
		next lpy
		get image 1,cx-r,cy-r,cx+r,cy+r,1
 
	set current bitmap 0
	paste image 1,cx-r,cy-r,1
endfunction
 
Function gbox(x1,y1,x2,y2)
	for lpy = y1 to y2
		if lpx > -1 & lpx < 641 & lpy > -1 & lpy < 481
			pbox(x1,lpy)=1
			pbox(x2,lpy)=1
		endif
	next lpy
EndFunction