vsvg ( virtual SVG )
vsvg is a small lib that allow you to create svg's server side or client side. Its still in early devlopment so expect bug and file issues.
Install
$ npm install vsvg
You can also use it with your Browserify bundles.
Usage
vsvg exports an singleton with methods that corresponds to svg tags.
var vsvg = require( 'vsvg' ),
svg = vsvg.svg({
width: '130',
height: '120',
class: 'bar'
}),
style = vsvg.style(),
line = vsvg.line({
x1: 0,
y1: 0,
x2: 100,
y2: 100,
class: 'my-class',
style: {
stroke: 'black'
}
});
style.innerText = '.my-class{ stoke-width: 5px; }';
style.setAttribute( 'type', 'text/css' );
conosle.log( style.getAttibute( 'type' ) );
svg.appendChild( line );
svg.insertBefore( style, line );
console.log( svg.outerHTML );
console.log( svg.innerHTML );
svg.toHTML();