From 831e814ce9bdb84e86c06c4a52008f6bdaaa00d6 Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 16 Nov 2018 00:24:51 +0800 Subject: =?UTF-8?q?*=E5=90=88=E5=B9=B6master=E5=88=B0minimal=E5=88=86?= =?UTF-8?q?=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/Graphics/je_color.h | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (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..06b8f61 100644 --- a/src/libjin/Graphics/je_color.h +++ b/src/libjin/Graphics/je_color.h @@ -1,11 +1,13 @@ /** * Some color operating here. */ -#ifndef __JE_COLOR_H -#define __JE_COLOR_H +#ifndef __JE_COLOR_H__ +#define __JE_COLOR_H__ #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,30 @@ namespace JinEngine static const Color MAGENTA; static const Color YELLOW; + static const uint32 RMASK; + static const uint32 GMASK; + static const uint32 BMASK; + static const uint32 AMASK; + + /// + /// 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; + } + /// /// /// @@ -90,4 +116,4 @@ namespace JinEngine #endif // jin_graphics -#endif // __JE_COLOR_H \ No newline at end of file +#endif // __JE_COLOR_H__ \ No newline at end of file -- cgit v1.1-26-g67d0