Browse Source

@saga-web/graphy 2.1.33 解决业务空间生成空白问题。

庞利祥 5 years ago
parent
commit
6646d5c09e

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

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/draw",
-    "version": "2.1.59",
+    "version": "2.1.60",
     "description": "上格云绘制引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 28 - 8
saga-web-draw/src/SPath2D.ts

@@ -1,4 +1,5 @@
 import { SPoint } from "./index";
+import {SStringBuilder} from "@saga-web/base/lib";
 
 /**
  * Path对象
@@ -8,6 +9,14 @@ import { SPoint } from "./index";
 export class SPath2D {
     /** 内部path对象 */
     _path = new Path2D();
+    private svgBuilder = new SStringBuilder();
+
+    /**
+     * svg数据值
+     */
+    svgPath(): string {
+        return this.svgBuilder.toString(" ");
+    } // Function svgPath()
 
     /**
      * 添加路径
@@ -16,6 +25,7 @@ export class SPath2D {
      */
     addPath(path: SPath2D): void {
         this._path.addPath(path._path);
+        this.svgBuilder.append(path.svgBuilder.toString(" "))
     } // Function addPath()
 
     /**
@@ -26,6 +36,7 @@ export class SPath2D {
      */
     moveTo(x: number, y: number): void {
         this._path.moveTo(x, y);
+        this.svgBuilder.append(`M ${x} ${y}`);
     } // Function moveTo()
 
     /**
@@ -36,6 +47,7 @@ export class SPath2D {
      */
     lineTo(x: number, y: number): void {
         this._path.lineTo(x, y);
+        this.svgBuilder.append(`L ${x} ${y}`);
     } // Function moveTo()
 
     /**
@@ -53,13 +65,16 @@ export class SPath2D {
         this._path.lineTo(r, y);
         this._path.lineTo(r, b);
         this._path.lineTo(x, b);
-        this._path.lineTo(x, y);
-        // 逆时针
-        this._path.moveTo(x, y);
-        this._path.lineTo(r, y);
-        this._path.lineTo(r, b);
-        this._path.lineTo(x, b);
-        this._path.lineTo(x, y);
+        this._path.closePath();
+        this.svgBuilder.append(`M ${x} ${y} L${r} ${y} L${r} ${b} L${x} ${b} Z`);
+        // // 逆时针
+        // this._path.moveTo(x, y);
+        // this._path.lineTo(r, y);
+        // this._path.lineTo(r, b);
+        // this._path.lineTo(x, b);
+        // this._path.closePath();
+        // this.svgBuilder.append(`M ${x} ${y} L${r} ${y} L${} ${} L${} ${} L${} ${}`);
+
     } // Function rect()
 
     /**
@@ -74,8 +89,10 @@ export class SPath2D {
         points.map((it: SPoint, index: number): void => {
             if (index == 0) {
                 this._path.moveTo(it.x, it.y);
+                this.svgBuilder.append(`M ${it.x} ${it.y}`);
             } else {
                 this._path.lineTo(it.x, it.y);
+                this.svgBuilder.append(`L ${it.x} ${it.y}`);
             }
         });
     } // Function drawPolyline()
@@ -92,11 +109,14 @@ export class SPath2D {
         points.map((it: SPoint, index: number): void => {
             if (index == 0) {
                 this._path.moveTo(it.x, it.y);
+                this.svgBuilder.append(`M ${it.x} ${it.y}`);
             } else {
                 this._path.lineTo(it.x, it.y);
+                this.svgBuilder.append(`L ${it.x} ${it.y}`);
             }
         });
-        this._path.lineTo(points[0].x, points[0].y);
+        this._path.closePath();
+        this.svgBuilder.append(`Z`);
     } // Functin polygon()
 
     /**

+ 1 - 1
saga-web-draw/src/engines/SSvgPaintEngine.ts

@@ -262,7 +262,7 @@ export class SSvgPaintEngine extends SPaintEngine {
      */
     drawPath(path: SPath2D): void {
         this._builder.append(
-            `<path d="${path._path}" ${this.getStyle(true, true, false)} ${this.getSvgMatrix()}/>`
+            `<path d="${path.svgPath()}" ${this.getStyle(true, true, false)} ${this.getSvgMatrix()}/>`
         );
     } // Function drawPath()
 

+ 2 - 2
saga-web-graphy/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/graphy",
-    "version": "2.1.32",
+    "version": "2.1.33",
     "description": "上格云二维图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -31,6 +31,6 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@saga-web/draw": "^2.1.59"
+        "@saga-web/draw": "^2.1.60"
     }
 }