Explorar o código

解决GraphItem的isTransform=false时坐标计算错误问题。

sybotan %!s(int64=5) %!d(string=hai) anos
pai
achega
b7ba6d6f52
Modificáronse 1 ficheiros con 2 adicións e 21 borrados
  1. 2 21
      saga-web-graph/src/SGraphItem.ts

+ 2 - 21
saga-web-graph/src/SGraphItem.ts

@@ -181,11 +181,7 @@ export class SGraphItem extends SObject {
             // 如果不进行变形处理,则取消painter的变型操作
             if (!item.isTransform) {
                 let matrix = painter.worldTransform;
-                // let x0 = matrix.e;
-                // let y0 = matrix.f;
-                // painter.resetTransform();
-                // painter.translate(x0, y0);
-                item._inverseScale = 1 / matrix.a;
+                item._inverseScale = 1.0 / matrix.a;
                 painter.scale(item._inverseScale, item._inverseScale);
             }
             // 设置绘制区域
@@ -328,17 +324,6 @@ export class SGraphItem extends SObject {
 
             // 如果不进行变形处理,则取消painter的变型操作
             if (!item.isTransform) {
-                // const vm = new DOMMatrix();
-                // // vm.translateSelf(
-                // //     this.scene?.view?.origin.x,
-                // //     this.scene?.view?.origin.x
-                // // );
-                // vm.scaleSelf(this.scene?.view?.scale, this.scene?.view?.scale);
-                // vm.multiplySelf(m);
-                // let x0 = vm.e;
-                // let y0 = vm.f;
-                // m = new DOMMatrix();
-                // m.translate(x0, y0);
                 m.scaleSelf(item._inverseScale, item._inverseScale);
             }
         }
@@ -616,10 +601,6 @@ export class SGraphItem extends SObject {
         ce.matrix.rotateSelf(0, 0, child.rolate);
 
         if (!child.isTransform) {
-            // let x0 = ce.matrix.e;
-            // let y0 = ce.matrix.f;
-            // ce.matrix = new DOMMatrix();
-            // ce.matrix.translateSelf(x0, y0);
             ce.matrix.scaleSelf(child._inverseScale, child._inverseScale);
         }
 
@@ -665,7 +646,7 @@ export class SGraphItem extends SObject {
         m.scaleSelf(this.scale, this.scale);
         m.rotateSelf(this.rolate);
         if (!this.isTransform) {
-            m.rotateSelf(this._inverseScale, this._inverseScale);
+            m.scaleSelf(this._inverseScale, this._inverseScale);
         }
 
         const mp = new DOMPoint(x, y).matrixTransform(m);