|
@@ -4,12 +4,103 @@ import { mathUtil } from "../Util/MathUtil.js";
|
|
import { coordinate } from "../Coordinate.js";
|
|
import { coordinate } from "../Coordinate.js";
|
|
import Constant from "../Constant.js";
|
|
import Constant from "../Constant.js";
|
|
|
|
|
|
|
|
+//const sideWidth = 10;
|
|
export default class SVG extends Geometry {
|
|
export default class SVG extends Geometry {
|
|
constructor(center, vectorId) {
|
|
constructor(center, vectorId) {
|
|
super();
|
|
super();
|
|
this.center = center;
|
|
this.center = center;
|
|
|
|
+ this.points = null; //包裹的矩形的四个顶点
|
|
|
|
+ this.angle = 0; //逆时针为负,顺时针为正。单位是:°
|
|
|
|
+ this.scale = 1; //缩放比例
|
|
this.name = null;
|
|
this.name = null;
|
|
this.geoType = VectorType.SVG;
|
|
this.geoType = VectorType.SVG;
|
|
this.setId(vectorId);
|
|
this.setId(vectorId);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // createDefaultPoints() {
|
|
|
|
+ // this.points = [];
|
|
|
|
+ // this.points[0] = {
|
|
|
|
+ // x: this.center.x - sideWidth / 2,
|
|
|
|
+ // y: this.center.y + sideWidth / 2,
|
|
|
|
+ // };
|
|
|
|
+ // this.points[1] = {
|
|
|
|
+ // x: this.center.x + sideWidth / 2,
|
|
|
|
+ // y: this.center.y + sideWidth / 2,
|
|
|
|
+ // };
|
|
|
|
+ // this.points[2] = {
|
|
|
|
+ // x: this.center.x + sideWidth / 2,
|
|
|
|
+ // y: this.center.y - sideWidth / 2,
|
|
|
|
+ // };
|
|
|
|
+ // this.points[3] = {
|
|
|
|
+ // x: this.center.x - sideWidth / 2,
|
|
|
|
+ // y: this.center.y - sideWidth / 2,
|
|
|
|
+ // };
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ getBoundingVertexs(center) {
|
|
|
|
+ const boundingVertexs = [];
|
|
|
|
+ const rec = this.getLengthWidth();
|
|
|
|
+ const length = this.getScale() * rec.length * this.scale;
|
|
|
|
+ const width = this.getScale() * rec.width * this.scale;
|
|
|
|
+
|
|
|
|
+ const minX = center.x - length / 2;
|
|
|
|
+ const minY = center.y - width / 2;
|
|
|
|
+ const maxX = center.x + length / 2;
|
|
|
|
+ const maxY = center.y + width / 2;
|
|
|
|
+
|
|
|
|
+ const point1 = this.rotatePoint(
|
|
|
|
+ {
|
|
|
|
+ x: minX,
|
|
|
|
+ y: maxY,
|
|
|
|
+ },
|
|
|
|
+ center,
|
|
|
|
+ this.angle
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ const point2 = this.rotatePoint(
|
|
|
|
+ {
|
|
|
|
+ x: maxX,
|
|
|
|
+ y: maxY,
|
|
|
|
+ },
|
|
|
|
+ center,
|
|
|
|
+ this.angle
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ const point3 = this.rotatePoint(
|
|
|
|
+ {
|
|
|
|
+ x: maxX,
|
|
|
|
+ y: minY,
|
|
|
|
+ },
|
|
|
|
+ center,
|
|
|
|
+ this.angle
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ const point4 = this.rotatePoint(
|
|
|
|
+ {
|
|
|
|
+ x: minX,
|
|
|
|
+ y: minY,
|
|
|
|
+ },
|
|
|
|
+ center,
|
|
|
|
+ this.angle
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ boundingVertexs.push(point1);
|
|
|
|
+ boundingVertexs.push(point2);
|
|
|
|
+ boundingVertexs.push(point3);
|
|
|
|
+ boundingVertexs.push(point4);
|
|
|
|
+
|
|
|
|
+ return boundingVertexs;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //不同图例,缩放比不一样
|
|
|
|
+ getScale() {
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getLengthWidth() {
|
|
|
|
+ return {
|
|
|
|
+ length: 32,
|
|
|
|
+ width: 32,
|
|
|
|
+ };
|
|
|
|
+ }
|
|
}
|
|
}
|