SetColor RGB

BlitzMax Forums/BlitzMax Module Tweaks/SetColor RGB

TomToad(Posted 2010) [#1]
Change Max2d.mod\Max2D.bmx SetColor() function like this:
Function SetColor( red,green=-1,blue =-1)
	If green = -1
		blue = red & $FF
		green = (red Shr 8) & $ff
		red = (red Shr 16) & $ff
	End If

	gc.color_red=red
	gc.color_green=green
	gc.color_blue=blue
	_max2dDriver.SetColor red,green,blue
End Function

Now you can set the color with SetColor(Red, Green, Blue) or SetColor(RGB).
It's sometimes more convenient to do it with one single Int than 3 bytes, like of you are setting the color depending on a pixel read from a pixmap. You can also change the SetMaskColor and SetClsColor the same way.