canvg

在画布(Canvas)上解析和渲染 SVG 的 JavaScript。「Javascript SVG parser and renderer on Canvas」

Github星跟蹤圖

canvg

NPM version
Dependencies status
Build status
Coverage status

JavaScript SVG parser and renderer on Canvas. It takes the URL to the SVG file or the text of the SVG file, parses it in JavaScript and renders the result on Canvas. It also can be used to rasterize SVG images.

Quickstart
  •  
Docs
  •  
Demo

Quickstart

Install this library using your favorite package manager:

pnpm add canvg
# or
yarn add canvg
# or
npm i canvg

Then, just import Canvg and use it:

import { Canvg } from 'canvg';

let v = null;

window.onload = async () => {
  const canvas = document.querySelector('canvas');
  const ctx = canvas.getContext('2d');

  v = await Canvg.from(ctx, './svgs/1.svg');

  // Start SVG rendering with animations and mouse handling.
  v.start();
};

window.onbeforeunload = () => {
  v.stop();
};

Description of all exports you can find in Documentation.

Docs

What's implemented?

The end goal is everything from the SVG spec. The majority of the rendering and animation is working. If you would like to see a feature implemented, don't hesitate to add it to the issues list, or better is to create pull request 😎

主要指標

概覽
名稱與所有者canvg/canvg
主編程語言TypeScript
編程語言JavaScript (語言數: 6)
平台
許可證MIT License
所有者活动
創建於2014-12-07 19:18:53
推送於2025-10-18 19:23:03
最后一次提交2025-10-18 23:21:04
發布數22
最新版本名稱v3.0.11 (發布於 )
第一版名稱v1.4 (發布於 )
用户参与
星數3.8k
關注者數64
派生數619
提交數1.1k
已啟用問題?
問題數723
打開的問題數112
拉請求數551
打開的拉請求數14
關閉的拉請求數479
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?