aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/je_color.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/Graphics/je_color.h')
-rw-r--r--src/libjin/Graphics/je_color.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libjin/Graphics/je_color.h b/src/libjin/Graphics/je_color.h
index 8fe7691..10d2818 100644
--- a/src/libjin/Graphics/je_color.h
+++ b/src/libjin/Graphics/je_color.h
@@ -6,6 +6,8 @@
#include "../core/je_configuration.h"
#if defined(jin_graphics)
+#include "../math/je_math.h"
+
#include "../common/je_types.h"
#include "../utils/je_endian.h"
@@ -28,6 +30,25 @@ namespace JinEngine
static const Color MAGENTA;
static const Color YELLOW;
+ ///
+ /// Get lerp color with given factor.
+ ///
+ /// @param start Start color.
+ /// @param end End color.
+ /// @param t Factor of interplation.
+ /// @return Color after interplation.
+ ///
+ static Color lerp(Color start, Color end, float t)
+ {
+ t = Math::clamp<float>(t, 0, 1);
+ Color c;
+ c.r = Math::lerp(start.r, end.r, t);
+ c.g = Math::lerp(start.g, end.g, t);
+ c.b = Math::lerp(start.b, end.b, t);
+ c.a = Math::lerp(start.a, end.a, t);
+ return c;
+ }
+
///
///
///