svg-sketch
svg widget
Last updated 3 years ago by jameskyburz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install svg-sketch 
SYNC missed versions from official npm registry.

svg-sketch

svg widget with built in json eventstream

svg -> json -> what ever FTW

js-standard-style

build status

Sauce Test Status

Try it out! view on requirebin

use with browserify

methods

var sketch = require('svg-sketch')

sketch([opts={}])

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.size size of anchor (default is 14px)

  • opts.anchor.exclude regex checked for a falsy value, used to determine when to remove anchor elements. (default is /undo|redo|grid/)

  • opts.anchor.include regex checked for a truthy value, used to determine when to show anchor elements. (default is /rubber|move|text/)

  • opts.anchor.position optional function to determine the xy position of a svg shape.

sketch.appendTo(el)

append svg element to element

sketch.registerControl()

register drawing control

sketch.remove()

remove svg element and event listeners

sketch.setEvents(events)

set drawing events data

sketch.setControl(control)

set which control is currently being used

sketch.resize(width, height)

set viewport to width and height

sketch.setColor(color)

set current drawing color in hex or rgb

sketch.setStyle(style)

sketch.setGridStyle(style)

override grid style used

svg.setClipboard(json)

clipboard context for widget used by paste.

svg.copy()

save eventStream json and emit copy event

svg.cut

save eventStream json, remove drawing and emit copy event

svg.paste(e)

paste copied eventStream to drawing if e contains clipboard data used that instead of local copied eventStream.

events

svg.changeControl(name)

svg.changeColor(color)

svg.changeStyle(style)

svg.eventStream(events)

complete json structure for drawing

svg.copy

emitted when drawing copied

svg.drawing

emitted when interacting with drawing

install

With npm do:

npm install svg-sketch

test

npm test

license

MIT

Current Tags

  • 1.4.32                                ...           latest (3 years ago)

53 Versions

  • 1.4.32                                ...           3 years ago
  • 1.4.31                                ...           3 years ago
  • 1.4.30                                ...           3 years ago
  • 1.4.29                                ...           3 years ago
  • 1.4.28                                ...           3 years ago
  • 1.4.27                                ...           3 years ago
  • 1.4.24                                ...           3 years ago
  • 1.4.23                                ...           3 years ago
  • 1.4.22                                ...           3 years ago
  • 1.4.21                                ...           3 years ago
  • 1.4.20                                ...           3 years ago
  • 1.4.19                                ...           3 years ago
  • 1.4.18                                ...           3 years ago
  • 1.4.17                                ...           3 years ago
  • 1.4.16                                ...           3 years ago
  • 1.4.15                                ...           3 years ago
  • 1.4.14                                ...           3 years ago
  • 1.4.13                                ...           4 years ago
  • 1.4.12                                ...           4 years ago
  • 1.4.11                                ...           4 years ago
  • 1.4.10                                ...           4 years ago
  • 1.4.9                                ...           4 years ago
  • 1.4.8                                ...           4 years ago
  • 1.4.7                                ...           4 years ago
  • 1.4.6                                ...           4 years ago
  • 1.4.5                                ...           4 years ago
  • 1.4.4                                ...           4 years ago
  • 1.4.3                                ...           4 years ago
  • 1.4.2                                ...           4 years ago
  • 1.4.1                                ...           4 years ago
  • 1.4.0                                ...           4 years ago
  • 1.1.10                                ...           4 years ago
  • 1.1.7                                ...           4 years ago
  • 1.1.6                                ...           4 years ago
  • 1.1.5                                ...           4 years ago
  • 1.1.4                                ...           4 years ago
  • 1.1.3                                ...           4 years ago
  • 1.1.2                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
  • 0.0.8                                ...           5 years ago
  • 0.0.7                                ...           5 years ago
  • 0.0.6                                ...           5 years ago
  • 0.0.5                                ...           5 years ago
  • 0.0.4                                ...           5 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
  • 0.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 56
Dependencies (7)
Dev Dependencies (8)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |