MCPcopy Index your code
hub / github.com/bodoni/svg

github.com/bodoni/svg @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
160 symbols 312 edges 15 files 20 documented · 12%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

SVG Package Documentation Build

The package provides an SVG composer and parser.

Example: Composing

use svg::Document;
use svg::node::element::Path;
use svg::node::element::path::Data;

let data = Data::new()
    .move_to((10, 10))
    .line_by((0, 50))
    .line_by((50, 0))
    .line_by((0, -50))
    .close();

let path = Path::new()
    .set("fill", "none")
    .set("stroke", "black")
    .set("stroke-width", 3)
    .set("d", data);

let document = Document::new()
    .set("viewBox", (0, 0, 70, 70))
    .add(path);

svg::save("image.svg", &document).unwrap();

Example: Parsing

use svg::node::element::path::{Command, Data};
use svg::node::element::tag::Path;
use svg::parser::Event;

let path = "image.svg";
let mut content = String::new();
for event in svg::open(path, &mut content).unwrap() {
    match event {
        Event::Tag(Path, _, attributes) => {
            let data = attributes.get("d").unwrap();
            let data = Data::parse(data).unwrap();
            for command in data.iter() {
                match command {
                    &Command::Move(..) => { /* … */ },
                    &Command::Line(..) => { /* … */ },
                    _ => {}
                }
            }
        }
        _ => {}
    }
}

Contribution

Your contribution is highly appreciated. Do not hesitate to open an issue or a pull request. Note that any contribution submitted for inclusion in the project will be licensed according to the terms given in LICENSE.md.

Extension points exported contracts — how you extend this code

Node (Interface)
A node. [4 implementers]
src/node/mod.rs
NodeDefaultHash (Interface)
(no doc) [5 implementers]
src/node/mod.rs
NodeClone (Interface)
(no doc) [1 implementers]
src/node/mod.rs

Core symbols most depended-on inside this repo

consume_char
called by 32
src/parser/reader.rs
read_parameters
called by 16
src/node/element/path/data.rs
consume_whitespace
called by 12
src/parser/reader.rs
capture
called by 10
src/parser/reader.rs
assign
called by 7
src/node/element/mod.rs
consume_while
called by 6
src/parser/reader.rs
add
called by 6
src/node/element/path/data.rs
consume_digits
called by 5
src/parser/reader.rs

Shape

Method 108
Function 32
Class 13
Enum 4
Interface 3

Languages

Rust100%

Modules by API surface

src/parser/reader.rs43 symbols
src/node/element/path/data.rs21 symbols
src/node/element/mod.rs17 symbols
src/node/mod.rs14 symbols
src/node/element/tag.rs13 symbols
src/parser/mod.rs12 symbols
src/node/comment.rs8 symbols
src/node/text.rs7 symbols
src/node/value.rs6 symbols
src/node/blob.rs5 symbols
src/lib.rs5 symbols
src/parser/error.rs4 symbols

For agents

$ claude mcp add svg \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact