https://github.com/theseanl/svg-to-canvas
https://github.com/theseanl/svg-to-canvas
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/theseanl/svg-to-canvas
- Owner: theseanl
- Created: 2019-05-18T01:23:19.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T23:51:40.000Z (over 2 years ago)
- Last Synced: 2025-02-08T16:17:38.084Z (4 months ago)
- Language: JavaScript
- Size: 127 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# svg-to-canvas-2d
A command line tool for converting static SVGs into Javascript canvas API calls.
Based on [svg2canvas by samsha](https://github.com/samsha/svg2canvas), which is again based on [canvg](https://github.com/canvg/canvg). It uses puppeteer and applies does code formatting to automate and batch process conversion. Note that sometimes a bug of canvg leads to canvas API calls with defects, so users should manually verify that the resulting JS draws what is expected.
## Installation
```
yarn install
```## Usage
```
svg-to-canvas [glob_of_svg_files[,glob2[, ...]]] [output_file_name]
```
```
// output.js - one line per file, ./path/to/svg_file.svg is converted to:
var svg_file = function (ctx) { ctx.save(); /* ... */ ctx.restore(); };
```