Crates.io | vsvg-viewer |
lib.rs | vsvg-viewer |
version | 0.5.0 |
source | src |
created_at | 2023-09-29 19:45:37.95261 |
updated_at | 2024-09-21 09:51:18.114106 |
description | Portable, hardware-accelerated, extensible viewer for the vsvg crate. |
homepage | https://github.com/abey79/vsvg |
repository | https://github.com/abey79/vsvg |
max_upload_size | |
id | 987805 |
size | 214,961 |
This crate is part of the vsvg project.
Status: Beta. It works, but the API is subject to change.
This crate implements an extensible egui- and wgpu-based viewer for vsvg. It's very much similar to vpype-viewer, but built on much stronger foundations:
This combination enables targeting WebAssembly too.
vsvg-viewer offers two main features:
vsvg::Document
viewervsvg::Document
viewerThe basic vsvg::Document
viewer requires a single line of code:
fn main() -> anyhow::Result<()> {
let doc = vsvg::Document::from_svg("path/to/input.svg");
vsvg_viewer::show(&doc)
}
Here is an example screenshot:
For users familiar with vpype, this basically corresponds to what happens with vpype [...] show
.
Alternatively, vsvg-viewer can be used to build complex, interactive application around the core vsvg::Document
renderer feature:
struct MyApp {}
impl vsvg_viewer::ViewerApp for MyApp {
/* ... */
}
fn main() -> anyhow::Result<()> {
vsvg_viewer::show_with_viewer_app(MyApp::new())
}
Your app must implement the vsvg_viewer::ViewerApp
trait, which offers hooks to:
A basic example for a custom app is provided in the examples/
directory.
whiskers) uses this API to implement its sketch runner: