def arc.draw

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

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

351def arc.draw(+p: Path, +q: Point, +cmd: U32, +rx: F32, +ry: F32, +phi: F32,
352  +center: Point, +theta: F32, +delta: F32) -> Path:
353  Path{cur, start, ctrl, old, prev, es, trace, tol} = p
354  # A chord of angle step on the larger radius stays within the tolerance:
355  # step = 2 acos(1 - tol / r), approximated by 2 sqrt(2 tol / r).
356  +tt = tol
357  +step = U.max(0.001, (2.0 * F32.sqrt((2.0 * U.max(tt, 0.000001) / U.max(rx, ry) : F32)) : F32))
358  +count = U.max(1.0, F32.ceil((F32.abs(delta) / step : F32)))
359  Path{q, start, q, cmd, 65, arc.edges(U32.to_nat(F32.to_u32(U.min(4096.0, count))),
360    1.0, (delta / U.min(4096.0, count) : F32), theta, center, rx, ry, phi, q, cur, es), marker.segment(trace, MarkerSegment{cur, q, marker.arc.tangent(rx, ry, phi, theta, delta), marker.arc.tangent(rx, ry, phi, (theta + delta : F32), delta), 0}), tt}

Uses (18)

Used by (1)