Question: Making a hex color darker - 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: Question: Making a hex color darker (
/showthread.php?tid=420995)
Question: Making a hex color darker -
Maxips2 - 07.03.2013
Can I get some help wth making a hex color darker by specifying how much darker i want it to be?
I believe that I need to reduce the same amount of red, green and blue to make the same color darker.
I was thinking of using bit-wise operators for that, but I couldn't figure a working formula.
Re: Question: Making a hex color darker -
Vince - 07.03.2013
I suppose you could subtract the same amount for red, green and blue. Though I don't think that'll always work. To do it properly you'd need to convert the color to HSB (Hue, Saturation, Brightness) and reduce the saturation and/or brightness.
Re: Question: Making a hex color darker -
LarzI - 07.03.2013
Found this on stackoverflow:
http://stackoverflow.com/questions/1...n-a-hex-colour
Re: Question: Making a hex color darker -
Maxips2 - 16.03.2013
Quote:
Originally Posted by LarzI
|
This is very useful, thanks for that (sorry for responding just now, I forgot to check any comments on this thread).
Someone commented there, on stackoverflow and suggested another implemention which only makes the color a little bit darker.
However, I want to do it with a multiplyer (how much lighter I want it to be).
I conveted his implemention to RGBA (it was RGB), it works, but I have no idea how to do it like I want it to be.
pawn Код:
#define RGBA_DARKER(%0) (((%0 & 0x7E7E7E00) >> 1) | (%0 & 0x80808000))