def piece.events

gralha-coverage@0.1.0.1 · cover.bend:679

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

679# The contributions of a line piece clipped to the row [y, y + 1).
680def piece.events(p: Piece, +y: F32, +w: U32, b: (Array<F32> & Array<U32>) & (U32 & U32)) -> (Array<F32> & Array<U32>) & (U32 & U32):
681  Piece{x0, y0, slope, top, bottom, dir} = p
682  +xx0 = x0
683  +yy0 = y0
684  +s = slope
685  +ya = U.max(top, y)
686  +yb = U.min(bottom, (y + 1.0 : F32))
687  +xa = (xx0 + (ya - yy0) * s : F32)
688  +xb = (xx0 + (yb - yy0) * s : F32)
689  +span = F32.to_u32((F32.abs((F32.floor(xb) - F32.floor(xa) : F32)) + 2.0 : F32))
690  piece.cuts(F32.is_le(yb, ya), U32.to_nat(span), xa, ya, xb, yb, dir, s, w, b)

Uses (16)

Used by (1)