diff options
author | chai <chaifix@163.com> | 2018-11-16 00:24:51 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-11-16 00:24:51 +0800 |
commit | 831e814ce9bdb84e86c06c4a52008f6bdaaa00d6 (patch) | |
tree | f91fccc7d2628d6e0a39886134b2bb174f5eede4 /src/libjin/Graphics/je_color.h | |
parent | 6dc75930fe5fe02f1af5489917752d315cf9e48f (diff) |
*合并master到minimal分支
Diffstat (limited to 'src/libjin/Graphics/je_color.h')
-rw-r--r-- | src/libjin/Graphics/je_color.h | 32 |
1 files changed, 29 insertions, 3 deletions
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<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; + } + /// /// /// @@ -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 |