SetColor() thoughts

Monkey Forums/Monkey Programming/SetColor() thoughts

Gerry Quinn(Posted 2011) [#1]
Maybe it's too late to change this, as it would break existing code, but I find it very annoying the way SetColor() in Mojo is overloaded to affect both the painting colour of rectangles etc., and the colorisation of bitmap images. I am always getting bugs when I draw images because I have forgotten to change the colour back to white. These two things are conceptually different to me, and I think there should be separate colour variables for them.

I also think it would be nice to have a built-in SetColorNull() function instead of SetColor( 255, 255, 255 ), to indicate that you are painting bitmaps normally. But I have included this in my 'standard library' of functions anyway so it doesn't really matter.


GfK(Posted 2011) [#2]
I prefer it how it is.

I have a ResetScreenState() function which resets blendmode, color and alpha.


Raz(Posted 2011) [#3]
Edit: Dunno why I didn't see Gfk's post, but it's more useful than mine so removed!


GfK(Posted 2011) [#4]
Edit: Dunno why I didn't see Gfk's post, but it's more useful than mine so removed!
Its because I'm a stealthy ninja.


Jesse(Posted 2011) [#5]

I prefer it how it is.


Ditto!


Raz(Posted 2011) [#6]
Its because I'm a stealthy ninja.

Did you actually write it almost an hour ago or are you a time travelling Ninja? I'm hoping the latter!


GfK(Posted 2011) [#7]
58 minutes ago, it says. That's about right. :)

Er... I mean... yes, I'm a time travelling ninja. In fact, I'm typing this tomorrow.


wiebow(Posted 2011) [#8]
That's funny, cos I read this yesterday already!


MikeHart(Posted 2011) [#9]
+1 for no changes to SetColor.


Gerry Quinn(Posted 2011) [#10]
Well, looks like I'm decidely in the minority here!

Do you guys colourise your bitmaps a lot? Seems to me that the use of the same colour value (which is always needed when doing text or geometric shapes) is just a way to break normal blitting from an image!


skid(Posted 2011) [#11]
Do you guys colourise your bitmaps a lot?


As monkey uses image drawing to do text the answer is yes.


matty(Posted 2011) [#12]
Yes I colourise some bitmaps from time to time, not just for text but for a range of things...coloured smoke is one of these...


Gerry Quinn(Posted 2011) [#13]
Good point about the text being bitmaps in Mojo.

I still think images with their own colours (i.e. ordinary bitmap images) are conceptually different from things that are essentially colourless and must be assigned a colour any time they are used. I don't expect the colour assignation for the latter to have an effect on the former.

But clearly the majority has spoken here.


FlameDuck(Posted 2011) [#14]
I still think images with their own colours (i.e. ordinary bitmap images) are conceptually different from things that are essentially colourless and must be assigned a colour any time they are used.
Except they aren't conceptually different as there is no inherent property on "ordinary bitmap images" to indicate whether or not they are "essentially colorless".

For instance creating a Diablo type enemy where you use the same graphics, with a different hue to indicate enemy difficulty, becomes trivial. Same thing for making practically any sports game where you want to allow some type of team colour customization. On devices with limited storage or where download size is likely to be relevant, you'd probably want to include a more diverse selection of graphics, for the same penalty, rather than palette swapped ones.


Gerry Quinn(Posted 2011) [#15]
I get to decide what is conceptually different in my conceptual system ;-) Sure, there is no inherent property - from Mojo's perspective they are plain white. But that's a property, and it has implications.

And in all honesty, I don't think colorisation is the way to go in differentiating monsters/teams.


Raz(Posted 2011) [#16]
In that case add this code
Function SetColorNull:Void()
SetColor(255,255,255)
End

It will fulfill your conceptual needs and everyone else can fulfill theirs.


Gerry Quinn(Posted 2011) [#17]
I already added it! But it doesn't fulfil my conceptual needs, which require that SetColor() not muck with bitmap blitting. However, it seems they will remain unfulfilled, so I will say no more about it...

I suppose I could put something in my blitting functions (I have separate ones from DrawImageRect() anyway).

Something like:

Function MyBlittingFunction( image:Image, pos:Point, srcRect:Rect )
Local colour:Float[ 3 ] = GetColor()
SetColor( 255, 255, 255 )
DrawImageRect( ... )
SetColor( colour[ 0 ], colour[ 1 ], colour[ 2 ] )
End Function

Not very efficient, but it would make things the way I like them!


Raz(Posted 2011) [#18]
Sorry after posting that, I realised I had missed the point.

I was going to suggest you store the colours elsewhere and switch to white with each image draw, but I can see above you've done that! :)