def filter.kernel

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

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

4832def filter.kernel(+vector: Point, +step: F32) -> List<&2, FilterTap>:
4833  +sigma = point.distance(vector, Point{0.0, 0.0})
4834  +radius = U.min(512.0, F32.ceil((3.0 * sigma / step : F32)))
4835  +spacing = U.max(step, (3.0 * sigma / U.max(radius, 1.0) : F32))
4836  +kernel = filter.kernel.raw(U32.to_nat(F32.to_u32((radius * 2.0 + 1.0 : F32))), 0.0, radius, (U.max(sigma, 0.000001) / spacing : F32), point.scale(vector, (spacing / U.max(sigma, 0.000001) : F32)))
4837  U.branch(List<&2, FilterTap>, F32.is_lt(sigma, 0.000001), _ => Con{FilterTap{Point{0.0, 0.0}, 1.0}, Nil{}}, _ => filter.kernel.normalize(kernel, filter.kernel.sum(kernel)))

Uses (19)

Used by (1)