def raster.sample
gralha-svg-render@0.1.0.1 · svg.bend:2262
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
import gralha-image@0.1.0.1/image.bend as Img
2262def raster.sample(+r: Raster, p: Point) -> Img.Color:
2263 Raster{Point{ox, oy}, step, width, height, depth, pixelsLinear, pixels} = r
2264 Point{x, y} = p
2265 +fx = ((x - ox) / step - 0.5 : F32)
2266 +fy = ((y - oy) / step - 0.5 : F32)
2267 +ix = F32.floor(fx)
2268 +iy = F32.floor(fy)
2269 +dx = (fx - ix : F32)
2270 +dy = (fy - iy : F32)
2271 U.branch(Img.Color, F32.is_eq(dy, 0.0), _ => raster.horizontal(r, ix, iy, dx),
2272 _ => color.mix(raster.horizontal(r, ix, iy, dx), raster.horizontal(r, ix, (iy + 1.0 : F32), dx), dy))