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.

It seems that writing the above question helped me answer it, in particular - the description of 'circle punched out of the middle of a rect' gave me an idea.

How I've achieved the effect is quite simple in the end; I make a masked image with a circle punched out of the middle, draw this image over the everything (scaled) and then draw rects on all sides of it - I've included the code for anyone that's interested.


' circle mask effect

Graphics 640,480,0
AutoMidHandle True
'create the mask image
Local timask=CreateImage(640,480,1,MASKEDIMAGE | DYNAMICIMAGE | FILTEREDIMAGE)
'set mask color to white
SetMaskColor 255,255,255
'draw white circle on black b/g
SetColor 255,255,255
DrawOval 0,0,640,480
'grab background into timask
GrabImage timask,0,0

Local done:Int=False
Local sc:Float=2

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

		'reduce scale of mask
	sc=sc-.01

	'draw boxes on either side of circle mask
	SetScale 1,1
	SetColor 0,0,0
	DrawRect 0,0,640,ImageHeight(timask)/2-(ImageHeight(timask)/2*sc)
	DrawRect 0,ImageHeight(timask)/2+(ImageHeight(timask)/2*sc),640,480
	DrawRect 0,0,ImageWidth(timask)/2-(ImageWidth(timask)/2*sc),480
	DrawRect ImageWidth(timask)/2+(ImageWidth(timask)/2*sc),0,640,480
	


	'draw circle mask
	SetScale sc,sc
	SetColor 255,255,255
	DrawImage timask,ImageWidth(timask)/2,ImageHeight(timask)/2
	
	Flip
	If KeyDown(key_escape) Then done=True
Until done=True