箭头设备调整

This commit is contained in:
fan 2023-10-10 09:53:22 +08:00
parent 77b69005b6
commit af08d1ae10
2 changed files with 20 additions and 14 deletions

View File

@ -45,13 +45,16 @@ export class Arrow extends JlGraphic implements ILineGraphic {
this.arrowGraphic.clear(); this.arrowGraphic.clear();
this.arrowGraphic.beginFill(ArrowConsts.lineColor, 1); this.arrowGraphic.beginFill(ArrowConsts.lineColor, 1);
if (this.arrowGraphic.drawRegularPolygon) { if (this.arrowGraphic.drawRegularPolygon) {
this.arrowGraphic.drawRegularPolygon( let roation = Math.PI / 2;
-10, const angle = Math.atan2(p1.y - p2.y, p1.x - p2.x);
0, if (angle > Math.PI / 2) {
10, roation = angle - Math.PI / 2;
3, } else if (angle <= Math.PI / 2 && angle >= 0) {
Math.atan2(p2.y - p1.y, p2.x - p1.y) roation = Math.PI / 2 - angle;
); } else {
roation = angle - Math.PI / 2;
}
this.arrowGraphic.drawRegularPolygon(p2.x, p2.y, 10, 3, roation);
} }
this.arrowGraphic.endFill(); this.arrowGraphic.endFill();
} }

View File

@ -70,13 +70,16 @@ export class ArrowDraw extends GraphicDrawAssistant<ArrowTemplate, IArrowData> {
this.arrowGraphic.clear(); this.arrowGraphic.clear();
this.arrowGraphic.beginFill(ArrowConsts.lineColor, 1); this.arrowGraphic.beginFill(ArrowConsts.lineColor, 1);
if (this.arrowGraphic.drawRegularPolygon) { if (this.arrowGraphic.drawRegularPolygon) {
this.arrowGraphic.drawRegularPolygon( let roation = Math.PI / 2;
-10, const angle = Math.atan2(p1.y - p.y, p1.x - p.x);
0, if (angle > Math.PI / 2) {
10, roation = angle - Math.PI / 2;
3, } else if (angle <= Math.PI / 2 && angle >= 0) {
Math.atan2(p.y - p1.y, p.x - p1.y) roation = Math.PI / 2 - angle;
); } else {
roation = angle - Math.PI / 2;
}
this.arrowGraphic.drawRegularPolygon(p.x, p.y, 10, 3, roation);
} }
this.arrowGraphic.endFill(); this.arrowGraphic.endFill();
} }