def filter.resource

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

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
import gralha-css-style@0.1.0.1/css.bend as CSS

2616def filter.resource(result: Maybe<&2, XML.Element>, +box: Bounds, m: Matrix, +w: F32, +h: F32) -> FilterEffect:
2617  match result:
2618    case None{}: NoFilter{}
2619    case Some{XML.Element{name, attrs, kids, txt}}:
2620      +as = CSS.properties(attrs)
2621      +object = U.string.equal(XML.attr.get(as, "primitiveUnits", "userSpaceOnUse"), "objectBoundingBox")
2622      U.branch(FilterEffect, U.string.equal(name, "filter"), _ => FilterSpec{filter.region(as, box, w, h, object), matrix.mul(m, U.choose(Matrix, object, gradient.box(box), identity())), Point{U.choose(F32, object, 1.0, w), U.choose(F32, object, 1.0, h)}, as, kids}, _ => NoFilter{})

Uses (16)

Used by (1)