1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:07:46 +00:00

LibGfx: Implement simple signed distance field rendering

This is mostly a simple grayscale bilinear scale, with an extra step
of computing the distance and alpha with a little smoothing. This
can be used to paint more scalable UI elements/icons from rather
small distance fields. A tiny 16x16 SDF seems to do a decent job
for simple icons.
This commit is contained in:
MacDue 2023-03-21 20:20:00 +01:00 committed by Sam Atkins
parent 429d7b002b
commit 77456d1d0b
2 changed files with 47 additions and 0 deletions

View file

@ -15,6 +15,7 @@
#include <LibGfx/Font/FontDatabase.h>
#include <LibGfx/Forward.h>
#include <LibGfx/Gradients.h>
#include <LibGfx/GrayscaleBitmap.h>
#include <LibGfx/PaintStyle.h>
#include <LibGfx/Point.h>
#include <LibGfx/Rect.h>
@ -113,6 +114,7 @@ public:
void draw_glyph_or_emoji(FloatPoint, u32, Font const&, Color);
void draw_glyph_or_emoji(FloatPoint, Utf8CodePointIterator&, Font const&, Color);
void draw_circle_arc_intersecting(IntRect const&, IntPoint, int radius, Color, int thickness);
void draw_signed_distance_field(IntRect const& dst_rect, Color, Gfx::GrayscaleBitmap const&, float smoothing);
// Streamlined text drawing routine that does no wrapping/elision/alignment.
void draw_text_run(IntPoint baseline_start, Utf8View const&, Font const&, Color);