def outline.inner

gralha-svg-render@0.1.0.1 · svg.bend:1520

import gralha-svg-render@0.1.0.1/svg.bend as Svg
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U

1520# On the inner side the two offset lines cross; when they cross within both
1521# segments that point replaces both offset ends, so the outline has no loop
1522# there. Otherwise (a segment shorter than the offset) the ends stay and the
1523# loop they make still fills under nonzero winding.
1524def outline.inner(+p: Point, +u: Point, +a1: Point, +lenPrev: F32, +v: Point, +b0: Point, +lenNext: F32, +acc: List<&2, Point>) -> List<&2, Point>:
1525  +den = point.cross(u, v)
1526  +t = (point.cross(point.sub(b0, a1), v) / den : F32)
1527  +s = (point.cross(point.sub(b0, a1), u) / den : F32)
1528  U.choose(List<&2, Point>, F32.is_le(t, 0.0) && F32.is_ge(t, F32.neg(lenPrev)) && F32.is_ge(s, 0.0) && F32.is_le(s, lenNext),
1529    Con{point.add(a1, point.scale(u, t)), acc}, Con{b0, Con{a1, acc}})

Uses (13)

Used by (1)