Pointless Circle thingy...

Blitz3D Forums/Blitz3D Programming/Pointless Circle thingy...

You know how you sometimes find yourself coding for the sake of it... with no real aim... and you end up with something... well... kinda interesting and pointless at the same time...

Here's an example of such a thing!

Graphics 640,480

outerr = Rand(0,220)
innerr = outerr - Rand(10,outerr)
col = Rand(0,16777215)

Repeat


	LockBuffer FrontBuffer()
	
	For x=-outerr To outerr
		For y=-outerr To outerr
		
			r= Sqr((x*x)+(y*y))

			
			If r>=innerr And r<=outerr Then
				If intriangle(x,y,0,0,Sin(ang)*(outerr*2),Cos(ang)*(outerr*2),Sin(ang+2)*(outerr*2),Cos(ang+2)*(outerr*2)) Then 
					If r=innerr Or r=outerr Then c=16777215 Else c=col
					WritePixelFast x+320,y+240,c
				EndIf
			EndIf
		
		Next
	Next
	
	UnlockBuffer FrontBuffer()
	
	ang = (ang + 1) Mod 360
	
	If ang = 0 Then
		outerr = Rand(0,220)
		innerr = outerr - Rand(10,outerr)
		col = Rand(0,16777215)
	EndIf
		
		
	
Until KeyHit(1)


Function InTriangle(x,y,x1,y1,x2,y2,x3,y3)
	ab# = (y-y1)*(x2-x1) - (x-x1)*(y2-y1) 
	ca# = (y-y3)*(x1-x3) - (x-x3)*(y1-y3)
	bc# = (y-y2)*(x3-x2) - (x-x2)*(y3-y2)
	Return ab*bc>0 And bc*ca>0
End Function