Circle in & circle out effect

BlitzMax Forums/BlitzMax Programming/Circle in & circle out effect

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Or you can use DrawPoly, like this:
' circle fade out effect
Graphics 640,480,0

Local done:Int=False
Local size:Float = 800

Repeat
	Cls
	For a=1 To 5000
		SetColor Rand(1,255),Rand(1,255),Rand(1,255)
		DrawRect Rand(1,640),Rand(1,480),4,4
	Next

	' reduce scale of mask
	size :- 4

	' draw boxes on either side of circle mask
	SetColor 0,0,0
	DrawCircleBox(0,0,GraphicsWidth(),GraphicsHeight(),size,size)
	
	Flip
	If KeyDown(key_escape) Then done=True
Until done=True


Function DrawCircleBox(x:Float,y:Float,w:Float,h:Float,radiusx:Float,radiusy:Float,stp:Int = 8)

	Local xy:Float[6]

	Local cx:Float = x+w*0.5
	Local cy:Float = y+h*0.5

	For Local quad:Int = 0 To 3
		Local offset:Int = 0
		
	 	Select quad
			Case 0
				xy[0] = x
				xy[1] = y
				offset = 0
			Case 1
				xy[0] = x+w
				xy[1] = y
				offset = -90
			Case 2
				xy[0] = x+w
				xy[1] = y+h
				offset = 180			
			Case 3
				xy[0] = x
				xy[1] = y+h
				offset = 90
		EndSelect
	
		For Local i:Int = 0 To 90/stp
			Local j:Int = i*stp + offset
		
			xy[2] = cx - Sin(j)*radiusx
			xy[3] = cy - Cos(j)*radiusy

			xy[4] = cx - Sin(j+stp)*radiusx
			xy[5] = cy - Cos(j+stp)*radiusy
		
			DrawPoly(xy)
		Next
	Next

	Local dy:Float = (h*0.5)-radiusy
	Local dx:Float = (w*0.5)-radiusx

	DrawPoly([x,y,cx,y+dy,x+w,y])
	DrawPoly([x,y+h,cx,y+h-dy,x+w,y+h])
	DrawPoly([x,y,x+dx,cy,x,y+h])
	DrawPoly([x+w,y,x+w-dx,cy,x+w,y+h])

End Function