Radial Gradient?

Blitz3D Forums/Blitz3D Programming/Radial Gradient?

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.

In this thread http://www.blitzbasic.com/Community/posts.php?topic=77155#863163

I created a little function that returns a radial texture like that.

Function CreateStar(Size)
	; Create texture
	I = CreateImage(Size,Size)
	T = CreateTexture(Size,Size)
	LockBuffer ImageBuffer(i)
	
	S = Size / 2
	For x=-S To S
	For y=-S To S
		r# = ((x*x)+(y*y))
		If r < s Then
			c# = 255.0 - ((255.0 / s) * r)
			argb=(c Or (c Shl 8) Or (c Shl 16) Or ($ff000000))
			WritePixelFast x + s,y + s,argb,ImageBuffer(i)
		EndIf
	Next
	Next
	
	UnlockBuffer ImageBuffer(i)
	CopyRect 0,0,size,size,0,0,ImageBuffer(i),TextureBuffer(t)
	FreeImage i
	Return t
End Function
So you'd just do something like
ShadowTex = CreateStar(256)
And then you've got your texture.

If you want to add the banded look simply add a snap size to the c# variable in the code.
c# = Floor(c/bands) * bands
Obviously pass the bands variable into the function.

Job done. And I would suspect, although this it unproven, but it'll be approximately a shed load faster than using ovals.