Support using a lambda in vecr colorizer

This commit is contained in:
Nikita Lisitsa 2025-04-06 21:55:40 +03:00
parent 472d095e2d
commit 5fcd2a171f

View file

@ -49,10 +49,17 @@ namespace psemek::vecr
template <typename Colorizer>
any_colorizer & operator = (Colorizer && colorizer)
{
if constexpr (std::is_invocable_v<Colorizer, math::point<float, 2> const &, sdf_sample const &>)
{
colorizer_ = std::move(colorizer);
}
else
{
colorizer_ = [colorizer = std::forward<Colorizer>(colorizer)](math::point<float, 2> const & p, sdf_sample const & sample){
return colorize(colorizer, p, sample);
};
}
return *this;
}