Browse Source

添加选中点的填充颜色

zhangyu 5 years ago
parent
commit
d220a5113b
1 changed files with 20 additions and 14 deletions
  1. 20 14
      saga-web-big/src/items/SLineItem.ts

+ 20 - 14
saga-web-big/src/items/SLineItem.ts

@@ -55,8 +55,8 @@ export class SLineItem extends SGraphItem {
         this.update();
     }
 
-    /** 填充色 */
-    _fillColor: string = "#2196f3";
+    /** 端点填充色 */
+    _fillColor: string = "#ffffff";
     get fillColor(): string {
         return this._fillColor;
     }
@@ -65,6 +65,16 @@ export class SLineItem extends SGraphItem {
         this.update();
     }
 
+    /** 选中端点填充色 */
+    _activeFillColor: string = "#2196f3";
+    get activeFillColor(): string {
+        return this._activeFillColor;
+    }
+    set activeFillColor(v: string) {
+        this._activeFillColor = v;
+        this.update();
+    }
+
     /** 线条宽度    */
     _lineWidth: number = 1;
     get lineWidth(): number {
@@ -241,7 +251,7 @@ export class SLineItem extends SGraphItem {
      * */
     findNearestPoint(p: SPoint): void {
         let len = this.sceneDis;
-        for (let i = 0; i < 2; i++) {
+        for (let i = 0; i < this.line.length; i++) {
             let dis = SMathUtil.pointDistance(
                 p.x,
                 p.y,
@@ -399,17 +409,13 @@ export class SLineItem extends SGraphItem {
                 this.status == SItemStatus.Create
             ) {
                 // 绘制端点
-                painter.brush.color = new SColor(this.fillColor);
-                painter.drawCircle(
-                    this.line[0].x,
-                    this.line[0].y,
-                    painter.toPx(5)
-                );
-                painter.drawCircle(
-                    this.line[1].x,
-                    this.line[1].y,
-                    painter.toPx(5)
-                );
+                this.line.forEach((p, i): void => {
+                    painter.brush.color = new SColor(this.fillColor);
+                    if (i == this.curIndex) {
+                        painter.brush.color = new SColor(this.activeFillColor);
+                    }
+                    painter.drawCircle(p.x, p.y, painter.toPx(5));
+                });
             }
         } else if (this.line.length == 1) {
             if (