To clarify a bit on image tinting:
-
tintMode
changes the way that the colourisation is performed. Image.TINTING_MULTIPLY
(which is 0
) works in “multiply” mode - if you’ve used photoshop you’ll know this. Basically it will always make the image darker or the same, never lighter. Image.TINTING_COLORIZE
(which is 1
) is a straight-up colourise - mixing the source colour with the destination colour. tintMode
can also be any number between 0 and 1, which will be a mixture of both effects. Technically it could be outside of this range too, but I’m not sure what that would look like or how useful it would be.
-
tintFactor
indicates the power of the effect. 0
is no effect, 1
is 100% effect. Taking the example of TINTING_COLORIZE
, tintFactor
set to 0.5
would mean that each destination pixel colour would be the average of the source colour and the tint colour. tintFactor
set to 1
would mean that each destination pixel colour would be set to the tint colour (which is precisely what Darrin is trying to do here)
It is possible to have tintFactor
set outside the range of [0,1]
- I seem to recall setting the tint colour to black and tintFactor
to -1
made an interesting lighting effect.
An example of why you’d use each tintFactor
:
If you want enemies to flash white or red when damaged, TINTMODE_COLORIZE
is for you. At 100% there is no shading or texture visible on the enemy, they’re 100% white (or red). Photoshop analog is the “Color Overlay” layer effect in normal blending mode.
If you want a sprite to change colour but maintain shading, you need TINTMODE_MULTIPLY
. Have the “main” colour as pure white and greys to indicate shadow/depth. Now when you apply the tinting with red (for example), all the white parts will become pure red, and all the greys darker red - shading is preserved.
When would you use an intermediate tintMode
? No idea, but the option is there.