Any way to colorize sprites?

Monkey Forums/Monkey Programming/Any way to colorize sprites?

Raptisoft(Posted 2011) [#1]
Often when doing special effects, I colorize a sprite-- for instance, I might have a pure white graphic of a spark, and I set things up so that it actually draws red (or the color of my choice).

Any way to do that in Monkey? Or will I have to store redundant graphics? (And if that's the case... how to do a nice smooth fade from orange to red to black to do smoke?)

Wasn't sure if that was cross-compatible with Flash or HTML or not, and thus wouldn't be in there.


John Galt(Posted 2011) [#2]
You answered your own question. It's not compatible with all targets, hence unlikely to become part of the core Monkey language... which is a bummer.


Raptisoft(Posted 2011) [#3]
Fie... it looks like HTML5 is the odd man out... this is such an incredibly important gaming feature, that doesn't it seem reasonable to put it in and let HTML5 be the exception?

Perhaps someone could write some C++, XNA, and Flash importing code that could be used?

Again, this is a *very* important feature. I've been writing games professionally for ten years now, and I have used this in every single one of them since the beginning.

Leaving this out limits the special effect capacity of a game *tremendously.*


jjsonick(Posted 2011) [#4]
I suspect module-makers will enable it for various specific targets, even if it never makes into the core of Monkey. At least that's what I'm hoping.


therevills(Posted 2011) [#5]
Having Monkey export to HTML5 is cool and fun, but it is just a toy ATM.

So I think having SetColor work with images for other targets is a must.


taumel(Posted 2011) [#6]
SetColor is definitely missing badly. In the long run i would welcome a concept where there are features which work on all platforms and features which are only working on certain platforms (beeing marked in the docs according to their supported platforms) as otherwise you will end up with the annoyances of the least common denominator. This only works out if all platforms aren't too far away from each other, otherwise it can be a real drag.


GW_(Posted 2011) [#7]
I agree!
Making targets with commercial potential suffer because of some with no commercial potential is a bad idea. (Im looking at you javascript)


degac(Posted 2011) [#8]
Well HTML5 can do quite everything, the problem is the speed in doing this
Here someone suggest to change the color of an image making a copy of it and drawing on it with another color, than 'grabbing' it.
But sure this is not as fast as an OpenGL call.
Here another solution: in this case the 'pixmap' (getImageData) is manipulated directly to change its component.
Still the problem - presume - is the speed.

Cheers

ps: with getImageData it should be possible to implement Write/Read pixel...


Canardian(Posted 2011) [#9]
WebGL is part of HTML5, but I don't know how to enable it with Monkey.


degac(Posted 2011) [#10]
Here someone has done a wrapper for monkey based on WebGL.
Maybe you can get inspiration!


taumel(Posted 2011) [#11]
@degac
Well, speed somehow can be everything. If it's not fast enough, it just isn't an option.


degac(Posted 2011) [#12]
Ok, but you can always 'prepare' before run the resources: you download one image, then you colorize it before playing the game...


Canardian(Posted 2011) [#13]
The WebGL demo is really interesting. I think next I will do a Monkey Target Installer, which adds the GLFWMINGW and WEBGL target, and later on more.
The Target Installer would work with any Monkey version, because it only patches some Monkey files. One big benefit of the WEBGL target would be that it is the fastest to compile, so it would be a good quick test tool when writing code and testing it. Currently HTML5 is the fastest to compile, but since it is so slow and lacks features, WEBGL would be better.


JaviCervera(Posted 2011) [#14]
I think that having this is a must. Hopefully Mark will listen to us.


simonh(Posted 2011) [#15]
I'm pretty sure Mark intends to add this sooner rather than later.


peterigz(Posted 2011) [#16]
Yep, this will be useful for particle systems in particular :)