Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ decal Public

Declarative DSL for describing scenes and rendering them to SVG or PNG

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

mem-red/decal

Repository files navigation

Decal

Latest Version Rust Documentation

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:

  1. Build a scene using the decal! macro and primitives like Row, Column, Text, Image, etc.
  2. Initialize an Engine with fonts and options.
  3. 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

About

Declarative DSL for describing scenes and rendering them to SVG or PNG

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Contributors

Languages