svg widget with built in json eventstream
svg -> json -> what ever FTW
use with browserify
var sketch = require('svg-sketch')Returns a new sketch instance.
opts is optional
opts.anchor is used for move, delete operations and to easily click on
text elements
If you want anchors to appear then there are the options (they help with deleting and moving elements) :-
-
opts.anchor.sizesize of anchor (default is 14px) -
opts.anchor.excluderegex checked for a falsy value, used to determine when to remove anchor elements. (default is/undo|redo|grid/) -
opts.anchor.includeregex checked for a truthy value, used to determine when to show anchor elements. (default is/rubber|move|text/) -
opts.anchor.positionoptional function to determine the xy position of a svg shape.
append svg element to element
register drawing control
remove svg element and event listeners
set drawing events data
set which control is currently being used
set viewport to width and height
set current drawing color in hex or rgb
override grid style used
clipboard context for widget used by paste.
save eventStream json and emit copy event
save eventStream json, remove drawing and emit copy event
paste copied eventStream to drawing
if e contains clipboard data used that instead of local copied eventStream.
complete json structure for drawing
emitted when drawing copied
emitted when interacting with drawing
With npm do:
npm install svg-sketch
npm test
MIT
