An SVG element as data (spec/07 §24), copied from visualize's Visualize.SVG.Element:
%Macaw.Draw.SVG.Element{tag, attrs, children, content}, mirroring an element one to
one: tag an SVG tag atom, attrs a map, children a list of elements, content text
or nil.
iex> alias Macaw.Draw.SVG.Element
iex> Element.svg(width: 10) |> Element.append(Element.circle(r: 2)) |> to_string()
~s(<svg width="10" xmlns="http://www.w3.org/2000/svg"><circle r="2"/></svg>)new(tag, attrs) and one constructor per tag build elements, each taking a map or a
keyword list; attrs/2 merges attributes; append/2 appends an element, a scene IR
element (converted by from_ir/1) or a list mixing both; content/2 sets the text.
from_ir/1 converts a Macaw.Draw.IR.Element tree to the element tree its SVG renderer
writes, exactly: the renderer writes through it (spec/10 §3.2). The element implements
String.Chars, and Phoenix.HTML.Safe when Phoenix.HTML is loaded, so it
interpolates into a template as markup; Macaw.Draw takes no Phoenix dependency.
Summary
Functions
Appends an element, a Macaw.Draw.IR.Element (by from_ir/1), or a list mixing both.
Merges attributes into an element's.
A <circle> element.
A <clipPath> element.
Sets an element's text content; nil clears it.
A <defs> element.
A <ellipse> element.
The element tree the SVG renderer writes for a scene IR element tree (spec/10 §3): each
node's tag, its attributes as Macaw.Draw.Render.SVG writes them, its children and its
text, so the builder and the renderer write one markup. A clipped node converted alone
is its definition and itself, side by side in a group; a node the renderer refuses is
left out, as an interpolation leaves it out (spec/10 §3.5).
A <g> element.
A <line> element.
A <linearGradient> element.
An element of tag with attrs.
A <path> element.
A <polygon> element.
A <polyline> element.
A <radialGradient> element.
A <rect> element.
A <stop> element.
A root <svg>, with xmlns="http://www.w3.org/2000/svg".
A <text> element.
A <title> element.
A <tspan> element.
Types
Functions
@spec append(t(), t() | Macaw.Draw.IR.Element.t() | [t() | Macaw.Draw.IR.Element.t()]) :: t() | error()
Appends an element, a Macaw.Draw.IR.Element (by from_ir/1), or a list mixing both.
Merges attributes into an element's.
A <circle> element.
A <clipPath> element.
Sets an element's text content; nil clears it.
A <defs> element.
A <ellipse> element.
@spec from_ir(Macaw.Draw.IR.Element.t()) :: t() | error()
The element tree the SVG renderer writes for a scene IR element tree (spec/10 §3): each
node's tag, its attributes as Macaw.Draw.Render.SVG writes them, its children and its
text, so the builder and the renderer write one markup. A clipped node converted alone
is its definition and itself, side by side in a group; a node the renderer refuses is
left out, as an interpolation leaves it out (spec/10 §3.5).
A <g> element.
A <line> element.
A <linearGradient> element.
An element of tag with attrs.
A <path> element.
A <polygon> element.
A <polyline> element.
A <radialGradient> element.
A <rect> element.
A <stop> element.
A root <svg>, with xmlns="http://www.w3.org/2000/svg".
A <text> element.
A <title> element.
A <tspan> element.