Expand description
§esvg
A document object model based SVG library for construction of vector graphics.
Access is available to the attributes and tags allowing you to construct any SVG you need.
Uses Polygonical for its shape representation
§Examples
Construct a document and draw a circle
use esvg::page::Page;
use esvg::{create_document, Element};
use polygonical::point::Point;
let page = Page::A4(96); // 96 dpi
let mut doc = create_document(&page);
let mut group = Element::new("g");
group.set("class", "foo");
let mut circle = esvg::shapes::circle(page.center(), 50);
circle.add_style("stroke", "red");
group.add(&circle);
doc.add(&group);
let expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">
<svg height=\"297.1270833333333mm\" viewBox=\"0, 0, 794, 1123\" width=\"210.07916666666668mm\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">
\t<g class=\"foo\">
\t\t<circle cx=\"397\" cy=\"561\" fill=\"none\" r=\"50\" style=\"stroke:red\" />
\t</g>
</svg>
";
assert_eq!(doc.to_pretty_string(), expected);
§Features
- Constructing SVGs in memory
- Reading SVGs (Including comments and text nodes)
- Writing SVGs (Including comments and text nodes)
- Path objects
- Text objects
- Circles
- Common page sizes built in
§Wanted features
- Path data to polygons
§Things we explicitly won’t support
- Converting SVGs to other formats.
Modules§
- convert
- A collection of useful conversion functions
- error
- Error types used by this library
- page
- Things to do with the document being created, its size, its borders, etc
- path
- Helpers for handling Path data
- read
- Tools for reading in svg files
- shapes
- Helper functions for creating particular shapes
- text
- Helper functions for handling text
- value
- Attribute values and handling different types that can be converted to a value
Structs§
- Element
- An svg xml tag
Enums§
- Node
- Defines a node in the xml tree
Functions§
- create_
document - Create a new document with the width, height, and view box setup for the provided page.
- read
- Read an svg from the given path.
- save
- Write the provided document to a file at the given path.