def ttf.contour.last

gralha-truetype@0.1.0.1 · font.bend:468

import gralha-truetype@0.1.0.1/font.bend as Font
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U

468# A contour starts at its first on-curve point; when the first point is off-curve,
469# the last point starts it if on-curve, else the implied midpoint between last and first.
470def ttf.contour.last(+first: TTPoint, +rest: List<&2, TTPoint>, last: TTPoint) -> String:
471  TTPoint{lx, ly, lon} = last
472  +x = lx
473  +y = ly
474  U.branch(String, lon,
475    _ => "M" ++ ttf.pair(TTPoint{x, y, True{}}) ++ ttf.walk(Con{first, ttf.init(rest)}, None{}, TTPoint{x, y, True{}}),
476    _ => ttf.contour.implied(ttf.mid(first, TTPoint{x, y, False{}}), first, rest))

Uses (12)

Used by (1)