bill 2 kuukautta sitten
vanhempi
commit
77d15cf39d
2 muutettua tiedostoa jossa 35 lisäystä ja 6 poistoa
  1. 3 5
      src/dbo/main.ts
  2. 32 1
      src/graphic/Renderer/Draw.js

+ 3 - 5
src/dbo/main.ts

@@ -4,11 +4,9 @@ import { params } from "@/hook";
 const instance = axios.create();
 
 console.log(import.meta.env);
-export const baseURL =
-  // import.meta.env.VITE_API_BASE_URL
-  //   ? `/${import.meta.env.VITE_API_BASE_URL}/${params.m}`
-  //   :
-  `/${params.m}`;
+export const baseURL = import.meta.env.VITE_API_BASE_URL
+  ? `/${import.meta.env.VITE_API_BASE_URL}/${params.m}`
+  : `/${params.m}`;
 
 instance.defaults.baseURL = baseURL;
 

+ 32 - 1
src/graphic/Renderer/Draw.js

@@ -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,
+      });
     }
   }