vsvg-viewer crate
This crate is part of the vsvg project.
Status: Beta. It works, but the API is subject to change.
What's this?
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:
- The egui crate is an immediate-mode UI framework, which makes it suited for easy customisation and highly interactive projects (such as whiskers).
- The wgpu crate is a wrapper over modern native and web graphics APIs. It's future-proof.
This combination enables targeting WebAssembly too.
Usage
vsvg-viewer offers two main features:
- a basic
vsvg::Documentviewer - a fully customisable application built on the
vsvg::Documentviewer
Basic viewer
The basic vsvg::Document viewer requires a single line of code:
Here is an example screenshot:
For users familiar with vpype, this basically corresponds to what happens with vpype [...] show.
Customisable app
Alternatively, vsvg-viewer can be used to build complex, interactive application around the core vsvg::Document renderer feature:
Your app must implement the vsvg_viewer::ViewerApp trait, which offers hooks to:
- display the custom UI, for example in side panels;
- customise options such as windows title, etc.;
- load/save state from persistent storage.
A basic example for a custom app is provided in the examples/ directory.
whiskers) uses this API to implement its sketch runner: