Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeremyletang/svg
Simple library to create svg with Rust
https://github.com/jeremyletang/svg
Last synced: 25 days ago
JSON representation
Simple library to create svg with Rust
- Host: GitHub
- URL: https://github.com/jeremyletang/svg
- Owner: jeremyletang
- License: mit
- Created: 2014-02-16T19:43:57.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-17T20:04:38.000Z (about 9 years ago)
- Last Synced: 2023-07-31T14:58:49.183Z (over 1 year ago)
- Language: Rust
- Homepage:
- Size: 341 KB
- Stars: 32
- Watchers: 3
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
svg
===__libsvg__ allow you to create svg graphics using Rust.
###A simple example from the SVG spec
```Rust
extern crate svg;use std::old_io::{BufferedWriter, File, Truncate, ReadWrite};
use svg::SVG;fn main() {
// Create the SVG object
let mut image = SVG::new(12, 4);
image.view_box(0, 0, 1200, 400);
// Add a little description
image.desc("Example circle01 - circle filled with red and stroked with blue");
// ... a rectangle
image.rect(1, 1, 1198, 398, "fill=none stroke=blue stroke-width=2");
// ... and circle
image.circle(600, 200, 100, "fill=red stroke=blue stroke-width=10");// Create an ouput and export the svg image inside
let mut output = BufferedWriter::new(File::open_mode(&Path::new("output.svg"),
Truncate,
ReadWrite)).unwrap();
image.finalize(&mut output);
}```
This is the simple way to use __libsvg__. Inside the SVG object a Shape struct is
create to represent each object. You can too create a Shape, modify it, and add it
to the image using the method `SVG::add()`.