Responsive JS Wrapper to allow drawing in a canvas with the mouse or touching the screen. It can be used either on a desktop, a tablet or a smartphone and render img to the wanted size even on small screen
- import canvasDrawing.js in the file you need it
- create a new instance of the plugin calling
new CanvasDrawing.CanvasDrawing(elt,width,height,params); - store the result to be able to call plugin's methods
elt: canvas locationwidth: canvas widthheight: canvas heightparams (optionnal): object in which you can specify canvas parameters. Only one param is actually support: background_color which set canvas' background color, default value is white (#ffffff)
If you want to be able to export the image drawn, you have to import that library provided by gillyb : gillyb/reimg
setColor(rgb): set color used to drawgetColor(): return the currently color used to drawsetSize(px): set the size used to drawgetSize(): return the currently color used to drawgetImg(): return the image drawn (need 'reimg', see Dependance)getContext(): return the canvas contextsetImgSrc(url): set the background image usedsetImgFromVideo(videoElement): set the background img from a video elementsetImgFromDataUrl(dataUrl): set the background img from a dataUrlclear(): clear the canvastriggerResize(): usefull when the plugin was created with a display to none
Examples are availables in the examples directory
Feel free to ask for request or to do pull request if you think you've improved the plugin
This piece of software is issued under the GNU GENERAL PUBLIC LICENSE. You can view the license here