Quartz.SVG (Quartz v0.8.1)

View Source

Utilities to work with SVG elements.

This is made public in case users want to create their own sketches, as a sketch needs to know how to render itself into SVG.

Summary

Types

t()

An SVG element is represented by

Functions

SVG <circle/> element.

Render a full document into a binary.

Render a full document into an iolist.

SVG <g/> element.

SVG <line/> element.

SVG <rect/> element.

Build a top level SVG element.

SVG <text/> element.

SVG <title/> element.

SVG <tspan/> element.

Escapes the given HTML to iodata.

Types

t()

@type t() :: {binary(), list(), list()}

An SVG element is represented by

Functions

attr_value_to_iodata(color)

attrs_to_iodata(attrs)

circle(attrs, content \\ [])

SVG <circle/> element.

doc_to_binary(doc)

Render a full document into a binary.

doc_to_iolist(doc)

Render a full document into an iolist.

escaped_iodata(iodata)

g(attrs, contents)

SVG <g/> element.

line(attrs, content \\ [])

SVG <line/> element.

path(attrs, content \\ [])

Build a path.

rect(attrs, content \\ [])

SVG <rect/> element.

style_to_iodata(style_attrs)

svg(attrs, contents)

Build a top level SVG element.

svg_doc_dimension(dim)

text(attrs, content)

SVG <text/> element.

title(attrs, content)

SVG <title/> element.

This element is not rendered but is very useful for debugging. It can be used to show properties of the containing element.

to_binary(element)

to_iodata(list_of_stuff)

tspan(attrs, content)

SVG <tspan/> element.

xml_escape(data)

@spec xml_escape(any()) :: any()

xml_escape_iodata(data)

@spec xml_escape_iodata(iodata()) :: {:escaped_iodata, iodata()}

xml_escape_to_iodata(data)

@spec xml_escape_to_iodata(String.t()) :: {:escaped_iodata, iodata()}

Escapes the given HTML to iodata.

iex> Quartz.SVG.xml_escape_to_iodata("foo")
{:escaped_iodata, "foo"}

iex> Quartz.SVG.xml_escape_to_iodata("<foo>")
{:escaped_iodata, [[[] | "&lt;"], "foo" | "&gt;"]}

iex> Quartz.SVG.xml_escape_to_iodata("quotes: \" & \'")
{:escaped_iodata, [[[[], "quotes: " | "&quot;"], " " | "&amp;"], " " | "&#39;"]}