Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/canvg/canvg
JavaScript SVG parser and renderer on Canvas
https://github.com/canvg/canvg
canvas hacktoberfest javascript svg
Last synced: 2 days ago
JSON representation
JavaScript SVG parser and renderer on Canvas
- Host: GitHub
- URL: https://github.com/canvg/canvg
- Owner: canvg
- License: mit
- Created: 2014-12-07T19:18:53.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-10-09T07:51:42.000Z (4 months ago)
- Last Synced: 2024-10-29T23:50:39.116Z (3 months ago)
- Topics: canvas, hacktoberfest, javascript, svg
- Language: TypeScript
- Homepage: https://canvg.js.org
- Size: 29.2 MB
- Stars: 3,658
- Watchers: 65
- Forks: 610
- Open Issues: 125
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-canvas - canvg - Javascript SVG parser and renderer on Canvas. ![](https://img.shields.io/github/stars/canvg/canvg?style=social) ![](https://img.shields.io/github/forks/canvg/canvg?style=social) (Libraries / Data processing)
- awesome-list - canvg
README
# canvg
[![NPM version][npm]][npm-url]
[![Dependencies status][deps]][deps-url]
[![Build status][build]][build-url]
[![Coverage status][coverage]][coverage-url][npm]: https://img.shields.io/npm/v/canvg.svg
[npm-url]: https://npmjs.com/package/canvg[deps]: https://img.shields.io/librariesio/release/npm/canvg
[deps-url]: https://libraries.io/npm/canvg/tree[build]: https://img.shields.io/github/actions/workflow/status/canvg/canvg/ci.yml?branch=master
[build-url]: https://github.com/canvg/canvg/actions[coverage]: https://img.shields.io/codecov/c/github/canvg/canvg.svg
[coverage-url]: https://app.codecov.io/gh/canvg/canvgJavaScript 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:
```sh
pnpm add canvg
# or
yarn add canvg
# or
npm i canvg
```Then, just import `Canvg` and use it:
```js
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.](https://canvg.js.org/api)
## Docs
- [Migration to v4](https://canvg.js.org/docs/migration-to-v4)
- [API](https://canvg.js.org/api/classes/Canvg)
- [Examples](https://canvg.js.org/examples)## What's implemented?
The end goal is everything from the [SVG spec](http://www.w3.org/TR/SVG/). 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 😎