Expand description
Takumi renders a UI component tree to an image.
This crate is the facade. The entry-point functions live at the crate root;
the curated, stable types live in prelude. Glob the prelude, build a node
tree, and call render.
§Example
use takumi::prelude::*;
use takumi::render;
let node = Node::container([Node::text("Hello, world!").with_style(
Style::default().with(StyleDeclaration::font_size(Length::Px(32.0).into())),
)]);
// Reuse one font context across renders to share the decode cache.
let mut fonts = Fonts::default();
fonts.register(FontResource::new(include_bytes!(
"../../assets/fonts/geist/Geist[wght].woff2"
)))?;
let options = RenderOptions::builder()
.viewport(Viewport::new((1200, 630)))
.node(node)
.fonts(&fonts)
.build();
let image = render(options)?;§Feature flags
raster-backend(default): raster rendering backend.svg-source(default): SVG image sources in the core and raster backend.svg-backend: vector SVG output backend (render_svg).woff2: WOFF2 font support.woff: WOFF font support.rayon: parallelism in the raster backend; needsraster-backend.unstable: re-export the backend crates with no semver guarantee.
Modules§
- prelude
- The curated, stable data structures for building a node tree and configuring a render.
- unstable
- Unstable, semver-exempt access to the backend crates in full.
Functions§
- from_
html - Parse HTML markup into a node tree.
- measure
- Measures the layout of a node.
- render
- Renders a node to an image.
- render_
animation - Renders all frames for a sequential animation timeline at a fixed frame rate.
- render_
svg - Renders a node tree to a vector SVG string.
- write_
animated_ gif - Encode a sequence of RGBA frames into an animated GIF and write to
destination. - write_
animated_ png - Encode a sequence of RGBA frames into an animated PNG and write to
destination. - write_
animated_ webp - Encodes a sequence of RGBA frames into an animated WebP.
- write_
animation - Renders a timeline at
fpsand streams each frame straight intoformat, holding one raw frame at a time instead of the whole animation. - write_
image - Writes a single rendered image to
destinationusingformat.