From 0809563b6365a40e79cd1c8da055c5de5c4d9031 Mon Sep 17 00:00:00 2001 From: Elton Date: Tue, 11 Aug 2015 22:27:43 +0800 Subject: [PATCH] minor update handwriting.canvas.js, rename example.html, make it more complete --- example.html | 90 +++++++++++++++++++++++++++++++++++++++++++ handwriting.canvas.js | 8 ++-- testLibrary.html | 27 ------------- 3 files changed, 93 insertions(+), 32 deletions(-) create mode 100644 example.html delete mode 100644 testLibrary.html diff --git a/example.html b/example.html new file mode 100644 index 0000000..bf36d2b --- /dev/null +++ b/example.html @@ -0,0 +1,90 @@ + + + + + + hangwriting.js + + + + +

This is canvas 1 (Undo, Redo enabled)

+ PenSize + 3
+ + +
+
+ Language: + +
+
+ + + + +
+ result: +
+ +

This is canvas 2 (Undo, Redo disabled)

+ PenSize2 + 10
+ +
+
+ Language: + +
+
+ + + + +
+ result: +
+ + + + + diff --git a/handwriting.canvas.js b/handwriting.canvas.js index 6c0947e..4890d3d 100644 --- a/handwriting.canvas.js +++ b/handwriting.canvas.js @@ -100,7 +100,7 @@ var w = []; w.push(this.handwritingX); w.push(this.handwritingY); - // w.push([]); + w.push([]); this.trace.push(w); this.drawing = false; if (this.allowUndo) this.step.push(this.canvas.toDataURL()); @@ -155,7 +155,7 @@ if (this.allowRedo) { this.redo_step.push(this.step.pop()); this.redo_trace.push(this.trace.pop()); - this.erase(); + this.cxt.clearRect(0, 0, this.width, this.height); } } else { if (this.allowRedo) { @@ -170,8 +170,7 @@ }; handwriting.Canvas.prototype.redo = function() { - if (!this.allowRedo) return; - if (this.redo_step.length <= 0) return; + if (!this.allowRedo || this.redo_step.length <= 0) return; this.step.push(this.redo_step.pop()); this.trace.push(this.redo_trace.pop()); loadFromUrl(this.step.slice(-1)[0], this); @@ -212,7 +211,6 @@ }] }); var xhr = new XMLHttpRequest(); - console.log(data); xhr.addEventListener("readystatechange", function() { if (this.readyState === 4) { switch (this.status) { diff --git a/testLibrary.html b/testLibrary.html deleted file mode 100644 index 93e20c1..0000000 --- a/testLibrary.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - -