Collaborative, extendable, JavaScript Canvas2D drawing tool, supporting dozens of builtin tools, as well as generates JavaScript code for 2D animations.
designer.setSelected or designer.setTools for below tools.
line --- to draw straight lines
pencil --- to write/draw shapes
dragSingle --- to drag/ove and especially resize last selected shape
dragMultiple --- to drag/move all shapes
eraser --- to erase/clear specific portion of shapes
rectangle --- to draw rectangles
arc --- to draw circles
bezier --- to draw bezier curves
quadratic --- to draw quadratic curves
text --- to write texts on single or multiple lines, select font families/sizes and more
image --- add external images
arrow --- draw arrow lines
marker --- draw markers
lineWidth --- set line width
colorsPicker --- background and foreground colors picker
extraOptions --- extra options eg. lineCap, lineJoin, globalAlpha, globalCompositeOperation etc.
pdf --- to import PDF
code --- to enable/disable code view
undo --- undo recent shapes
dragSingle should be: drag-move-resize last-selected-shape.
dragMultiple should be: drag-move all-shapes.
ctrl+z keys (undo all shapes, undo last 10 or specific shapes, undo range of shapes or undo last shape)
box or anywhere, and simply copy that text.
T tool icon from the tool-box and press ctrl+v to paste your own language's text.
ctrl+v
T icon, and then press ctrl+v to paste your copied text
canvas-designer-widget.js from this github repository.
designer.widgetHtmlURL and designer.widgetJsURL in your HTML file.
var designer = new CanvasDesigner();
designer.appendTo(document.body);
html
`
Complete Usage
`javascript
var designer = new CanvasDesigner();
websocket.onmessage = function(event) {
designer.syncData( JSON.parse(event.data) );
};
designer.addSyncListener(function(data) {
websocket.send(JSON.stringify(data));
});
designer.setSelected('pencil');
designer.setTools({
pencil: true,
text: true
});
designer.appendTo(document.documentElement);
`
It is having designer.destroy() method as well.
Use WebRTC!
`javascript
webrtc.onmessage = function(event) {
designer.syncData( event.data );
};
designer.addSyncListener(function(data) {
webrtc.send(data);
});
`
Use Socket.io
`javascript
socket.on('message', function(data) {
designer.syncData( data );
});
designer.addSyncListener(function(data) {
socket.emit('message', data);
});
`
API Reference
widgetHtmlURL
You can place widget.html file anywhere on your site.
`javascript
designer.widgetHtmlURL = '/html-files/widget.html';
`
By default widget.html is placed in the same directory of index.html.
`javascript
// here is default value
designer.widgetHtmlURL = 'widget.html';
`
Remember, widget.html is loaded using