diff --git a/src/common/tvgMath.cpp b/src/common/tvgMath.cpp index 2b2f1b32..6275554a 100644 --- a/src/common/tvgMath.cpp +++ b/src/common/tvgMath.cpp @@ -363,4 +363,14 @@ float Bezier::angle(float t) const return rad2deg(tvg::atan2(pt.y, pt.x)); } -} \ No newline at end of file + +uint8_t lerp(const uint8_t &start, const uint8_t &end, float t) +{ + auto result = static_cast(start + (end - start) * t); + if (result > 255) result = 255; + else if (result < 0) result = 0; + return static_cast(result); +} + +} + diff --git a/src/common/tvgMath.h b/src/common/tvgMath.h index 71509d57..3d020929 100644 --- a/src/common/tvgMath.h +++ b/src/common/tvgMath.h @@ -286,6 +286,8 @@ static inline T lerp(const T &start, const T &end, float t) return static_cast(start + (end - start) * t); } +uint8_t lerp(const uint8_t &start, const uint8_t &end, float t); + } #endif //_TVG_MATH_H_