Browse Source

移除dpr放大,增加旋转效果

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

+ 6 - 32
index/drawCanvas.js

@@ -11,10 +11,8 @@ class DrawCanvas {
   _init({ width, height, canvas, dicTypePath = '' }) {
     if (!width || !height || !canvas) return
     const ctx = canvas.getContext('2d')
-    const dpr = wx.getSystemInfoSync().pixelRatio
-    canvas.width = width * dpr
-    canvas.height = height * dpr
-    ctx.scale(dpr, dpr)
+    canvas.width = width
+    canvas.height = height
     this._canvas = canvas
     this._ctx = ctx
     this._executionArr = [] //每移动一笔的数据
@@ -74,34 +72,10 @@ class DrawCanvas {
     img.onload = () => {
       const fillStyle = this._ctx.createPattern(img, 'repeat')
       // 矩阵变化
-      // fillStyle.setTransform(matrix.rotate(-45))
-      // const matrix = new DOMMatrix()
-      fillStyle.setTransform({
-        a: 0.7071067811865476,
-        b: 0.7071067811865476,
-        c: -0.7071067811865476,
-        d: 0.7071067811865476,
-        e: 0,
-        f: 0,
-        is2D: true,
-        isIdentity: false,
-        m11: 0.7071067811865476,
-        m12: 0.7071067811865476,
-        m13: 0,
-        m14: 0,
-        m21: -0.7071067811865476,
-        m22: 0.7071067811865476,
-        m23: 0,
-        m24: 0,
-        m31: 0,
-        m32: 0,
-        m33: 1,
-        m34: 0,
-        m41: 0,
-        m42: 0,
-        m43: 0,
-        m44: 1
-      })
+      const matrix = this._ctx.getTransform()
+      matrix.rotateSelf(-45)
+      console.log(11111,matrix);
+      fillStyle.setTransform(matrix)
       this._style = { fillStyle, w, h }
     }
     img.src = url