Question: Making a hex color darker
#1

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.
Reply
#2

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.
Reply
#3

Found this on stackoverflow: http://stackoverflow.com/questions/1...n-a-hex-colour
Reply
#4

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))
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)