def tile.blend

gralha-svg-render@0.1.0.1 · svg.bend:2331

import gralha-svg-render@0.1.0.1/svg.bend as Svg
import Base
import gralha-image@0.1.0.1/image.bend as Img

2331def tile.blend(+pixels: Img.Pixels, +side: U32, +width: U32, +height: U32, +fx: F32, +fy: F32) -> Img.Color:
2332  +ix = F32.floor(fx)
2333  +iy = F32.floor(fy)
2334  +dx = (fx - ix : F32)
2335  +dy = (fy - iy : F32)
2336  +x0 = tile.index(ix, width)
2337  +x1 = tile.index((ix + 1.0 : F32), width)
2338  +y0 = tile.index(iy, height)
2339  +y1 = tile.index((iy + 1.0 : F32), height)
2340  color.add(color.add(tile.corner(pixels, side, x0, y0, ((1.0 - dx) * (1.0 - dy) : F32)), tile.corner(pixels, side, x1, y0, (dx * (1.0 - dy) : F32))),
2341    color.add(tile.corner(pixels, side, x0, y1, ((1.0 - dx) * dy : F32)), tile.corner(pixels, side, x1, y1, (dx * dy : F32))))

Uses (11)

Used by (1)