Skip to content

Commit a8eccfc

Browse files
committed
Added Clear Canvas function
1 parent 8b23640 commit a8eccfc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/sketch.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ var __slice = Array.prototype.slice;
2727
return this;
2828
}
2929
};
30+
$.fn.clear = function () {
31+
var sketch = this.data('sketch');
32+
if (sketch != undefined) {
33+
sketch.context.clearRect(0, 0, sketch.canvas[0].width, sketch.canvas[0].height);
34+
sketch.context = sketch.el.getContext('2d');
35+
sketch.actions = [];
36+
sketch.action = [];
37+
}
38+
};
3039
Sketch = (function() {
3140
function Sketch(el, opts) {
3241
this.el = el;

0 commit comments

Comments
 (0)