Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dodo/node-canvas-svg
drawing svg on a Canvas in Node.js
https://github.com/dodo/node-canvas-svg
Last synced: 10 days ago
JSON representation
drawing svg on a Canvas in Node.js
- Host: GitHub
- URL: https://github.com/dodo/node-canvas-svg
- Owner: dodo
- License: agpl-3.0
- Created: 2010-12-02T01:09:17.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2010-12-03T17:01:53.000Z (almost 14 years ago)
- Last Synced: 2024-04-14T09:09:15.339Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 127 KB
- Stars: 35
- Watchers: 5
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-canvas-svg
drawing svg on a [canvas](https://github.com/LearnBoost/node-canvas) in [node.js](http://nodejs.org/).
## Features
* drawing svg data on canvas
## Installation with git
git clone https://github.com/dodo/node-canvas-svg.git
cd node-canvas-svg
git submodules update --init
cd deps/node-canvas
make
cd ../node-overload
make## Motivation
NIH - not invented here ...
srsly .. i want to generate some good looking charts without using javascript on client side (because this is lame for none-interactive images)## Dependencies
* [canvg](http://code.google.com/p/canvg/)
* [jsdom](https://github.com/tmpvar/jsdom)
* [node-canvas](https://github.com/LearnBoost/node-canvas)
* [node-htmlparser](https://github.com/tautologistics/node-htmlparser)
* [node-overload](https://github.com/bmeck/node-overload)
* [vargs](https://github.com/cloudhead/vargs)## Usage
var canvassvg = require('node-canvas-svg');
First you need to load the canvg modules:
canvassvg.load(function (err, canvg_module) { … });
you can use as well the shorter from:
canvassvg.load(function (err) { … }); // the module is saved in canvassvg.svg.canvg
# Drawing SVG
canvassvg.svg.render(svg, function (err, canvas) { … });
or
canvassvg.svg.render(canvas, svg, function (err, canvas) { … });
width and height can be applied as well:
canvassvg.svg.render(svg, width, height function (err, canvas) { … });
or
canvassvg.svg.render(canvas, svg, width, height function (err, canvas) { … });
## Example
Fetching a svg file from wikipedia and return it as png:
* https://github.com/dodo/node-canvas-svg/example/wikipedia.js
## TODO
* More documentation
* tests