11.03.2020, 12:49
There are different implementations, I like this one: https://stackoverflow.com/a/13532993
Returns the new color.
percent > 0 (lighter)
percent = 0 (same)
percent < 0 (darker)
pawn Code:
Color_ChangeShadow(color, percent)
{
new r = clamp(((color >> 24) & 0xFF) * (100 + percent) / 100, 0, 255),
g = clamp(((color >> 16) & 0xFF) * (100 + percent) / 100, 0, 255),
b = clamp(((color >> 8) & 0xFF) * (100 + percent) / 100, 0, 255),
a = color & 0xFF;
return (r << 24) | (g << 16) | (b << 8) | a;
}
percent > 0 (lighter)
percent = 0 (same)
percent < 0 (darker)