12 releases (6 breaking)
| 0.6.0 | Feb 22, 2026 |
|---|---|
| 0.5.0 | Feb 20, 2026 |
| 0.4.2 | Feb 10, 2026 |
| 0.3.0 | Jan 29, 2026 |
| 0.0.0 | Jul 4, 2025 |
#257 in Images
535KB
14K
SLoC
Decal
A declarative graphics rendering library that lets you describe scenes using a Rust-native DSL and render them to SVG or PNG.
Usage
At a high level, the flow looks like this:
- Build a scene using the
decal!macro and primitives likeRow,Column,Text,Image, etc. - Initialize an
Enginewith fonts and options. - Render the scene to SVG (
vectorize) or rasterize it to a bitmap (rasterize).
use decal::prelude::*;
use std::fs;
fn main() {
let mut engine = Engine::new(EngineOptions::default());
let mut scene = decal! {
Block {}
.size(256)
.background(rgb(0xffffff))
};
let (svg, _size) = engine
.vectorize(&mut scene, &VectorizeOptions::default())
.unwrap();
fs::write("./markup.svg", svg).unwrap();
let (pixmap, _size) = engine
.rasterize(&mut scene, &RasterizeOptions::default())
.unwrap();
pixmap.save_png("./render.png").unwrap();
}
Explore examples.
License
MIT or Apache-2.0
Dependencies
~32–46MB
~766K SLoC