Skip to main content

Overview

The package runs the @thorvg/webcanvas API in Node.js. The classes and methods are the same as in the browser.

thorvg-canvas architecture

Layers​

LayerRole
RuntimeNode.js. Your script calls init(), the classes and the output methods
InterfaceThe WebCanvas API. Shape, Scene, Picture, Text, LottieAnimation and the other classes, with the same methods as in the browser
BindingsA native addon that calls the ThorVG C API through Node-API
EngineThorVG, which builds the scene and renders it
Render backendThe CPU renderer ('sw')
SurfaceA pixel buffer in memory, read with getImageData() or saved with toFile()

Native​

ThorVG is compiled into the addon and called directly, without WebAssembly. Paints are ThorVG objects held by JavaScript and released when they are garbage collected or disposed.

render() runs on the calling thread. renderAsync() runs on the libuv thread pool and keeps the event loop free.