Skip to content

Simple, chainable SVG-building tool for NodeJS and the browser (with Browserify)

Notifications You must be signed in to change notification settings

JoeChapman/svg-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

svg-builder

Simple, chainable SVG-building tool for NodeJS and the browser (with Browserify)

Build Status NPM version Greenkeeper badge

Install

npm install svg-builder

SVG Elements

  • a
  • circle
  • foreignObject
  • g
  • line
  • path
  • rect
  • style
  • text

Usage

    var svg = require('svg-builder')
        .width(125)
        .height(125);

    var logo = svg
        .circle({
            r: 40,
            fill: 'none',
            'stroke-width': 1,
            stroke: '#CB3728',
            cx: 42,
            cy: 82
        }).circle({
            r: 40,
            fill: 'none',
            'stroke-width': 1,
            stroke: '#3B92BC',
            cx: 84,
            cy: 82
        }).text({
            x: 10,
            y: 20,
            'font-family': 'helvetica',
            'font-size': 15,
            stroke : '#fff',
            fill: '#fff'
        }, 'My logo').render();
    
    svg.reset(); //removes all elements from the internal DOM.
    
    svg.line({
        x1:0,
        y1:0,
        x2:125,
        y2:125,
        stroke:'#FF0000',
        'stroke-width': 10
    }).line({
        x1:0,
        y1:125,
        x2:125,
        y2:0,
        stroke:'#FF0000',
        'stroke-width': 10
    }).render();
    

or

    
    var otherBuilder = svg.newInstance(); // returns a new builder instance
    otherBuilder.width(640).height(480);
    otherBuilder.line({
        x1:0,
        y1:0,
        x2:640,
        y2:480,
        stroke:'#FF0000',
        'stroke-width': 40
    }).line({
        x1:0,
        y1:480,
        x2:640,
        y2:0,
        stroke:'#FF0000',
        'stroke-width': 40
    }).render();

Test

$ npm test

About

Simple, chainable SVG-building tool for NodeJS and the browser (with Browserify)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published