Browse Source

'添加图片原点位置属性'

zhangyu 5 năm trước cách đây
mục cha
commit
bd1a7fa7a2
1 tập tin đã thay đổi với 16 bổ sung2 xóa
  1. 16 2
      saga-web-graph/src/items/SImageItem.ts

+ 16 - 2
saga-web-graph/src/items/SImageItem.ts

@@ -1,6 +1,6 @@
 import { SObjectItem } from "./SObjectItem";
-import { SPainter, SRect, SSize, SColor } from "@saga-web/draw/lib";
-import { SImageShowType } from "..";
+import { SPainter, SRect, SSize, SColor, SPoint } from "@saga-web/draw/lib";
+import { SImageShowType, STextOrigin } from "..";
 import { SGraphItem } from "../SGraphItem";
 
 /**
@@ -43,6 +43,16 @@ export class SImageItem extends SObjectItem {
         this.update();
     }
 
+    /** 原点位置    */
+    private _originPosition: STextOrigin = STextOrigin.LeftTop;
+    get originPosition(): STextOrigin {
+        return this._originPosition;
+    }
+    set originPosition(v: STextOrigin) {
+        this._originPosition = v;
+        this.update();
+    }
+
     /** 图片加载是否完成 */
     isLoadOver: boolean = false;
 
@@ -128,6 +138,10 @@ export class SImageItem extends SObjectItem {
             }
             this.imgWidth = width;
             this.imgHeight = height;
+            // 设置原点位置(默认左上角)
+            if (this.originPosition == STextOrigin.Centrum) {
+                this.origin = new SPoint(this.width / 2, this.height / 2);
+            }
         }
     } // Function computeImgSize()