diff --git a/libs/gfx/include/psemek/gfx/color.hpp b/libs/gfx/include/psemek/gfx/color.hpp index f70e1f20..845776c6 100644 --- a/libs/gfx/include/psemek/gfx/color.hpp +++ b/libs/gfx/include/psemek/gfx/color.hpp @@ -83,6 +83,19 @@ namespace psemek::gfx return to_coloru8(lerp(to_colorf(c0), to_colorf(c1), t)); } + inline color_4f blend(color_4f const & c0, color_4f const & c1) + { + color_4f result = lerp(c0, c1, c1[3]); + result[3] = c0[3] * (1.f - c1[3]) + c1[3]; + return result; + } + + template + auto blend(geom::vector const & c0, geom::vector const & c1, float t) + { + return to_coloru8(blend(to_colorf(c0), to_colorf(c1), t)); + } + template auto to_srgb(geom::vector const & c, float g = 1.f / 2.2f) {