|
@@ -60,7 +60,27 @@ export class SRectSelectItem extends SGraphItem {
|
|
|
* @return 边界区域
|
|
|
*/
|
|
|
boundingRect(): SRect {
|
|
|
- return new SRect(this.startPoint, this.endPoint);
|
|
|
+ let left, top, w, h;
|
|
|
+ // 起始点在结束点左侧
|
|
|
+ if (this.startPoint.x < this.endPoint.x) {
|
|
|
+ left = this.startPoint.x;
|
|
|
+ w = this.endPoint.x - this.startPoint.x;
|
|
|
+ } else {
|
|
|
+ // 否则
|
|
|
+ left = this.endPoint.x;
|
|
|
+ w = this.startPoint.x - this.endPoint.x;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 起始点在结束点上侧
|
|
|
+ if (this.startPoint.y < this.endPoint.y) {
|
|
|
+ top = this.startPoint.y;
|
|
|
+ h = this.endPoint.y - this.startPoint.y;
|
|
|
+ } else {
|
|
|
+ // 否则
|
|
|
+ top = this.endPoint.y;
|
|
|
+ h = this.startPoint.y - this.endPoint.y;
|
|
|
+ }
|
|
|
+ return new SRect(left, top, w, h);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -85,6 +105,6 @@ export class SRectSelectItem extends SGraphItem {
|
|
|
painter.pen.lineWidth = painter.toPx(2);
|
|
|
painter.pen.color = ItemColor.rectSelectOutColor;
|
|
|
painter.brush.color = ItemColor.rectSelectInColor;
|
|
|
- painter.drawRect(this.startPoint, this.endPoint);
|
|
|
+ painter.drawRect(this.boundingRect());
|
|
|
}
|
|
|
}
|