A simple solution for creating SVGs in Elixir.
Summary
Functions
Adds a new SVG item to a Victor.
Gets the string representation of a SVG.
Creates a new Victor.
Writes a SVG string to a given file.
Adds a new SVG item to a Victor.
- victor: A Victor struct to add the item to.
- tag: The SVG tag type to be added (as an atom).
- props: A map of properties for the SVG item (i.e. width).
- style: An optional map of style properties for the SVG item.
iex> Victor.add(%Victor{}, :circle, %{cx: 10, cy: 10, r: 20})
%Victor{width: 100, height: 100, items: [{:circle, %{cx: 10, cy: 10, r: 20}, []}]}
iex> Victor.add(%Victor{}, :rect, %{x: 10, y: 10, width: 100, height: 50}, %{fill: "red"})
%Victor{width: 100, height: 100, items: [{:rect, %{x: 10, y: 10, width: 100, height: 50, style: "fill:red"}, []}]} Gets the string representation of a SVG.
- victor: A Victor struct to convert to a string.
iex> Victor.get_svg(%Victor{})
"<svg viewBox=\"0 0 100 100\" xmlns=\"http://www.w3.org/2000/svg\" />"
iex> Victor.add(%Victor{}, :circle, %{cx: 10, cy: 10, r: 20}) |> Victor.get_svg()
"<svg viewBox=\"0 0 100 100\" xmlns=\"http://www.w3.org/2000/svg\">\n\t<circle cx=\"10\" cy=\"10\" r=\"20\" />\n</svg>" Creates a new Victor.
- size: An optional map with
widthandheightkeys.
iex> Victor.new()
%Victor{width: 100, height: 100, items: []}
iex> Victor.new(%{width: 600, height: 400})
%Victor{width: 600, height: 400, items: []} Writes a SVG string to a given file.
A simple wrapper around File.write/2.
- svg: A string representation of a SVG.
- filepath: The path to the file.