Skip to content

Commit

Permalink
directvt#571 WIP: Revise title rendering (shadows + fix overbright)
Browse files Browse the repository at this point in the history
  • Loading branch information
o-sdn-o committed Apr 19, 2024
1 parent 37012c2 commit 6659c6f
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 90 deletions.
19 changes: 19 additions & 0 deletions src/netxs/desktopio/canvas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2962,7 +2962,10 @@ namespace netxs
digest++;
}
};
}

namespace netxs::misc
{
template<si32 Repeat = 2, bool InnerGlow = faux, class T = vrgb, class P = noop, si32 Ratio = 1>
void boxblur(auto& image, si32 r, T&& cache = {}, P shade = {})
{
Expand Down Expand Up @@ -2998,4 +3001,20 @@ namespace netxs
d_width, Ratio, s_point,
d_point, shade);
}
void contour(auto& image)
{
static auto shadows_cache = std::vector<fp32>{};
static auto boxblur_cache = std::vector<fp32>{};
auto r = image.area();
auto v = r.size.x * r.size.y;
boxblur_cache.resize(v);
shadows_cache.resize(v);
auto shadows_image = netxs::raster<std::span<fp32>, rect>{ shadows_cache, r };
shadows_image.step(-dot_11);
netxs::onbody(image, shadows_image, [](auto& src, auto& dst){ dst = src ? 255.f * 3.f : 0.f; });
shadows_image.step(dot_11);
shadows_image.clip(r);
netxs::misc::boxblur<2>(shadows_image, 1, boxblur_cache);
netxs::oncopy(image, shadows_image, [](auto& src, auto& dst){ src.chan.a = src ? 0xFF : (byte)std::clamp(dst, 0.f, 255.f); });
}
}
1 change: 1 addition & 0 deletions src/netxs/desktopio/geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ namespace netxs
twod map (twod p) const { return p - coor; }
rect shift (twod p) const { return { coor + p, size }; }
auto& shift_itself (twod p) { coor += p; return *this; }
auto& moveto (twod p) { coor = p; return *this; }
rect operator | (rect r) const { return unite(r, *this); }
auto& operator += (rect r) { coor += r.coor; size += r.size; return *this; }
auto& operator -= (rect r) { coor -= r.coor; size -= r.size; return *this; }
Expand Down
Loading

0 comments on commit 6659c6f

Please sign in to comment.