caner 1 year ago
parent
commit
7cf95a2421
2 changed files with 13 additions and 9 deletions
  1. 11 8
      index/drawCanvas.js
  2. 2 1
      project.private.config.json

+ 11 - 8
index/drawCanvas.js

@@ -56,6 +56,7 @@ class DrawCanvas {
       // 清空画布
       this._ctx.clearRect(0, 0, this._ctx.canvas.width, this._ctx.canvas.height)
       this._pathArr.pop()
+      // 重画
       for (let k = 0; k < this._pathArr.length; k++) {
         const el = this._pathArr[k];
         for (let j = 0; j < el.path.length; j++) {
@@ -76,15 +77,17 @@ class DrawCanvas {
     const img = this._canvas.createImage()
     img.src = url
     img.onload = () => {
-      const fillStyle = this._ctx.createPattern(img, 'repeat')
-      console.log('画笔样式',fillStyle);
-      // 旋转 + 矩阵变化
-      if (angle && this._matrix) {
-        this._matrix.rotateSelf(angle)
-        fillStyle.setTransform(this._matrix)
-      }
+      setTimeout(() => {
+        const fillStyle = this._ctx.createPattern(img, 'repeat')
+        console.log('画笔样式', fillStyle);
+        // 旋转 + 矩阵变化
+        if (angle && this._matrix) {
+          this._matrix.rotateSelf(angle)
+          fillStyle.setTransform(this._matrix)
+        }
+        this._style = { fillStyle, w, h }
+      }, 500);
 
-      this._style = { fillStyle, w, h }
     }
   }
 

+ 2 - 1
project.private.config.json

@@ -3,5 +3,6 @@
   "projectname": "canvas-demo",
   "setting": {
     "compileHotReLoad": true
-  }
+  },
+  "libVersion": "3.4.9"
 }