def brush.resource

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

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

2429def brush.resource(result: Maybe<&2, XML.Element>, +all: List<&2, XML.Element>, +box: Bounds, +w: F32, +h: F32,
2430  +opacity: F32, fallback: String, patterns: XML.Element -> Bounds -> F32 -> F32 -> F32 -> Brush) -> Brush:
2431  match result:
2432    case None{}: brush.solid(color(fallback), opacity)
2433    case Some{XML.Element{tagname, as, kids, txt}}:
2434      +tag = tagname
2435      +node = {XML.Element{tag, as, kids, txt} : XML.Element}
2436      U.branch(Brush, gradient.is.valid(node), _ => gradient.build(gradient.resolve(32n, node, all), box, w, h, opacity),
2437        _ => U.branch(Brush, U.string.equal(tag, "pattern"), _ => patterns(node)(box)(w)(h)(opacity),
2438          _ => brush.solid(color(fallback), opacity)))

Uses (14)

Used by (1)