Crates.io | svg2polylines |
lib.rs | svg2polylines |
version | 0.8.1 |
source | src |
created_at | 2017-04-02 15:30:31.371673 |
updated_at | 2022-08-28 11:07:58.928934 |
description | Convert SVG data to a list of polylines (aka polygonal chains or polygonal paths). |
homepage | |
repository | https://github.com/dbrgn/svg2polylines |
max_upload_size | |
id | 9392 |
size | 136,075 |
Convert SVG data to a list of polylines (aka polygonal chains or polygonal paths).
This can be used e.g. for simple drawing robot that just support drawing straight lines and liftoff / drop pen commands.
Flattening of Bézier curves is done using the Lyon library. SVG files are preprocessed / simplified using usvg.
Note: Currently the path style is completely ignored. Only the path itself is returned.
There is a small preview tool to view the generated polylines. It's simple and hacky, but helps to debug stuff.
cargo run --release --example preview path/to/file.svg
The --release
parameter is important, otherwise it's going to be very slow.
Use the mouse to drag / zoom the image and the Esc
key to close the window.
Signature:
fn svg2polylines::parse(svg: &str, tol: f64, preprocess: bool) -> Result<Vec<Polyline>, String>;
See examples/basic.rs
for a full usage example.
This crate used to contain FFI bindings. These have been dropped as of version 0.8.0. If you need them, open an issue on GitHub and I might bring them back.
Licensed under either of
Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.
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.