Browse Source

添加阴影支持;更新包

haojianlong 5 years ago
parent
commit
28ab25c383

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

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/big",
-    "version": "1.0.29",
+    "version": "1.0.32",
     "description": "上格云建筑信息化库",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -42,6 +42,6 @@
         "typescript": "^3.9.3"
     },
     "dependencies": {
-        "@saga-web/graph": "2.1.72"
+        "@saga-web/graph": "2.1.76"
     }
 }

+ 1 - 0
saga-web-big/src/items/SPolylineItem.ts

@@ -267,6 +267,7 @@ export class SPolylineItem extends SGraphItem {
         if (event.keyCode == 13) {
             this.status = SItemStatus.Normal;
             this.releaseItem();
+            this.$emit("finishCreated");
         }
     } // Function onKeyUp()
 

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

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

+ 14 - 4
saga-web-draw/src/SPainter.ts

@@ -15,6 +15,7 @@ import {
 import { SCompositeType } from "./enums/SCompositeType";
 import { SArrow } from "./types/SArrow";
 import { SArrowStyleType } from "./enums/SArrowStyleType";
+import { SShadow } from "./SShadow";
 
 /**
  * Painter
@@ -27,7 +28,7 @@ export class SPainter extends SObject {
     /** 绘制引擎 */
     private readonly engine: SPaintEngine;
 
-    /** 画笔 */
+    /** 画笔  */
     get pen(): SPen {
         return this.engine.state.pen;
     } // Get pen
@@ -35,7 +36,7 @@ export class SPainter extends SObject {
         this.engine.state.pen = value;
     } // Set pen
 
-    /** 画刷 */
+    /** 画刷  */
     get brush(): SBrush {
         return this.engine.state.brush;
     } // Get brush
@@ -43,7 +44,7 @@ export class SPainter extends SObject {
         this.engine.state.brush = value;
     } // Set brush
 
-    /** 字体属性 */
+    /** 字体属性    */
     get font(): SFont {
         return this.engine.state.font;
     } // Get font
@@ -51,7 +52,7 @@ export class SPainter extends SObject {
         this.engine.state.font = value;
     } // Set font
 
-    /** 融合属性 */
+    /** 融合属性    */
     get composite(): number {
         return this.engine.state._composite;
     } // Get composite
@@ -59,6 +60,14 @@ export class SPainter extends SObject {
         this.engine.state._composite = value;
     } // Set composite
 
+    /** 阴影设置    */
+    get shadow(): SShadow {
+        return this.engine.state.shadow;
+    } // Get shadow
+    set shadow(value: SShadow) {
+        this.engine.state.shadow = value;
+    } // Set shadow
+
     /** 变换矩阵 */
     get worldTransform(): DOMMatrix {
         return this.engine.state.matrix;
@@ -82,6 +91,7 @@ export class SPainter extends SObject {
         this.brush = new SBrush();
         this.font = new SFont();
         this.composite = SCompositeType.SourceOver;
+        this.shadow = new SShadow();
     } // Constructor()
 
     /**

+ 30 - 2
saga-web-draw/src/engines/SCanvasPaintEngine.ts

@@ -96,6 +96,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
         this.setPen();
         this.setBrush();
         this.setComposite();
+        this.setShadow();
         this._canvas.fillRect(rect.x, rect.y, rect.width, rect.height);
         this._canvas.strokeRect(rect.x, rect.y, rect.width, rect.height);
     } // Function drawRect()
@@ -112,6 +113,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
         this.setPen();
         this.setBrush();
         this.setComposite();
+        this.setShadow();
         this._canvas.beginPath();
         this._canvas.arc(cx, cy, r, 0, 2 * Math.PI, true);
         this._canvas.fill();
@@ -131,6 +133,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
         this.setPen();
         this.setBrush();
         this.setComposite();
+        this.setShadow();
         this._canvas.beginPath();
         this._canvas.ellipse(cx, cy, rx, ry, 0.5, 0, 2 * Math.PI, true);
     } // Function drawEllipse()
@@ -157,6 +160,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
         this.setPen();
         this.setBrush();
         this.setComposite();
+        this.setShadow();
         let p = SPath2D.arc(x, y, width, height, startAngle, endAngle);
         let path = new Path2D(
             SPath2D.arc(x, y, width, height, startAngle, endAngle)
@@ -186,6 +190,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
         this.setPen();
         this.setBrush();
         this.setComposite();
+        this.setShadow();
         let path = new Path2D(
             SPath2D.chord(x, y, width, height, startAngle, endAngle)
         );
@@ -216,6 +221,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
         this.setPen();
         this.setBrush();
         this.setComposite();
+        this.setShadow();
         let path = new Path2D(
             SPath2D.pie(x, y, width, height, startAngle, endAngle)
         );
@@ -233,6 +239,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
         this.setPen();
         this.setBrush();
         this.setComposite();
+        this.setShadow();
         this._canvas.beginPath();
         this._canvas.moveTo(line.x1, line.y1);
         this._canvas.lineTo(line.x2, line.y2);
@@ -254,6 +261,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
         this.setPen();
         this.setBrush();
         this.setComposite();
+        this.setShadow();
 
         this._canvas.beginPath();
         this._canvas.moveTo(points[0].x, points[0].y);
@@ -279,6 +287,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
         this.setPen();
         this.setBrush();
         this.setComposite();
+        this.setShadow();
 
         this._canvas.beginPath();
         this._canvas.moveTo(points[0].x, points[0].y);
@@ -301,6 +310,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
         this.setPen();
         this.setBrush();
         this.setComposite();
+        this.setShadow();
 
         this._canvas.fill(path._path);
         this._canvas.stroke(path._path);
@@ -320,6 +330,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
         this.setBrush();
         this.setFont();
         this.setComposite();
+        this.setShadow();
 
         if (maxWidth == undefined) {
             this._canvas.fillText(text, x, y);
@@ -418,7 +429,6 @@ export class SCanvasPaintEngine extends SPaintEngine {
      * @param   style       风格
      */
     private setLineCapStyle(style: SLineCapStyle): void {
-        // TODO: 找原因,去下边一行
         if (style == undefined) return;
         if (style == SLineCapStyle.Round) {
             this._canvas.lineCap = "round";
@@ -464,7 +474,9 @@ export class SCanvasPaintEngine extends SPaintEngine {
                 gradient.stopList.forEach((t: SGradientStop): void => {
                     drawGradient.addColorStop(
                         t.pos,
-                        `rgba(${t.color.red},${t.color.green},${t.color.blue},${t.color.alpha})`
+                        `rgba(${t.color.red},${t.color.green},${
+                            t.color.blue
+                        },${t.color.alpha / 255.0})`
                     );
                 });
                 this._canvas.fillStyle = drawGradient;
@@ -486,6 +498,22 @@ export class SCanvasPaintEngine extends SPaintEngine {
     } // Function setComposite()
 
     /**
+     * 设置阴影
+     */
+    private setShadow(): void {
+        if (this.state.shadow.shadowBlur > 0 && this.state.shadow.shadowColor) {
+            this._canvas.shadowBlur = this.state.shadow.shadowBlur;
+            this._canvas.shadowColor = `rgba(${
+                this.state.shadow.shadowColor.red
+            },${this.state.shadow.shadowColor.green}, ${
+                this.state.shadow.shadowColor.blue
+            }, ${this.state.shadow.shadowColor.alpha / 255.0})`;
+            this._canvas.shadowOffsetX = this.state.shadow.shadowOffsetX;
+            this._canvas.shadowOffsetY = this.state.shadow.shadowOffsetY;
+        }
+    } // Function setShadow()
+
+    /**
      * 设置字体
      */
     private setFont(): void {

+ 13 - 0
saga-web-draw/src/engines/SPaintState.ts

@@ -1,5 +1,6 @@
 import { SBrush, SFont, SPen } from "..";
 import { SCompositeType } from "../enums/SCompositeType";
+import { SShadow } from "../SShadow";
 
 /**
  * 绘制状态
@@ -40,8 +41,19 @@ export class SPaintState {
     /** 融合 */
     _composite = SCompositeType.SourceOver;
 
+    /** 阴影效果    */
+    private _shadow: SShadow = new SShadow();
+    get shadow(): SShadow {
+        return this._shadow;
+    }
+    set shadow(v: SShadow) {
+        this._shadow = v;
+    }
+
     /**
      * 构造函数
+     *
+     * @param   state   绘制状态
      */
     constructor(state?: SPaintState) {
         if (state != undefined) {
@@ -49,6 +61,7 @@ export class SPaintState {
             this.brush = new SBrush(state.brush);
             this.font = new SFont(state.font);
             this._composite = state._composite;
+            this.shadow = new SShadow(state.shadow);
             let m = new DOMMatrix();
             m.m11 = state.matrix.m11;
             m.m12 = state.matrix.m12;

+ 3 - 3
saga-web-graph/package.json

@@ -1,12 +1,12 @@
 {
     "name": "@saga-web/graph",
-    "version": "2.1.72",
+    "version": "2.1.76",
     "description": "上格云二维图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
     "remote": {
         "host": "47.94.89.44",
-        "path": "/opt/tomcat9/webapps/api/web/graphy",
+        "path": "/opt/tomcat9/webapps/api/web/graph",
         "user": "user1",
         "password": "@)!^sagacloud",
         "local": "api"
@@ -41,6 +41,6 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@saga-web/draw": "2.1.86"
+        "@saga-web/draw": "2.1.89"
     }
 }