Drawing a glowing line?

Monkey Forums/Monkey Programming/Drawing a glowing line?

Supertino(Posted 2012) [#1]
Hey guys, how would you go about drawing a glowing line? not asking for code just a starting point or ideas.

Called with something like;

DrawGlowLine( x1:int , y1:int , x2:int , y2:int , thickness:int , softedge:bool )



Nobuyuki(Posted 2012) [#2]
You need to write a drawing routine which will do this for you. Although you could use multiple line function calls to achieve a similar effect, there is no guarantee over the pixel consistency when multiple lines are stacked edge-to-edge with each other over the target platforms, so whatever this would look like could look very different between platforms.

Alternatively, you can take a (very small) texture with a soft edge or reflected gradient, and then rotate and stretch it in the shape and direction of the line you want. SetColor() could tint the texture but I would recommend against it since the effect can be costly and isn't really appropriate for glows. Instead, I'd recommend baking in the proper gradient (white-hot -> your glow color) into the texture.


therevills(Posted 2012) [#3]
When I did this quick little game:

http://www.monkeycoder.co.nz/Community/topics.php?forum=1045&app_id=45

I cheated, I ported Bresenham Line Algorithm to Monkey and when I draw the "glow" line I did it like this:

For Local i% = 1 To 3
	Select i
		Case 1
			SetAlpha 0.04
		Case 2
			SetAlpha 0.01
		Case 3
			SetAlpha 0.01
	End Select
	LineB x - x1, y - y1, x - x2, y - y2, i * 6
Next
SetAlpha 1
DrawLine x-x1,y-y1,x-x2,y-y2


Bresenham Line Algorithm:



Supertino(Posted 2012) [#4]
O.o thanks Revills that looks very interesting.