@@ -18,21 +18,27 @@ namespace horrible {
1818 inline constexpr cocos2d::ccColor3B gold = {255 , 200 , 150 };
1919 inline constexpr cocos2d::ccColor3B black = {0 , 0 , 0 };
2020
21- inline constexpr cocos2d::ccColor3B lerpColor (cocos2d::ccColor3B const & a, cocos2d::ccColor3B const & b, float t) noexcept {
22- return {
23- static_cast <GLubyte>(a.r + (b.r - a.r ) * t),
24- static_cast <GLubyte>(a.g + (b.g - a.g ) * t),
25- static_cast <GLubyte>(a.b + (b.b - a.b ) * t),
21+ namespace internal {
22+
23+ inline constexpr cocos2d::ccColor3B lerpColor (cocos2d::ccColor3B const & a, cocos2d::ccColor3B const & b, float t) noexcept {
24+ return {
25+ static_cast <GLubyte>(a.r + (b.r - a.r ) * t),
26+ static_cast <GLubyte>(a.g + (b.g - a.g ) * t),
27+ static_cast <GLubyte>(a.b + (b.b - a.b ) * t),
28+ };
2629 };
2730 };
2831
2932 inline constexpr cocos2d::ccColor3B fadeColor (float value) noexcept {
33+ if (value > 100 .f ) value = 100 .f ;
34+ if (value < 0 .f ) value = 0 .f ;
35+
3036 if (value <= 50 .0f ) {
31- float t = value / 50 .0f ;
32- return lerpColor (red, yellow, t);
37+ auto t = value / 50 .0f ;
38+ return internal:: lerpColor (red, yellow, t);
3339 } else {
34- float t = (value - 50 .0f ) / 50 .0f ;
35- return lerpColor (yellow, green, t);
40+ auto t = (value - 50 .0f ) / 50 .0f ;
41+ return internal:: lerpColor (yellow, green, t);
3642 };
3743 };
3844 };
0 commit comments