def edge.cross
gralha-svg-render@0.1.0.1 · svg.bend:526
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
526
527def edge.cross(+edge: Edge, +p: Point) -> F32:
528 Edge{x1, y1, x2, y2, stroked, closed} = edge
529 Point{x, y} = p
530 U.branch(F32, (F32.is_le(y1, y) && F32.is_gt(y2, y)) || (F32.is_le(y2, y) && F32.is_gt(y1, y)),
531 _ => U.choose(F32, F32.is_gt((x1 + (y - y1) * (x2 - x1) / (y2 - y1) : F32), x),
532 U.choose(F32, F32.is_gt(y2, y1), 1.0, F32.neg(1.0)), 0.0), _ => 0.0)