svgtypes

Build Status Crates.io Documentation

svgtypes is a collection of parsers, containers and writers for SVG types.

Usage is simple as:

```rust use svgtypes::Path;

let path: Path = "M10-20A5.5.3-4 110-.1".parse().unwrap(); asserteq!(path.tostring(), "M 10 -20 A 5.5 0.3 -4 1 1 0 -0.1"); ```

You can also use a low-level, pull-based parser:

```rust use svgtypes::PathParser;

let p = PathParser::from("M10-20A5.5.3-4 110-.1"); for token in p { println!("{:?}", token); } ```

You can also tweak an output format:

```rust use svgtypes::{Path, WriteBuffer, WriteOptions};

let pathstr = "M10-20A5.5.3-4 110-.1"; let path: Path = pathstr.parse().unwrap();

let opt = WriteOptions { removeleadingzero: true, usecompactpathnotation: true, joinarctoflags: true, .. WriteOptions::default() };

asserteq!(path.withwriteopt(&opt).tostring(), path_str); ```

Supported SVG types

| SVG Type | Rust Type | Storage | Parser | | ------------------------- | ------------- | ------- | ------------------- | | [\

Benefits

Limitations

Safety

Alternatives

None.

Migration from svgparser

This crate is a successor for the svgparser crate, but it differs from it in many ways.

Usage

Dependency: Rust >= 1.18

Add this to your Cargo.toml:

toml [dependencies] svgtypes = "0.1"

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.