Skip to content

A WASM-based ThorVG engine for Lottie players and WebCanvas. It enables high-performance graphics through integration with WebGL and WebGPU.

License

Notifications You must be signed in to change notification settings

thorvg/thorvg.web

Repository files navigation

Discord ThorVGPT OpenCollective License npm

ThorVG for Web

ThorVG.Web is a WebAssembly (WASM)-based extension of the ThorVG vector graphics engine, designed to run seamlessly in modern web environments. It enables efficient and high-performance rendering of vector graphics and Lottie animations directly in the browser, leveraging both WebGL and WebGPU for hardware-accelerated rendering. Fully compatible with ThorVG’s core rendering logic, ThorVG.Web ensures consistent output across desktop, mobile, and web platforms, allowing developers to reuse the same vector assets and rendering code across multiple targets with minimal changes.

Whether you're building a high-performance Lottie animation, a graphics editing tool, or a scalable UI framework for the browser, ThorVG.Web provides the speed and flexibility needed to deliver modern vector graphics experiences on the web.


What is ThorVG?

ThorVG is a lightweight, cross-platform vector graphics engine that powers this web implementation. ThorVG Web brings its performance and flexibility to JavaScript/TypeScript through WebAssembly bindings, supporting Software, WebGL, and WebGPU rendering backends.

📦 Packages

This monorepo contains two complementary packages:

npm

Declarative Lottie animation player - Web component for embedding Lottie animations

<script src="https://unpkg.com/@thorvg/lottie-player@latest/dist/lottie-player.js"></script>

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

→ Read lottie-player documentation


npm

Imperative TypeScript Canvas API - Fluent Interface for vector graphics

import ThorVG from '@thorvg/webcanvas';

const TVG = await ThorVG.init({ renderer: 'sw' });
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();

→ Read webcanvas documentation

Rendering Backends

All packages support multiple rendering backends:

Backend Description
Software (sw) CPU-based rendering
WebGL (gl) GPU-accelerated
WebGPU (wg) WebGPU API

Examples

Basic Examples

Lottie Player Examples:

WebCanvas Examples:

Framework Integration

See framework-specific examples:

Monorepo Structure

→ Read monorepo documentation

Development

Prerequisites

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

Building from Source

# Install dependencies
pnpm install

# Build all packages
pnpm run build

# Run linter
pnpm run lint

# 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_setup.sh

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

Testing Framework Integration

Test compatibility across different frameworks:

pnpm run test:build

Documentation

About

A WASM-based ThorVG engine for Lottie players and WebCanvas. It enables high-performance graphics through integration with WebGL and WebGPU.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Contributors 12