def mask.at

gralha-coverage@0.1.0.1 · cover.bend:77

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

77# Coverage of the pixel containing (px, py), in grid pixel coordinates; the
78# reads branch through matches, not lambdas, since they run once per pixel.
79def mask.at(+m: CovMask, +px: F32, +py: F32) -> F32:
80  CovMask{x, y, w, h, size, depth, data, present} = m
81  +sizeDup = size
82  +yDup = y
83  +xDup = x
84  +fx = F32.floor(px)
85  +fy = F32.floor(py)
86  +ix = (F32.to_u32(U.max(fx, 0.0)) - xDup : U32)
87  +iy = (F32.to_u32(U.max(fy, 0.0)) - yDup : U32)
88  mask.at.in(F32.is_lt(fx, U32.to_f32(xDup)) || F32.is_lt(fy, U32.to_f32(yDup)) || U32.is_ge(ix, sizeDup) || U32.is_ge(iy, sizeDup), data, U32.div(sizeDup, 2), ix, iy)

Uses (13)

Used by (1)