Skip to content

Repository files navigation

CodeFactor Socket Badge License Wikipedia Discord OpenCollective
WebCanvas Lottie Player

ThorVG for Web

ThorVG.Web is a WebAssembly (WASM)-based extension of the ThorVG vector graphics engine, bringing ThorVG’s rendering capabilities to modern web environments. It provides a lightweight and flexible foundation for rendering vector graphics and Lottie animations directly in the browser, with hardware acceleration through WebGL and WebGPU.

At the core of ThorVG.Web is WebCanvas, a JavaScript/TypeScript API that provides programmatic access to ThorVG’s drawing primitives, scene graph, animation, effects, and vector rendering pipeline. Developers can create, manipulate, and render dynamic graphics while sharing ThorVG’s core rendering architecture, assets, and graphics workflows across native and web platforms.

The following diagram illustrates the architecture of ThorVG.Web, from the web application layer to the underlying rendering backends and web platform.

The WebCanvas API is built on top of lower-level WebAssembly bindings generated using Emscripten, bridging the JavaScript environment with the native ThorVG engine. The engine handles scene composition and rendering through multiple backends, including the CPU software renderer, WebGL, and WebGPU.

On the web platform, the rendered output is presented through an HTML <canvas> element, providing consistent rendering behavior while leveraging the appropriate rendering backend for the target environment.

Contents

📦 Packages

This monorepo contains two complementary packages:

npm

Lottie animation player - Web Components for embedding Lottie animations

<lottie-player
  autoPlay
  loop
  src="animation.json"
  style="width: 500px; height: 500px;"
></lottie-player>

npm

ThorVG Canvas for Web – A TypeScript API with a fluent interface for vector graphics rendering

import ThorVG from '@thorvg/webcanvas';

const TVG = await ThorVG.init({ renderer: 'gl' });
const canvas = new TVG.Canvas('#canvas', { width: 800, height: 600 });

const shape = new TVG.Shape();
shape.appendRect(100, 100, 200, 150, { rx: 10, ry: 10 });
shape.fill(255, 0, 0, 255);

canvas.add(shape);
canvas.render();

Back to contents

Examples

Lottie Player

WebCanvas

Framework Integration

Back to contents

Development

Prerequisites

  • Node.js 20+
  • pnpm 10+
  • Emscripten SDK (for WASM builds)
  • Meson & Ninja (for native builds)

Building from Source

# Install dependencies
pnpm install

# Build all packages
pnpm run build

# Clean build artifacts
pnpm run clean

Building WASM Bindings

Each package has its own WASM build script:

# Build lottie-player WASM
cd packages/lottie-player
sh ./wasm_player_setup.sh

# Build webcanvas WASM
cd packages/webcanvas
sh ./wasm_wcanvas_setup.sh

Back to contents

About

ThorVG web integration for Lottie players and WebCanvas using WebGL and WebGPU

Topics

Resources

Code of conduct

Stars

51 stars

Watchers

5 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages