Posts: 723
Threads: 366
Joined: Jun 2016
Hi,
I convert hex to int, and then i want that int make lighter color, because player can write any hex, i want to make function that automatic generate lighter color depends of int i give
Posts: 170
Threads: 10
Joined: Sep 2011
Код:
stock MakeColorLighter(color, percent)
{
new
r,
g,
b,
Float:percentage = (100 - percent) + 0.1;
Convert_HexToRGB(color, r, g, b);
r = floatround(r * percentage / 100) + floatround(255 - percentage / 100 * 255);
g = floatround(g * percentage / 100) + floatround(255 - percentage / 100 * 255);
b = floatround(b * percentage / 100) + floatround(255 - percentage / 100 * 255);
return Convert_RGBToHex(r, g, b);
}
Posts: 723
Threads: 366
Joined: Jun 2016
But if my color is already converted to int?
Posts: 170
Threads: 10
Joined: Sep 2011
My function is working on int.
Posts: 723
Threads: 366
Joined: Jun 2016
Convert_HexToRGB
You not give that function
Posts: 170
Threads: 10
Joined: Sep 2011
Sry, forgot.
Код:
stock Convert_HexToRGB(color, &r, &g, &b)
{
r = (color >> 24) & 0xFF;
g = (color >> 16) & 0xFF;
b = (color >> 8) & 0xFF;
}
stock Convert_RGBToHex(r, g, b)
{
return (((r & 0xFF) << 16) | ((g & 0xFF) << 8) | ((b & 0xFF) << 0));
}
Posts: 723
Threads: 366
Joined: Jun 2016
I have to write positive or negative procents?
Posts: 170
Threads: 10
Joined: Sep 2011
Quote:
Originally Posted by MerryDeer
I have to write positive or negative procents?
|
Positive.