[TUTO] Darkening/tinting sprites using Drawmethod

O Ilusionista

Captain 100K
Darkening/tinting sprites using Drawmethod
===============================================


----------[CREDITS]----------
By O Ilusionista - 2020.06.28
Original  drawmethod codes - I don't know
Shortcut version - uTunnels

----------[INFO]----------
As I said on another topic, I had some old codes (2013) from different authors written down on a online notepad where I haven't saved the author and among them there was some shorcuts to drawmethod, which can give you an easy access to OpenBOR powerful drawmethod and I use it a lot.

I made a search just to find the original topic and to confirm that uTunnels did it: http://www.chronocrash.com/forum/index.php?topic=145.msg943#msg943 - there are more info on that post - just to make things clear and avoid get things out of context.

----------[WHAT IT DOES]----------
The code can control the sprite colors without having the need of using a palette or a new image (plus, drawmethod can be used to scale, rotate and a lot of other things, see the link above).

I already use drawmethod to tint sprites, but I never was able to darken then.
So I made some tests and I finally go it done - this is how I made this Sentinel to shrink and to get darker:
5ntPQBJ.gif


The trick relies on using the right ALPHA for tintmode

drawmethod tintmode {int}

{alpha} is integer value.
0 = No alpha effect.
1-6 = Alpha 1-6
(I don't know if the shortcut version accepts "-1 = Use entity's alpha")


Straight from the manual:
alpha {int}

~If set to 1, this entity will be displayed with alpha transparency.
~If set to 2, this entity will use negative alpha transparency (the darker colors are stronger, like shadows). <---- THIS
~If set to 3, this entity will overlay transparency. It's described in the engine as being a combination of alpha and negative alpha, and the formula is "bg<128 ? multiply(bg*2,fg) : screen((bg-128)*2,fg)".
~If set to 4, this entity will use hardlight transparency. Seems to be the opposite of overlay. The formula is "fg<128 ? multiply(fg*2,bg) : screen((fg-128)*2,bg)".
~If set to 5, this entity uses dodge transparency. Described in the code as being "Very nice for a colourful boost of light."
~If set to 6, this entity will use 50% transparency. The entire entity will be 50% transparent: every pixel will be averaged with the pixel right behind it.
~In 8bit colormode, this setting DOES NOT work with remaps. You need 16bit or 32bit color mode to use this together with remaps.

So we will be using the "negative alpha" for this:

drawmethod tintmode 2
drawmethod tintcolor 100_100_100
frame data/chars/enemies/robots/megasent/s1_idle.gif

The values are RGB values, so its R100 G100 B100 - a light gray
bHyI3h9.png


----------[NOTES]----------
1 - You need to set the tintmode before using the tintcolor
2 - since we are in negative, the higher the values, the less dark it will get.

So if you want it to get darker, you should user lower values:
drawmethod tintmode 2
drawmethod tintcolor 50_50_50
frame data/chars/enemies/robots/megasent/s1_idle.gif

You can combine drawmethod shortucts - this is how I managed to get it darker and smaller at the same time
drawmethod tintmode 2
drawmethod tintcolor 100_100_100
drawmethod scale 0.98
frame data/chars/enemies/robots/megasent/s1_idle.gif
 
Back
Top Bottom