From d74e03063095d43c654fa52c3868f7ef8fce69f1 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 23 Oct 2018 22:09:22 +0800 Subject: =?UTF-8?q?*=E7=B2=92=E5=AD=90=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/Graphics/je_color.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/libjin/Graphics/je_color.h') 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(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; + } + /// /// /// -- cgit v1.1-26-g67d0