10

Is there a javascript library which lets me draw on a web page and then save the state of that drawing?

I want to draw an 2D image using the mouse and then how to store and load that drawing

ed1t
  • 8,339
  • 16
  • 66
  • 106

3 Answers3

9

Use HTML5 Canvas. A simple example for drawing images is here: http://jsfiddle.net/ghostoy/wTmFE/1/.

I recommend this online book: Dive Into HTML5.

µBio
  • 10,512
  • 6
  • 37
  • 55
Ghostoy
  • 2,609
  • 17
  • 17
4

If you want the free drawing to work with touchscreens, I recommend Fabric.js:

Code:

<canvas id="c1" width="100" height="100" style="border:1px solid black;">
</canvas>

var canvas = new fabric.Canvas('c1');
canvas.isDrawingMode = true;
canvas.freeDrawingBrush.width = 5;
console.log(canvas);

See JSfiddle

Martin Thoma
  • 108,021
  • 142
  • 552
  • 849
4

You should look at ProcessingJS.

Matthew
  • 14,826
  • 2
  • 35
  • 28
pradeek
  • 20,585
  • 2
  • 30
  • 32
  • does that let me draw dynamically using my mouse? or I need to have pre-defined shapes and it just loads it? – ed1t Jul 21 '11 at 03:30