From 00c611a5fbb7087514e1663a3750529333927ea2 Mon Sep 17 00:00:00 2001 From: ChrisDill Date: Fri, 8 Nov 2019 20:02:41 +0000 Subject: [PATCH] [Core] Added ColorFromNormalized which is the reverse of ColorNormalize. (#1011) --- src/core.c | 13 +++++++++++++ src/raylib.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/core.c b/src/core.c index b247c1aa..518472e2 100644 --- a/src/core.c +++ b/src/core.c @@ -1616,6 +1616,19 @@ Vector4 ColorNormalize(Color color) return result; } +// Returns color from normalized values [0..1] +Color ColorFromNormalized(Vector4 normalized) +{ + Color result; + + result.r = normalized.x*255.0f; + result.g = normalized.y*255.0f; + result.b = normalized.z*255.0f; + result.a = normalized.w*255.0f; + + return result; +} + // Returns HSV values for a Color // NOTE: Hue is returned as degrees [0..360] Vector3 ColorToHSV(Color color) diff --git a/src/raylib.h b/src/raylib.h index 7b6bb328..a0bc09f4 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -924,6 +924,7 @@ RLAPI double GetTime(void); // Returns ela // Color-related functions RLAPI int ColorToInt(Color color); // Returns hexadecimal value for a Color RLAPI Vector4 ColorNormalize(Color color); // Returns color normalized as float [0..1] +RLAPI Color ColorFromNormalized(Vector4 normalized); // Returns color from normalized values [0..1] RLAPI Vector3 ColorToHSV(Color color); // Returns HSV values for a Color RLAPI Color ColorFromHSV(Vector3 hsv); // Returns a Color from HSV values RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value