def mask.region

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

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

2824def mask.region(+as: List<&2, XML.Attr>, +box: Bounds, +m: Matrix, +w: F32, +h: F32) -> Clip:
2825  +user = U.string.equal(XML.attr.get(as, "maskUnits", "objectBoundingBox"), "userSpaceOnUse")
2826  +vw = U.choose(F32, user, w, 1.0)
2827  +vh = U.choose(F32, user, h, 1.0)
2828  +width = dimension(as, "width", vw, "120%")
2829  +height = dimension(as, "height", vh, "120%")
2830  U.branch(Clip, F32.is_gt(width, 0.0) && F32.is_gt(height, 0.0),
2831    _ => ClipShape{edge.tree(path(shape.rect.path(dimension(as, "x", vw, "-10%"), dimension(as, "y", vh, "-10%"), width, height, 0.0, 0.0), 1.0)),
2832      matrix.inverse(matrix.mul(m, U.choose(Matrix, user, identity(), gradient.box(box)))), False{}, cover.none()}, _ => clip.empty())

Uses (23)

Used by (1)