|
|
@@ -1448,13 +1448,14 @@ export default class Draw {
|
|
|
const height = mathUtil.getDistance(points[0], points[3]);
|
|
|
const dires = [points[0], { ...points[0], x: 10000 }, points[1]];
|
|
|
let angle = mathUtil.Angle(...dires) * (Math.PI / 180);
|
|
|
+ const rawAngle = angle;
|
|
|
angle = mathUtil.isClockwise(dires) ? angle : -angle;
|
|
|
this.context.save();
|
|
|
this.context.translate(points[0].x, points[0].y);
|
|
|
this.context.rotate(angle);
|
|
|
this.context.scale(width / svgWidth, height / svgHidth);
|
|
|
- console.log(width, height);
|
|
|
const [style, label] = help.getVectorStyle(vector);
|
|
|
+
|
|
|
this.context.lineWidth = style.lineWidth / (width / svgWidth);
|
|
|
this.context.fillStyle = "rgba(0,0,0,0)";
|
|
|
this.context.strokeStyle = "rgba(0,0,0,0)";
|
|
|
@@ -1480,6 +1481,8 @@ export default class Draw {
|
|
|
this.context.stroke();
|
|
|
this.context.fill();
|
|
|
this.context.restore();
|
|
|
+ console.log(vector);
|
|
|
+
|
|
|
vector.points.forEach((point) =>
|
|
|
this.drawPoint({
|
|
|
...point,
|
|
|
@@ -1488,6 +1491,34 @@ export default class Draw {
|
|
|
radius: 5,
|
|
|
})
|
|
|
);
|
|
|
+
|
|
|
+ const center = { x: 0, y: 0 };
|
|
|
+ vector.points.forEach((point) => {
|
|
|
+ center.x += point.x;
|
|
|
+ center.y += point.y;
|
|
|
+ });
|
|
|
+ center.x /= vector.points.length;
|
|
|
+ center.y /= vector.points.length;
|
|
|
+
|
|
|
+ const len =
|
|
|
+ mathUtil.getDistance(vector.points[0], vector.points[2]) / 2 +
|
|
|
+ 20 * coordinate.ratio;
|
|
|
+
|
|
|
+ const v = {
|
|
|
+ x: Math.cos(rawAngle + Math.PI / 2),
|
|
|
+ y: Math.sin(rawAngle + Math.PI / 2),
|
|
|
+ };
|
|
|
+ const p = {
|
|
|
+ x: center.x + v.x * len,
|
|
|
+ y: center.y + v.y * len,
|
|
|
+ };
|
|
|
+
|
|
|
+ this.drawPoint({
|
|
|
+ ...p,
|
|
|
+ fillColor: "#fff",
|
|
|
+ color: style.strokeStyle,
|
|
|
+ radius: 5,
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|