Replaced ColorToFloat() by ColorNormalize()

This commit is contained in:
raysan5 2018-04-29 18:39:46 +02:00
parent 8d81b6e4e4
commit dff1028466
2 changed files with 14 additions and 14 deletions

View File

@ -1156,25 +1156,25 @@ double GetTime(void)
#endif #endif
} }
// Returns normalized float array for a Color
float *ColorToFloat(Color color)
{
static float buffer[4];
buffer[0] = (float)color.r/255;
buffer[1] = (float)color.g/255;
buffer[2] = (float)color.b/255;
buffer[3] = (float)color.a/255;
return buffer;
}
// Returns hexadecimal value for a Color // Returns hexadecimal value for a Color
int ColorToInt(Color color) int ColorToInt(Color color)
{ {
return (((int)color.r << 24) | ((int)color.g << 16) | ((int)color.b << 8) | (int)color.a); return (((int)color.r << 24) | ((int)color.g << 16) | ((int)color.b << 8) | (int)color.a);
} }
// Returns color normalized as float [0..1]
Vector4 ColorNormalize(Color color)
{
Vector4 result;
result.x = (float)color.r/255.0f;
result.y = (float)color.g/255.0f;
result.z = (float)color.b/255.0f;
result.w = (float)color.a/255.0f;
return result;
}
// Returns HSV values for a Color // Returns HSV values for a Color
// NOTE: Hue is returned as degrees [0..360] // NOTE: Hue is returned as degrees [0..360]
Vector3 ColorToHSV(Color color) Vector3 ColorToHSV(Color color)

View File

@ -745,8 +745,8 @@ RLAPI float GetFrameTime(void); // Returns tim
RLAPI double GetTime(void); // Returns elapsed time in seconds since InitWindow() RLAPI double GetTime(void); // Returns elapsed time in seconds since InitWindow()
// Color-related functions // Color-related functions
RLAPI float *ColorToFloat(Color color); // Returns normalized float array for a Color
RLAPI int ColorToInt(Color color); // Returns hexadecimal value for a Color RLAPI int ColorToInt(Color color); // Returns hexadecimal value for a Color
RLAPI Vector4 ColorNormalize(Color color); // Returns color normalized as float [0..1]
RLAPI Vector3 ColorToHSV(Color color); // Returns HSV values for a Color RLAPI Vector3 ColorToHSV(Color color); // Returns HSV values for a Color
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f