Browse Source

测试旋转

caner 1 year ago
parent
commit
a59cf52e1d
1 changed files with 6 additions and 5 deletions
  1. 6 5
      index/drawCanvas.js

+ 6 - 5
index/drawCanvas.js

@@ -72,10 +72,12 @@ class DrawCanvas {
     if (!url) return
     const img = this._canvas.createImage()
     img.onload = () => {
-      this._style = {
-        fillStyle: this._ctx.createPattern(img, 'repeat'),
-        w, h
-      }
+      const fillStyle = this._ctx.createPattern(img, 'repeat')
+      // 矩阵变化
+      // const svg1 = document.getElementById("svg1");
+      // const matrix = svg1.createSVGMatrix();
+      // fillStyle.setTransform(matrix.rotate(-45))
+      this._style = { fillStyle, w, h }
     }
     img.src = url
   }
@@ -104,7 +106,6 @@ class DrawCanvas {
   clear() {
     // 清空画布
     this._ctx.clearRect(0, 0, this._ctx.canvas.width, this._ctx.canvas.height)
-    // this._ctx.globalCompositeOperation = "source-over" //覆盖
     // 清除路径数据
     this._pathArr = []
     this._executionArr = []