Svg.image.layout.sized: def of gralha-svg-render@0.1.0.1 Import: import gralha-svg-render@0.1.0.1/svg.bend as Svg Lines 2720-2730 of gralha-svg-render@0.1.0.1/svg.bend: https://jend.leeeet.dev/read.txt?path=gralha-svg-render@0.1.0.1/svg.bend&start_line=2720&end_line=2730 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 def image.layout.sized(+as: List<&2, XML.Attr>, +values: List<&2, F32>, +vw: F32, +vh: F32) -> List<&2, XML.Attr>: +iw = U.nth(values, 0n, 300.0) +ih = U.nth(values, 1n, 150.0) +ratio = U.nth(values, 2n, 0.0) +aw = U.string.equal(XML.attr.get(as, "width", "auto"), "auto") +ah = U.string.equal(XML.attr.get(as, "height", "auto"), "auto") +rw = dimension(as, "width", vw, "0") +rh = dimension(as, "height", vh, "0") +w = U.choose(F32, aw, U.choose(F32, ah, iw, U.choose(F32, F32.is_gt(ratio, 0.0), (rh * ratio : F32), iw)), rw) +h = U.choose(F32, ah, U.choose(F32, aw, ih, U.choose(F32, F32.is_gt(ratio, 0.0), (rw / U.max(ratio, 0.000001) : F32), ih)), rh) Con{XML.Attr{"width", F32.show(w)}, Con{XML.Attr{"height", F32.show(h)}, as}} Uses (13): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.div https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.is_gt https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.show https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=gralha-svg-render@0.1.0.1/svg.bend&name=dimension https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=choose https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=max https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=nth https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=string.equal https://jend.leeeet.dev/definition.txt?path=gralha-xml-doc@0.1.0.1/xml.bend&name=Attr https://jend.leeeet.dev/definition.txt?path=gralha-xml-doc@0.1.0.1/xml.bend&name=attr.get