type

Svg

src @Js
const class Svg : Obj

SVG (Scalar Vector Graphics) utilities

fields

ns

SVG XML namesapce

nsXLink

XLink XML namespace

methods

def

Auto-generate an id for the def element and mount it into the svg document's defs section.

defUrl

Mount a definition element using def and return a CSS URL to the fragment identifier such as "url(#def-d)".

elem

Create element with proper namespace

image

Convenience to create a image element

line

Convenience to create line element

rect

Convenience to create rect element

text

Convenience to create text element

Slot Details

def

src static Str def(Elem svgElem, Elem defElem)

Auto-generate an id for the def element and mount it into the svg document's defs section. This method will automatically generate a <defs> child in the svg document as needed. If defs already has an id or is already mounted, then no action is taken.

defUrl

src static Str defUrl(Elem svgElem, Elem defElem)

Mount a definition element using def and return a CSS URL to the fragment identifier such as "url(#def-d)". This is used to reference gradient and clip definitions.

elem

src static Elem elem(Str tagName)

Create element with proper namespace

image

src static Elem image(Uri href, Float x, Float y, Float w, Float h)

Convenience to create a image element

line

src static Elem line(Num x1, Num y1, Num x2, Num y2)

Convenience to create line element

ns

src const static Uri ns := `http://www.w3.org/2000/svg`

SVG XML namesapce

src const static Uri nsXLink := `http://www.w3.org/1999/xlink`

XLink XML namespace

rect

src static Elem rect(Num x, Num y, Num w, Num h)

Convenience to create rect element

text

src static Elem text(Str text, Num x, Num y)

Convenience to create text element