def image.svg.size
gralha-svg-render@0.1.0.1 · svg.bend:3850
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
3850def image.svg.size(+as: List<&2, XML.Attr>) -> Point:
3851 +w = image.svg.absolute(XML.attr.get(as, "width", "auto"))
3852 +h = image.svg.absolute(XML.attr.get(as, "height", "auto"))
3853 +ratio = image.svg.ratio(as)
3854 +hasW = F32.is_ge(w, 0.0)
3855 +hasH = F32.is_ge(h, 0.0)
3856 +hasRatio = F32.is_gt(ratio, 0.0)
3857 +dw = U.choose(F32, hasRatio, U.min(300.0, (150.0 * ratio : F32)), 300.0)
3858 +dh = U.choose(F32, hasRatio, (dw / U.max(ratio, 0.000001) : F32), 150.0)
3859 Point{U.choose(F32, hasW, w, U.choose(F32, hasH && hasRatio, (h * ratio : F32), dw)), U.choose(F32, hasH, h, U.choose(F32, hasW && hasRatio, (w / U.max(ratio, 0.000001) : F32), dh))}