Hex Math for colors - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Hex Math for colors (
/showthread.php?tid=483858)
Hex Math for colors -
Pghpunkid - 28.12.2013
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.
AW: Hex Math for colors -
BigETI - 28.12.2013
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
Re: Hex Math for colors -
Pghpunkid - 28.12.2013
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);
|
..?