mirror of https://github.com/raysan5/raylib
REVIEWED: `ColorLerp()` formatting #4310
This commit is contained in:
parent
68e7cadabc
commit
b807f633d9
|
@ -1431,11 +1431,11 @@ RLAPI Color ColorBrightness(Color color, float factor); // G
|
|||
RLAPI Color ColorContrast(Color color, float contrast); // Get color with contrast correction, contrast values between -1.0f and 1.0f
|
||||
RLAPI Color ColorAlpha(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f
|
||||
RLAPI Color ColorAlphaBlend(Color dst, Color src, Color tint); // Get src alpha-blended into dst color with tint
|
||||
RLAPI Color ColorLerp(Color color1, Color color2, float factor); // Get color lerp interpolation between two colors, factor [0.0f..1.0f]
|
||||
RLAPI Color GetColor(unsigned int hexValue); // Get Color structure from hexadecimal value
|
||||
RLAPI Color GetPixelColor(void *srcPtr, int format); // Get Color from a source pixel pointer of certain format
|
||||
RLAPI void SetPixelColor(void *dstPtr, Color color, int format); // Set color formatted into destination pixel pointer
|
||||
RLAPI int GetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes for certain format
|
||||
RLAPI Color ColorLerp(Color color1, Color color2, float d); // Mix 2 Colors Together
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Font Loading and Text Drawing Functions (Module: text)
|
||||
|
|
|
@ -5185,6 +5185,22 @@ Color ColorAlphaBlend(Color dst, Color src, Color tint)
|
|||
return out;
|
||||
}
|
||||
|
||||
// Get color lerp interpolation between two colors, factor [0.0f..1.0f]
|
||||
Color ColorLerp(Color color1, Color color2, float factor)
|
||||
{
|
||||
Color color = { 0 };
|
||||
|
||||
if (d < 0) d = 0.0f;
|
||||
else if (d > 1) d = 1.0f;
|
||||
|
||||
color.r = (unsigned char)((1.0f - factor)*color1.r + factor*color2.r);
|
||||
color.g = (unsigned char)((1.0f - factor)*color1.g + factor*color2.g);
|
||||
color.b = (unsigned char)((1.0f - factor)*color1.b + factor*color2.b);
|
||||
color.a = (unsigned char)((1.0f - factor)*color1.a + factor*color2.a);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
// Get a Color struct from hexadecimal value
|
||||
Color GetColor(unsigned int hexValue)
|
||||
{
|
||||
|
@ -5424,24 +5440,6 @@ int GetPixelDataSize(int width, int height, int format)
|
|||
return dataSize;
|
||||
}
|
||||
|
||||
|
||||
// Mix 2 Colors togehter.
|
||||
// d = dominance. 0.5 for equal
|
||||
Color ColorLerp(Color color1, Color color2, float d)
|
||||
{
|
||||
Color newColor = { 0, 0, 0, 0 };
|
||||
if (d < 0) {d=0.0f;}
|
||||
else if(d>1) {d=1.0f;}
|
||||
|
||||
newColor.r = (unsigned char)((1.0f-d) * color1.r + d * color2.r);
|
||||
newColor.g = (unsigned char)((1.0f-d) * color1.g + d * color2.g);
|
||||
newColor.b = (unsigned char)((1.0f-d) * color1.b + d * color2.b);
|
||||
newColor.a = (unsigned char)((1.0f-d) * color1.a + d * color2.a);
|
||||
|
||||
return newColor;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module specific Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue