19.03.2015, 07:02
1.
2.
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.
Код:
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 ); }
Код:
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; }
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.