renamed MixColors to ColorLerp (https://github.com/raysan5/raylib/pull/4310#issuecomment-2340121038)
This commit is contained in:
parent
4e7887a7fc
commit
b2ca734fd1
|
|
@ -1425,7 +1425,7 @@ RLAPI int ColorToInt(Color color); // G
|
||||||
RLAPI Vector4 ColorNormalize(Color color); // Get Color normalized as float [0..1]
|
RLAPI Vector4 ColorNormalize(Color color); // Get Color normalized as float [0..1]
|
||||||
RLAPI Color ColorFromNormalized(Vector4 normalized); // Get Color from normalized values [0..1]
|
RLAPI Color ColorFromNormalized(Vector4 normalized); // Get Color from normalized values [0..1]
|
||||||
RLAPI Vector3 ColorToHSV(Color color); // Get HSV values for a Color, hue [0..360], saturation/value [0..1]
|
RLAPI Vector3 ColorToHSV(Color color); // Get HSV values for a Color, hue [0..360], saturation/value [0..1]
|
||||||
RLAPI Color MixColors(Color color1, Color color2, float t); // Mix 2 Colors together
|
RLAPI Color ColorLerp(Color color1, Color color2, float d); // Mix 2 Colors together
|
||||||
RLAPI Color ColorFromHSV(float hue, float saturation, float value); // Get a Color from HSV values, hue [0..360], saturation/value [0..1]
|
RLAPI Color ColorFromHSV(float hue, float saturation, float value); // Get a Color from HSV values, hue [0..360], saturation/value [0..1]
|
||||||
RLAPI Color ColorTint(Color color, Color tint); // Get color multiplied with another color
|
RLAPI Color ColorTint(Color color, Color tint); // Get color multiplied with another color
|
||||||
RLAPI Color ColorBrightness(Color color, float factor); // Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
|
RLAPI Color ColorBrightness(Color color, float factor); // Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
|
||||||
|
|
|
||||||
|
|
@ -4987,25 +4987,25 @@ Vector3 ColorToHSV(Color color)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Mix 2 Colors togehter.
|
Mix 2 Colors togehter.
|
||||||
t = what color is more dominant.
|
d = what color is more dominant.
|
||||||
t=0.0f means color 1 is more dominant
|
d=0.0f means color 1 is more dominant
|
||||||
t=1.0f means color 2 is more dominant
|
d=1.0f means color 2 is more dominant
|
||||||
set t to 0.5 to have both colors balanced
|
set d to 0.5 to have both colors balanced
|
||||||
*/
|
*/
|
||||||
Color MixColors(Color color1, Color color2, float t) {
|
Color ColorLerp(Color color1, Color color2, float d) {
|
||||||
Color newColor = { 0, 0, 0, 0};
|
Color newColor = { 0, 0, 0, 0};
|
||||||
if (t < 0) {t=0.0f;}
|
if (d < 0) {d=0.0f;}
|
||||||
else if(t>1) {t=1.0f;}
|
else if(d>1) {d=1.0f;}
|
||||||
|
|
||||||
newColor.r = (unsigned char)((1.0f-t) * color1.r + t * color2.r);
|
newColor.r = (unsigned char)((1.0f-d) * color1.r + d * color2.r);
|
||||||
newColor.g = (unsigned char)((1.0f-t) * color1.g + t * color2.g);
|
newColor.g = (unsigned char)((1.0f-d) * color1.g + d * color2.g);
|
||||||
newColor.b = (unsigned char)((1.0f-t) * color1.b + t * color2.b);
|
newColor.b = (unsigned char)((1.0f-d) * color1.b + d * color2.b);
|
||||||
newColor.a = (unsigned char)((1.0f-t) * color1.a + t * color2.a);
|
newColor.a = (unsigned char)((1.0f-d) * color1.a + d * color2.a);
|
||||||
|
|
||||||
return newColor;
|
return newColor;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get a Color from HSV values
|
// Get a Color from HSV values
|
||||||
// Implementation reference: https://en.wikipedia.org/wiki/HSL_and_HSV#Alternative_HSV_conversion
|
// Implementation reference: https://en.wikipedia.org/wiki/HSL_and_HSV#Alternative_HSV_conversion
|
||||||
// NOTE: Color->HSV->Color conversion will not yield exactly the same color due to rounding errors
|
// NOTE: Color->HSV->Color conversion will not yield exactly the same color due to rounding errors
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user