ColorBetween function. Fail.
#1

1.
Код:
stock ColorBetween(ColorA, ColorB, Float:Percent)
{
    new R1, G1, B1, A1, R2, G2, B2, A2;

    HexToInt(ColorA, R1, G1, B1, A1);
    HexToInt(ColorB, R2, G2, B2, A2);

    return IntToHex(
        floatround(Percent * (R2-R1)) + R1,
        floatround(Percent * (G2-G1)) + G1,
        floatround(Percent * (B2-B1)) + B1,
        floatround(Percent * (A2-A1)) + A1
    );
}
2.
Код:
stock HexToInt(hexcolor, &r, &g, &b, &a)
{
	r = ( hexcolor >> 32 ) & 0xFF;
	g = ( hexcolor >> 16 ) & 0xFF;
	b = ( hexcolor >> 8 ) & 0xFF;
	a = hexcolor & 0xFF;
}
stock IntToHex(r, g, b, a = 255, &hexcolor = -1) 
{
	hexcolor = (r*16777216)+(g*65536)+(b*256)+a;
	return hexcolor;
}
3. The hex-int functions works perfect. The problem is in the ColorBetween function.

4. Doing ColorBetween(0xFF7F3F1F, 0x00000000, 0.5) returns 0x10402010. Obviously this is wrong.






Does anyone know how to do this right? It's 3 in the morning here, I'm tired. It's probably something small and easy that I'm not noticing. Thanks.
Reply


Messages In This Thread
ColorBetween function. Fail. - by Crayder - 19.03.2015, 07:02
AW: ColorBetween function. Fail. - by Kaliber - 19.03.2015, 07:19
Re: ColorBetween function. Fail. - by Vince - 19.03.2015, 10:22
Re: ColorBetween function. Fail. - by Crayder - 19.03.2015, 12:06
AW: Re: ColorBetween function. Fail. - by Kaliber - 19.03.2015, 12:17
Re: ColorBetween function. Fail. - by Vince - 19.03.2015, 14:41
Re: ColorBetween function. Fail. - by Crayder - 19.03.2015, 20:43

Forum Jump:


Users browsing this thread: 1 Guest(s)