Add gfx::blend for colors
This commit is contained in:
parent
441db52e71
commit
63f576aee5
1 changed files with 13 additions and 0 deletions
|
|
@ -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 <std::size_t N>
|
||||
auto blend(geom::vector<std::uint8_t, N> const & c0, geom::vector<std::uint8_t, N> const & c1, float t)
|
||||
{
|
||||
return to_coloru8(blend(to_colorf(c0), to_colorf(c1), t));
|
||||
}
|
||||
|
||||
template <std::size_t N>
|
||||
auto to_srgb(geom::vector<float, N> const & c, float g = 1.f / 2.2f)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue