Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

tinyjin/thorvg.web

Β 
Β 

Repository files navigation

Discord ThorVGPT OpenCollective License npm

ThorVG for Web

High-performance vector graphics rendering for the modern web

ThorVG Web provides WebAssembly-powered vector graphics rendering with multiple APIs designed for different use cases. From declarative Lottie animations to imperative canvas drawing, ThorVG delivers native-like performance directly in your browser.

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/canvas-kit';

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 canvas-kit 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:

Canvas Kit 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 canvas-kit WASM
cd packages/canvas-kit
sh ./wasm_setup.sh

Testing Framework Integration

Test compatibility across different frameworks:

pnpm run test:build

Documentation

About

ThorVG for Web Platform

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 55.5%
  • C++ 24.7%
  • JavaScript 8.9%
  • Shell 5.0%
  • HTML 4.8%
  • Meson 0.6%
  • CSS 0.5%