浏览代码

修改字体默认top 且不允许修改

haojianlong 5 年之前
父节点
当前提交
7b45708547
共有 4 个文件被更改,包括 47 次插入6 次删除
  1. 1 1
      saga-web-big/package.json
  2. 3 3
      saga-web-draw/src/SFont.ts
  3. 36 2
      saga-web-draw/src/types/SRect.ts
  4. 7 0
      saga-web-graph/src/SGraphItem.ts

+ 1 - 1
saga-web-big/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/big",
-    "version": "1.0.23",
+    "version": "1.0.24",
     "description": "上格云建筑信息化库",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 3 - 3
saga-web-draw/src/SFont.ts

@@ -19,7 +19,7 @@ export class SFont {
     textAlign = STextAlign.Start;
 
     /** 文本基线对齐选项 */
-    textBaseLine = STextBaseLine.Top;
+    private textBaseLine = STextBaseLine.Top;
 
     /** 文本方向 */
     textDirection = STextDirection.Inherit;
@@ -44,7 +44,7 @@ export class SFont {
      * @param   name        字体
      * @param   size        字号
      */
-    constructor(name: string, size?: number)
+    constructor(name: string, size?: number);
     /**
      * 构造函数
      *
@@ -59,7 +59,7 @@ export class SFont {
             this.name = name.name;
             this.size = name.size;
             this.textAlign = name.textAlign;
-            this.textBaseLine = name.textBaseLine;
+            // this.textBaseLine = name.textBaseLine;
             this.textDirection = name.textDirection;
         } else {
             this.name = name;

+ 36 - 2
saga-web-draw/src/types/SRect.ts

@@ -187,7 +187,8 @@ export class SRect {
         return (
             x >= this.left &&
             x <= this.right &&
-            (y >= this.top && y <= this.bottom)
+            y >= this.top &&
+            y <= this.bottom
         );
     } // Function contains()
 
@@ -283,5 +284,38 @@ export class SRect {
         let right = Math.max(this.right, rect.right);
         let bottom = Math.max(this.bottom, rect.bottom);
         return new SRect(left, top, right - left, bottom - top);
-    } // Function union()
+    } // Function unioned()
+
+    /**
+     * 生成相交矩形
+     *
+     * @param   rect    合并的矩形
+     * @return  返回合并后的矩形
+     */
+    intersected(rect: SRect): SRect {
+        let minX = this.left < rect.left ? this.left : rect.left;
+        let minY = this.top < rect.top ? this.top : rect.top;
+        let maxX = this.right > rect.right ? this.right : rect.right;
+        let maxY = this.bottom > rect.bottom ? this.bottom : rect.bottom;
+        if (
+            this.width + rect.width > maxX - minX &&
+            this.height + rect.height > maxY - minY
+        ) {
+            return new SRect();
+        }
+        return new SRect();
+    } // Function Intersected()
+
+    /**
+     * 相交矩形
+     *
+     * @param   rect    合并的矩形
+     */
+    intersect(rect: SRect): SRect {
+        let left = Math.min(this.left, rect.left);
+        let top = Math.min(this.top, rect.top);
+        let right = Math.max(this.right, rect.right);
+        let bottom = Math.max(this.bottom, rect.bottom);
+        return new SRect(left, top, right - left, bottom - top);
+    } // Function intersect()
 } // Class SRect

+ 7 - 0
saga-web-graph/src/SGraphItem.ts

@@ -161,6 +161,11 @@ export class SGraphItem extends SObject {
             if (!item.visible) {
                 continue;
             }
+            // item所占矩阵与要刷新的矩阵相交则刷新,否则不刷
+            // if (item.boundingRect()--rect){
+            //
+            // }
+
             // 保存画布状态
             painter.save();
             // item位移到指定位置绘制
@@ -176,6 +181,8 @@ export class SGraphItem extends SObject {
             }
             // 设置绘制区域
             // canvas.clip(item.boundingRect())
+
+            // rect 调整  宽度高度取最小值  根据pos位移
             // 绘制item
             item.onPaint(painter, rect);
             // 恢复画布状态