def outline.miter.pick

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

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

1469# The join on the left side at vertex p, from the incoming direction u to the
1470# outgoing v, when that side is the outer one (the path turns right). Both
1471# offset endpoints a = p + r n(u) and b = p + r n(v) are pushed by the
1472# segments; only what lies between them is added here.
1473def outline.miter.pick(fits: Bool, clip: Bool, +m: Point, +a: Point, +b: Point, +da: F32, +db: F32, +distance: F32, +reach: F32, acc: List<&2, Point>) -> List<&2, Point>:
1474  match fits:
1475    case True{}: Con{m, acc}
1476    case False{}:
1477      match clip:
1478        case True{}:
1479          Con{point.add(b, point.scale(point.sub(m, b), U.clamp(((reach - db) / (distance - db) : F32), 0.0, 1.0))),
1480            Con{point.add(a, point.scale(point.sub(m, a), U.clamp(((reach - da) / (distance - da) : F32), 0.0, 1.0))), acc}}
1481        case False{}: acc

Uses (10)

Used by (1)