|
|
@@ -1,4 +1,5 @@
|
|
|
class DrawCanvas {
|
|
|
+
|
|
|
constructor() {
|
|
|
this._ctx = null
|
|
|
this._canvas = null
|
|
|
@@ -27,7 +28,6 @@ class DrawCanvas {
|
|
|
this._ctx = ctx
|
|
|
this._executionArr = [] //每移动一笔的数据
|
|
|
this._pathArr = [] //抬起落下为一笔
|
|
|
-
|
|
|
}
|
|
|
|
|
|
mouseStart() {
|
|
|
@@ -55,7 +55,7 @@ class DrawCanvas {
|
|
|
const item = this._pathArr.length <= 1 ? this._pathArr[0] : this._pathArr[this._pathArr.length - 1]
|
|
|
for (let k = 0; k < item.path.length; k++) {
|
|
|
const el = item.path[k];
|
|
|
- this._ctx.clearRect(el[0] - 5, el[1] - 5, 11, 11)
|
|
|
+ this._ctx.clearRect(el[0] - 5, el[1] - 5, 10, 10)
|
|
|
}
|
|
|
this._pathArr.pop()
|
|
|
}
|
|
|
@@ -73,7 +73,14 @@ class DrawCanvas {
|
|
|
|
|
|
// 清除画布
|
|
|
destory() {
|
|
|
- this._ctx.clearRect(0, 0, this._ctx.canvas.width, this._ctx.canvas.height)
|
|
|
+ // this._ctx.clearRect(0, 0, this._ctx.canvas.width, this._ctx.canvas.height)
|
|
|
+ for (let k = 0; k < this._pathArr.length; k++) {
|
|
|
+ const el = this._pathArr[k];
|
|
|
+ for (let j = 0; j < el.path.length; j++) {
|
|
|
+ const es = el.path[j];
|
|
|
+ this._ctx.clearRect(es[0] - 5, es[1] - 5, 10, 10)
|
|
|
+ }
|
|
|
+ }
|
|
|
this._pathArr = []
|
|
|
this._executionArr = []
|
|
|
this._style = null
|
|
|
@@ -88,7 +95,6 @@ class DrawCanvas {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
export { DrawCanvas }
|