def filter.convolution.taps

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

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

4948# The row-major kernel is rotated 180 degrees; target offsets refer to input cells.
4949def filter.convolution.taps(+xs: List<&2, F32>, +index: U32, +width: U32, +height: U32, +tx: F32, +ty: F32, +dx: Point, +dy: Point) -> List<&2, FilterTap>:
4950  match xs:
4951    case Nil{}: Nil{}
4952    case Con{weight, rest}:
4953      +x = (U32.to_f32((width - 1 - U32.mod(index, width) : U32)) - tx : F32)
4954      +y = (U32.to_f32((height - 1 - U32.div(index, width) : U32)) - ty : F32)
4955      U.branch(List<&2, FilterTap>, F32.is_eq(weight, 0.0), _ => filter.convolution.taps(rest, U32.inc(index), width, height, tx, ty, dx, dy),
4956        _ => Con{FilterTap{point.add(point.scale(dx, x), point.scale(dy, y)), weight}, filter.convolution.taps(rest, U32.inc(index), width, height, tx, ty, dx, dy)})

Uses (15)

Used by (1)