thorvg-rs
⚠️ Work in progress — This crate is under active development and not yet ready for production use. APIs may change without notice.
Rust bindings for ThorVG, a production-ready vector graphics engine supporting SVG, Lottie animations, shapes, text, gradients, effects, and more.
Crates
| Crate | Description |
|---|---|
thorvg-sys |
Raw FFI bindings generated by bindgen |
thorvg |
Safe, idiomatic Rust wrapper |
Quick Start
use ;
let _engine = init.unwrap;
let mut canvas = new.unwrap;
let mut buffer = vec!;
canvas.set_target.unwrap;
let mut shape = new;
shape.append_rect.unwrap;
shape.set_fill_color.unwrap;
canvas.push.unwrap;
canvas.draw.unwrap;
canvas.sync.unwrap;
// buffer now contains rendered pixels
Features
std(default) — Adds file I/O APIs that acceptstd::path::Pathvendored(default,thorvg-sys) — Builds ThorVG from source via the vendored git submodule
Disable default features for no_std + alloc environments:
[]
= { = "0.1", = false }
API Coverage
100% of the ThorVG C API surface (158 functions) is wrapped:
- Canvas —
SwCanvas,GlCanvas,WgCanvas - Paint — opacity, visibility, transforms, clipping, masking, blending, hit-testing
- Shape — paths, rectangles, circles, fill, stroke, gradients, trim path
- Gradient — linear, radial, color stops, spread, transforms
- Picture — load SVG/PNG/JPG/WebP/Lottie from file or memory
- Scene — grouping, effects (blur, drop shadow, fill, tint, tritone)
- Text — font loading, styling, wrapping, metrics, outline
- Animation — frame control, segments, duration
- LottieAnimation — slots, markers, tweening, expressions, quality
- Saver — export paint/animation to file
- Accessor — scene tree traversal with callbacks
no_std Support
Both crates are no_std compatible. The safe wrapper requires alloc. File I/O APIs (Picture::load, Text::load_font, Saver::save) are gated behind the std feature. All rendering, shapes, gradients, scenes, and canvas operations work in no_std.
Examples
All examples output PNG files in the current directory.
Building
ThorVG is vendored as a git submodule and built automatically. You need meson and ninja installed:
# Debian/Ubuntu
# Fedora
# macOS
# pip
Then:
Development
Requires just for task running:
Acknowledgments
This project provides Rust bindings to ThorVG, created and maintained by the ThorVG project contributors. ThorVG is a Linux Foundation project. All vector graphics rendering is performed by the ThorVG engine — this crate is a thin binding layer.
This project is not affiliated with, endorsed by, or sponsored by the ThorVG project or the Linux Foundation.
Special thanks to Hermet Park and all ThorVG contributors for building such an excellent, lightweight, and well-designed vector graphics engine with a clean C API that made these bindings possible.
License
MIT — same as ThorVG.