Functions & Hooks

renderToImage

function renderToImage(scene: ReactNode | SceneSource, options: RenderToImageOptions): Promise<TgfxImage>;

Draw a scene to an image without mounting a <Canvas>.

Takes JSX (compiled by the same reconciler a canvas uses, so function components, .map() and context all work), a SceneNode[] from the element factories, or a Scene - the non-JSX forms skip the reconciler entirely. The program is rendered on an offscreen GPU surface and registered as an image handle, ready for <TgfxImage>, <ImageShader>, or save().

Animated props are read once, at their committed value: there is no view to drive them and the result is a still frame. A Scene's live handle writes are baked in at their current values.

Parameters

scene

ReactNode | SceneSource

options

RenderToImageOptions

Returns

Promise<TgfxImage>

On this page