|
@@ -7,7 +7,7 @@ import VectorCategory from "../enum/VectorCategory";
|
|
import RoadStructure from "../enum/RoadStructure";
|
|
import RoadStructure from "../enum/RoadStructure";
|
|
import SVGType from "../enum/SVGType";
|
|
import SVGType from "../enum/SVGType";
|
|
|
|
|
|
-//const sideWidth = 10;
|
|
|
|
|
|
+const controlPointDistance = 100;
|
|
export default class SVG extends Geometry {
|
|
export default class SVG extends Geometry {
|
|
constructor(center, type, vectorId) {
|
|
constructor(center, type, vectorId) {
|
|
super();
|
|
super();
|
|
@@ -20,7 +20,8 @@ export default class SVG extends Geometry {
|
|
this.scaleLength = this.getScale();
|
|
this.scaleLength = this.getScale();
|
|
this.scaleWidth = this.getScale();
|
|
this.scaleWidth = this.getScale();
|
|
this.setBoundingVertexs();
|
|
this.setBoundingVertexs();
|
|
- this.controlAnglePoint = this.setControlAnglePoint();
|
|
|
|
|
|
+ this.controlAnglePoint = null;
|
|
|
|
+ this.setControlAnglePoint();
|
|
this.setId(vectorId);
|
|
this.setId(vectorId);
|
|
this.checkCategory(type);
|
|
this.checkCategory(type);
|
|
}
|
|
}
|
|
@@ -114,21 +115,50 @@ export default class SVG extends Geometry {
|
|
this.points = points;
|
|
this.points = points;
|
|
}
|
|
}
|
|
|
|
|
|
- setControlAnglePoint() {
|
|
|
|
- const len =
|
|
|
|
- mathUtil.getDistance(this.points[0], this.points[2]) / 2 +
|
|
|
|
- 20 * coordinate.ratio;
|
|
|
|
|
|
+ setCenter() {
|
|
|
|
+ this.center.x =
|
|
|
|
+ (this.points[0].x +
|
|
|
|
+ this.points[1].x +
|
|
|
|
+ this.points[2].x +
|
|
|
|
+ this.points[3].x) /
|
|
|
|
+ 4;
|
|
|
|
+ this.center.y =
|
|
|
|
+ (this.points[0].y +
|
|
|
|
+ this.points[1].y +
|
|
|
|
+ this.points[2].y +
|
|
|
|
+ this.points[3].y) /
|
|
|
|
+ 4;
|
|
|
|
+ }
|
|
|
|
|
|
- const v = {
|
|
|
|
- x: Math.cos(this.angle + Math.PI / 2),
|
|
|
|
- y: Math.sin(this.angle + Math.PI / 2),
|
|
|
|
- };
|
|
|
|
- console.log(this.angle);
|
|
|
|
- const p = {
|
|
|
|
- x: this.center.x + v.x * len,
|
|
|
|
- y: this.center.y + v.y * len,
|
|
|
|
- };
|
|
|
|
- return p;
|
|
|
|
|
|
+ setControlAnglePoint() {
|
|
|
|
+ // const len =
|
|
|
|
+ // mathUtil.getDistance(this.points[0], this.points[2]) / 2 +
|
|
|
|
+ // 20 * coordinate.ratio;
|
|
|
|
+ // const v = {
|
|
|
|
+ // x: Math.sin(this.angle),
|
|
|
|
+ // y: Math.cos(this.angle),
|
|
|
|
+ // };
|
|
|
|
+ // console.log("svg角度:" + this.angle);
|
|
|
|
+ // this.controlAnglePoint = {
|
|
|
|
+ // x: this.center.x + v.x * len,
|
|
|
|
+ // y: this.center.y + v.y * len,
|
|
|
|
+ // };
|
|
|
|
+ const distance = controlPointDistance * coordinate.ratio;
|
|
|
|
+ const line = mathUtil.createLine1(this.points[0], this.points[1]);
|
|
|
|
+ const lines = mathUtil.getParallelLineForDistance(line, distance);
|
|
|
|
+ const dis1 = mathUtil.getDisForPoinLine(this.center, lines.line1);
|
|
|
|
+ const dis2 = mathUtil.getDisForPoinLine(this.center, lines.line2);
|
|
|
|
+ if (dis1 > dis2) {
|
|
|
|
+ this.controlAnglePoint = mathUtil.getJoinLinePoint(
|
|
|
|
+ this.center,
|
|
|
|
+ lines.line1
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ this.controlAnglePoint = mathUtil.getJoinLinePoint(
|
|
|
|
+ this.center,
|
|
|
|
+ lines.line2
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// setLengthScale(scale1) {
|
|
// setLengthScale(scale1) {
|