Hex Math for colors
#1

Okay so basically, I need to figure out how to add/remove transparency to colors using 'Hex math'.

I know there is a few ways to do it, some right, some wrong. I need to do this correctly.

#define COLOR_WHITE 0xFFFFFFAA
#define TCOLOR_WHITE 0xFFFFFF00

#define COLOR_BLUE 0x0000BBAA
#define TCOLOR_BLUE 0x0000BB00

I know its RRGGBBAA but how would you add/remove the AA Values on the fly as opposed to doing a bunch of checks, if statements and whatever else?

Id like to just remove the TCOLOR's and do a function called SetTransparentColor and use the existing colors, then add/subtract hex values to make them opaque/transparent.
Reply
#2

You should use bitwise operators to manipulate certain bits, for example you can set alpha to zero by doing
pawn Код:
new_color = some_color&0xFFFFFF00;
Just take a look at https://sampforum.blast.hk/showthread.php?tid=177523
Reply
#3

Okay, thats what I was looking for.

But can you do lets say, using the defines I posted in the OP, can you do..
Quote:

SetPlayerColor(playerid,COLOR_WHITE&0xFFFFFF00);

..Or..
Quote:

new color = GetPlayerColor(playerid);
SetPlayerColor(color&0xFFFFFF00);

..?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)