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
context.font_context.load_and_store;
// Create a viewport
let viewport = new;
// Render the layout to an `RgbaImage`
let image = render.unwrap;
Credits
- taffy for the layout system.
- image for the image processing.
- cosmic-text for the text rendering.
- woff2-patched for the font processing.
- ts-rs for the type-safe serialization.
- resvg for SVG parsing and rendering.