drawing svg on a canvas in node.js.
- drawing svg data on canvas
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
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)
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
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) { … });
Fetching a svg file from wikipedia and return it as png:
- More documentation
- tests