Lighter color
#1

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

http://forum.sa-mp.com/showpost.php?...postcount=4407
Reply
#3

Код:
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);
}
Reply
#4

But if my color is already converted to int?
Reply
#5

My function is working on int.
Reply
#6

Convert_HexToRGB

You not give that function
Reply
#7

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));
}
Reply
#8

I have to write positive or negative procents?
Reply
#9

Quote:
Originally Posted by MerryDeer
Посмотреть сообщение
But if my color is already converted to int?
It will work. Hex values are integers.Conversion would be done automatically...
Reply
#10

Quote:
Originally Posted by MerryDeer
Посмотреть сообщение
I have to write positive or negative procents?
Positive.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)