def shape.data
gralha-svg-render@0.1.0.1 · svg.bend:883
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
883
884
885def shape.data(+name: String, +as: List<&2, XML.Attr>, +vw: F32, +vh: F32, data: String) -> String:
886 U.branch(String, U.string.equal(name, "path"), _ => data,
887 _ => U.branch(String, U.string.equal(name, "rect") || U.string.equal(name, "image") || U.string.equal(name, "#svg-image"), _ => shape.rect(as, vw, vh),
888 _ => U.branch(String, U.string.equal(name, "circle"),
889 _ => shape.ellipse.path(dimension(as, "cx", vw, "0"), dimension(as, "cy", vh, "0"),
890 dimension(as, "r", F32.sqrt(((vw * vw + vh * vh) / 2.0 : F32)), "0"),
891 dimension(as, "r", F32.sqrt(((vw * vw + vh * vh) / 2.0 : F32)), "0")),
892 _ => U.branch(String, U.string.equal(name, "ellipse"),
893 _ => shape.ellipse.path(dimension(as, "cx", vw, "0"), dimension(as, "cy", vh, "0"),
894 dimension(as, "rx", vw, "0"), dimension(as, "ry", vh, "0")),
895 _ => U.branch(String, U.string.equal(name, "line"),
896 _ => "M" ++ xy(dimension(as, "x1", vw, "0"), dimension(as, "y1", vh, "0"))
897 ++ "L" ++ xy(dimension(as, "x2", vw, "0"), dimension(as, "y2", vh, "0")),
898 _ => U.branch(String, U.string.equal(name, "polygon") || U.string.equal(name, "polyline"),
899 _ => "M" ++ XML.attr.get(as, "points", "") ++ U.choose(String, U.string.equal(name, "polygon"), "Z", ""),
900 _ => ""))))))