|
@@ -25,7 +25,8 @@ import {
|
|
|
SLineCapStyle,
|
|
|
SPainter,
|
|
|
SPoint,
|
|
|
- SPolygonUtil
|
|
|
+ SPolygonUtil,
|
|
|
+ SRect
|
|
|
} from "@saga-web/draw/lib";
|
|
|
import { SMouseEvent } from "@saga-web/base/lib";
|
|
|
import { ItemOrder } from "../types/ItemOrder";
|
|
@@ -43,6 +44,14 @@ export class ShadeItem extends SGraphItem {
|
|
|
closeFlag = false;
|
|
|
/** 鼠标移动点 */
|
|
|
private lastPoint = new SPoint();
|
|
|
+ /** X坐标最小值 */
|
|
|
+ private minX = Number.MAX_SAFE_INTEGER;
|
|
|
+ /** X坐标最大值 */
|
|
|
+ private maxX = Number.MIN_SAFE_INTEGER;
|
|
|
+ /** Y坐标最小值 */
|
|
|
+ private minY = Number.MAX_SAFE_INTEGER;
|
|
|
+ /** Y坐标最大值 */
|
|
|
+ private maxY = Number.MIN_SAFE_INTEGER;
|
|
|
|
|
|
/**
|
|
|
* 构造函数
|
|
@@ -163,10 +172,47 @@ export class ShadeItem extends SGraphItem {
|
|
|
// @ts-ignore
|
|
|
this.scene.isCutting = false;
|
|
|
}
|
|
|
+ this.calRect();
|
|
|
this.update();
|
|
|
} // Function createMask()
|
|
|
|
|
|
/**
|
|
|
+ * 计算 item 所占边界
|
|
|
+ */
|
|
|
+ calRect(): void {
|
|
|
+ if (this.outLine.length) {
|
|
|
+ this.outLine.forEach(it => {
|
|
|
+ let x = it.x,
|
|
|
+ y = it.y;
|
|
|
+ if (x < this.minX) {
|
|
|
+ this.minX = x;
|
|
|
+ }
|
|
|
+ if (y < this.minY) {
|
|
|
+ this.minY = y;
|
|
|
+ }
|
|
|
+ if (x > this.maxX) {
|
|
|
+ this.maxX = x;
|
|
|
+ }
|
|
|
+ if (y > this.maxY) {
|
|
|
+ this.maxY = y;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } // Function calRect()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 外接矩阵
|
|
|
+ */
|
|
|
+ boundingRect(): SRect {
|
|
|
+ return new SRect(
|
|
|
+ this.minX,
|
|
|
+ this.minY,
|
|
|
+ this.maxX - this.minX,
|
|
|
+ this.maxY - this.minY
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 判断点是否在区域内
|
|
|
*
|
|
|
* @param x
|