|
@@ -62,6 +62,7 @@ export class SceneMarkItem extends SGraphyItem {
|
|
* @return boolean
|
|
* @return boolean
|
|
*/
|
|
*/
|
|
onMouseDown(event: SMouseEvent): boolean {
|
|
onMouseDown(event: SMouseEvent): boolean {
|
|
|
|
+ console.log(arguments);
|
|
if (!this.closeFlag && event.buttons == 1) {
|
|
if (!this.closeFlag && event.buttons == 1) {
|
|
let p = new SPoint(event.x, event.y);
|
|
let p = new SPoint(event.x, event.y);
|
|
this.lastPoint.x = p.x;
|
|
this.lastPoint.x = p.x;
|
|
@@ -93,7 +94,7 @@ export class SceneMarkItem extends SGraphyItem {
|
|
if (event.keyCode == 13 && this.outLine.length >= 3) {
|
|
if (event.keyCode == 13 && this.outLine.length >= 3) {
|
|
this.createMask();
|
|
this.createMask();
|
|
}
|
|
}
|
|
- } // Function onKeydown()
|
|
|
|
|
|
+ } // Function onKeyUp()
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创建蒙版
|
|
* 创建蒙版
|
|
@@ -107,10 +108,35 @@ export class SceneMarkItem extends SGraphyItem {
|
|
this.mask.lineTo(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);
|
|
this.mask.lineTo(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);
|
|
this.mask.lineTo(Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);
|
|
this.mask.lineTo(Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);
|
|
this.mask.lineTo(Number.MIN_SAFE_INTEGER, Number.MIN_SAFE_INTEGER);
|
|
this.mask.lineTo(Number.MIN_SAFE_INTEGER, Number.MIN_SAFE_INTEGER);
|
|
- this.mask.polygon(this.outLine);
|
|
|
|
|
|
+
|
|
|
|
+ let antiArr = this.outLine;
|
|
|
|
+ if(this.isAntiClockWise(this.outLine)){
|
|
|
|
+ antiArr = this.outLine.reverse();
|
|
|
|
+ }
|
|
|
|
+ this.mask.polygon(antiArr);
|
|
} // Function createMask()
|
|
} // Function createMask()
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 判断多边形点是否逆时针排列
|
|
|
|
+ *
|
|
|
|
+ * @param pArr 点数组
|
|
|
|
+ * @return boolean 是-true 否-false
|
|
|
|
+ */
|
|
|
|
+ private isAntiClockWise(pArr: SPoint[]): boolean {
|
|
|
|
+ let newArr = pArr.concat([]);
|
|
|
|
+ let rightPoint = newArr[0],
|
|
|
|
+ index = 0;
|
|
|
|
+ for (let i = 1; i < newArr.length; i++) {
|
|
|
|
+ if (newArr[i].x > rightPoint.x) {
|
|
|
|
+ index = i;
|
|
|
|
+ rightPoint = newArr[i];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ index = index == 0 ? newArr.length - 1 : index - 1;
|
|
|
|
+ return rightPoint.y > newArr[index].y;
|
|
|
|
+ } // Function isAntiClockWise
|
|
|
|
+
|
|
|
|
+ /**
|
|
* Item绘制操作
|
|
* Item绘制操作
|
|
*
|
|
*
|
|
* @param painter painter对象
|
|
* @param painter painter对象
|