Skip to content
/ canvg Public
forked from canvg/canvg

Fork of the JavaScript SVG parser and renderer on Canvas

License

Notifications You must be signed in to change notification settings

yWorks/canvg

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

canvg

Fork of the 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.

This is a fork of the original canvg project modified for use with the VSDX Export for yFiles for HTML from yWorks.

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 😎

About

Fork of the JavaScript SVG parser and renderer on Canvas

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 53.2%
  • JavaScript 39.3%
  • HTML 5.0%
  • MDX 2.0%
  • Other 0.5%