def line.split
gralha-coverage@0.1.0.1 · cover.bend:156
import gralha-coverage@0.1.0.1/cover.bend as Cover
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
156def line.split(l: CovLine, +at: F32) -> List<&2, CovLine>:
157 CovLine{x0, y0, x1, y1} = l
158 +ax = x0
159 +ay = y0
160 +bx = x1
161 +by = y1
162 +t = ((at - ax) / (bx - ax) : F32)
163 +my = (ay + (by - ay) * t : F32)
164 U.branch(List<&2, CovLine>, (F32.is_lt(ax, at) && F32.is_gt(bx, at)) || (F32.is_gt(ax, at) && F32.is_lt(bx, at)),
165 _ => Con{CovLine{ax, ay, at, my}, Con{CovLine{at, my, bx, by}, Nil{}}},
166 _ => Con{CovLine{ax, ay, bx, by}, Nil{}})