mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-08 04:18:15 +00:00
ADDED: ColorBrightness()
This commit is contained in:
@@ -1331,6 +1331,7 @@ RLAPI Vector4 ColorNormalize(Color color); // G
|
|||||||
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 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 ColorBrightness(Color color, float factor); // Get color with brightness correction, brightness factor goes from 0.0f to 1.0f
|
||||||
RLAPI Color ColorAlpha(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 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 ColorAlphaBlend(Color dst, Color src, Color tint); // Get src alpha-blended into dst color with tint
|
||||||
RLAPI Color GetColor(unsigned int hexValue); // Get Color structure from hexadecimal value
|
RLAPI Color GetColor(unsigned int hexValue); // Get Color structure from hexadecimal value
|
||||||
|
@@ -3944,6 +3944,39 @@ Color ColorFromHSV(float hue, float saturation, float value)
|
|||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get color with brightness correction, brightness factor goes from 0.0f to 1.0f
|
||||||
|
Color ColorBrightness(Color color, float factor)
|
||||||
|
{
|
||||||
|
Color result = color;
|
||||||
|
|
||||||
|
if (factor > 1.0f) factor = 1.0f;
|
||||||
|
else if (factor < -1.0f) factor = -1.0f;
|
||||||
|
|
||||||
|
float red = (float)color.r;
|
||||||
|
float green = (float)color.g;
|
||||||
|
float blue = (float)color.b;
|
||||||
|
|
||||||
|
if (factor < 0.0f)
|
||||||
|
{
|
||||||
|
factor = 1.0f + factor;
|
||||||
|
red *= factor;
|
||||||
|
green *= factor;
|
||||||
|
blue *= factor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
red = (255 - red)*factor + red;
|
||||||
|
green = (255 - green)*factor + green;
|
||||||
|
blue = (255 - blue)*factor + blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.r = (unsigned char)red;
|
||||||
|
result.g = (unsigned char)green;
|
||||||
|
result.b = (unsigned char)blue;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Get color with alpha applied, alpha goes from 0.0f to 1.0f
|
// Get color with alpha applied, alpha goes from 0.0f to 1.0f
|
||||||
Color ColorAlpha(Color color, float alpha)
|
Color ColorAlpha(Color color, float alpha)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user