def bitmap.nearest
import gralha-svg-render@0.1.0.1/svg.bend as Svgimport Base
import gralha-text-scan@0.1.0.1/scan.bend as U
2304# Inverse F32 transforms can place an exact texel boundary a few ulps above
2305# its integer value. Snap only that rounding neighborhood before tie-breaking.
2306def bitmap.nearest(+q: F32) -> F32:
2307 +integer = F32.floor((q + 0.5 : F32))
2308 +close = F32.is_le(F32.abs((q - integer : F32)), (U.max(1.0, F32.abs(q)) * 0.000000476837158203125 : F32))
2309 F32.ceil((U.choose(F32, close, integer, q) - 1.0 : F32))