SA-MP Forums Archive
Lighter color - 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: Lighter color (/showthread.php?tid=628811)



Lighter color - MerryDeer - 15.02.2017

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


Re: Lighter color - SyS - 15.02.2017

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


Re: Lighter color - Rdx - 15.02.2017

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



Re: Lighter color - MerryDeer - 15.02.2017

But if my color is already converted to int?


Re: Lighter color - Rdx - 15.02.2017

My function is working on int.


Re: Lighter color - MerryDeer - 15.02.2017

Convert_HexToRGB

You not give that function


Re: Lighter color - Rdx - 15.02.2017

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));
}



Re: Lighter color - MerryDeer - 15.02.2017

I have to write positive or negative procents?


Re: Lighter color - SyS - 15.02.2017

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...


Re: Lighter color - Rdx - 15.02.2017

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