def filter.padding

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

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-xml-doc@0.1.0.1/xml.bend as XML

5020def filter.padding(+xs: List<&2, XML.Element>, +units: Matrix, +margin: F32) -> F32:
5021  match xs:
5022    case Nil{}: margin
5023    case Con{XML.Element{name, as, kids, txt}, rest}:
5024      +vs = U.numbers(XML.attr.get(as, "stdDeviation", U.choose(String, U.string.equal(name, "feDropShadow"), "2", "0")))
5025      +sx = U.nth(vs, 0n, 0.0)
5026      +sy = U.nth(vs, 1n, sx)
5027      +pad = (3.0 * (point.distance(matrix.vector(units, Point{sx, 0.0}), Point{0.0, 0.0}) + point.distance(matrix.vector(units, Point{0.0, sy}), Point{0.0, 0.0})) : F32)
5028      +radii = U.numbers(XML.attr.get(as, "radius", "0"))
5029      +rx = U.max(U.nth(radii, 0n, 0.0), 0.0)
5030      +ry = U.max(U.nth(radii, 1n, U.nth(radii, 0n, 0.0)), 0.0)
5031      +morphPad = (point.distance(matrix.vector(units, Point{rx, 0.0}), Point{0.0, 0.0}) + point.distance(matrix.vector(units, Point{0.0, ry}), Point{0.0, 0.0}) + 2.0 : F32)
5032      filter.padding(rest, units, U.choose(F32, U.string.equal(name, "feGaussianBlur") || U.string.equal(name, "feDropShadow"), U.max(margin, pad), U.choose(F32, U.string.equal(name, "feMorphology"), U.max(margin, morphPad), margin)))

Uses (17)

Used by (1)