Pulp
1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
path_to_sdf.hpp
Go to the documentation of this file.
1
#pragma once
2
3
// Runtime Path → SDF conversion.
4
//
5
// For procedural UI that draws arbitrary shapes (vector icons, custom
6
// glyphs, generated decorations) we want the same SDF quality as font
7
// text without pre-building an atlas. `path_to_sdf()` accepts a binary
8
// mask of a rasterized shape and runs the Felzenszwalb-Huttenlocher EDT
9
// to produce the signed distance field, mapped to the same [0, 255]
10
// convention (`128 == edge`) as `SdfAtlas`.
11
//
12
// The binary mask is the caller's responsibility — either
13
// `SkPath::toSimpleSVGString()` + nanosvg rasterization, or a direct
14
// `SkCanvas::drawPath()` into an off-screen `SkSurface` (the normal
15
// path for SkiaCanvas-backed callers).
16
17
#include <cstdint>
18
#include <vector>
19
20
namespace
pulp::canvas
{
21
22
// Given a width×height mask (0 = outside, 255 = inside), returns a
23
// width×height SDF where 128 corresponds to the edge. `spread` is the
24
// maximum distance (in pixels) encoded before saturating to 0 or 255.
25
std::vector<std::uint8_t>
path_to_sdf
(
const
std::uint8_t* mask,
26
int
width,
int
height,
27
int
spread = 8);
28
29
}
// namespace pulp::canvas
pulp::canvas
Definition
affine_transform.hpp:24
pulp::canvas::path_to_sdf
std::vector< std::uint8_t > path_to_sdf(const std::uint8_t *mask, int width, int height, int spread=8)
core
canvas
include
pulp
canvas
path_to_sdf.hpp
Generated by
1.15.0