Takumi
Takumi is a library with different parts to render your React components to images. This crate contains the core logic for layout, rendering.
Checkout the Getting Started page if you are looking for Node.js / WASM bindings.
Walkthrough
Create a GlobalContext to store image resources, font caches, the instance should be reused to speed up the rendering.
Then call render with Node and Viewport to get RgbaImage.
Theres a helper function write_image to write the image to a destination implements Write and Seek.
Example
use ;
// Create a node tree with `ContainerNode` and `TextNode`
let mut node = Container;
// Create a context for storing resources, font caches.
// You should reuse the context to speed up the rendering.
let context = default;
// Load fonts
// pass an optional [`FontInfoOverride`](parley::FontInfoOverride) to override the font's metadata,
// and an optional [`GenericFamily`](parley::GenericFamily) to specify the generic family of the font.
context.font_context.load_and_store;
// Create a viewport
let viewport = new;
// Create render options
let options = default
.viewport
.node
.global
.build
.unwrap;
// Render the layout to an `RgbaImage`
let image = render.unwrap;
Feature Flags
woff2: Enable WOFF2 font support.woff: Enable WOFF font support.svg: Enable SVG support.rayon: Enable rayon support.avif: Enable AVIF support.