Vectored.Renderable protocol (Vectored v0.4.0)

Copy Markdown View Source

Protocol for rendering data structures to SVG internal representations.

This protocol is responsible for converting Vectored element structs into the format expected by Erlang's :xmerl.

Most users will interact with Vectored.to_svg_string/1 instead of calling this protocol directly.

Format

The rendered format is typically a tuple: {tag_name, attributes, children}.

  • tag_name is an atom (e.g., :circle).
  • attributes is a keyword list of {atom, value} pairs.
  • children is a list of rendered elements or text nodes.

Summary

Types

t()

All the types that implement this protocol.

Functions

Render an element as xmerl-compatible XML structures.

Types

simple_element()

@type simple_element() ::
  {atom(), [{atom(), iolist() | atom() | integer()}], [simple_element()]}
  | {atom(), [simple_element()]}
  | atom()
  | iolist()
  | :xmerl.element()

t()

@type t() :: term()

All the types that implement this protocol.

Functions

to_svg(element)

@spec to_svg(t()) :: simple_element() | :xmerl.xmlElement()

Render an element as xmerl-compatible XML structures.