low-level svg helper
$ component install matthewmueller/svg
var graph = document.getElementById('graph');
var svg = require('svg');
var draw = svg(graph);
var box = draw.rect()
.fill('black')
.rotate(20)
.size(100)
.move(50);
Initialize an svg document and attach it to parent
. Returns a Group
.
All native SVG element types have a corresponding method to create them. They will automatically be added to the current group. The supported element types are listed below with there argument lists. These arguments are optional though and only there to help keep large documents concise. Each method returns an Element.
- ellipse(width, height, x, y)
- rect(width, height, x, y)
- line(x1, y1, x2, y2)
- circle(size, x, y)
- text(content)
- group()
Get and set attributes
Set the width and height
Apply a set of transfomations to the element or get this.transforms[key]
element.transform({rotate: 20}) // set rotation
element.transform('rotate', 20) // set rotation
element.transform('rotate') // get rotation
Move
Rotate the element
Set the elements radius. For rect's it will set the border-radius
Scale the element
Set the fill color. color
can be any valid CSS color string
Set the stroke color
Set the stroke linecap type to one of:
- butt
- round
- square
Set the dash length
MIT