frontline
This commit is contained in:
parent
bdbdcb5397
commit
93601754d8
105
ArrowPoints.js
105
ArrowPoints.js
@ -4,6 +4,8 @@ import { getArrowPolygon } from "athena-utils/shape/Arrow.js";
|
|||||||
import { ARROW_BODY_STYLE_CONSTANT, ARROW_BODY_STYLE_LINEAR, ARROW_BODY_STYLE_EXPONENTIAL } from "athena-utils/shape/Arrow.js";
|
import { ARROW_BODY_STYLE_CONSTANT, ARROW_BODY_STYLE_LINEAR, ARROW_BODY_STYLE_EXPONENTIAL } from "athena-utils/shape/Arrow.js";
|
||||||
import { getCirclePolygon } from "athena-utils/shape/BasicShapes.js";
|
import { getCirclePolygon } from "athena-utils/shape/BasicShapes.js";
|
||||||
import { getRectanglePolygon } from "athena-utils/shape/BasicShapes.js";
|
import { getRectanglePolygon } from "athena-utils/shape/BasicShapes.js";
|
||||||
|
import { getFrontline } from "athena-utils/shape/Frontline.js";
|
||||||
|
import { LEFT_SIDE, RIGHT_SIDE, BOTH_SIDES } from "athena-utils/shape/Frontline.js";
|
||||||
// Polygon merge using Turf library
|
// Polygon merge using Turf library
|
||||||
import {mergeTurfPolygons} from "athena-utils/shape/Polygon.js";
|
import {mergeTurfPolygons} from "athena-utils/shape/Polygon.js";
|
||||||
import {addTurfPolygonToMerge} from "athena-utils/shape/Polygon.js";
|
import {addTurfPolygonToMerge} from "athena-utils/shape/Polygon.js";
|
||||||
@ -23,18 +25,42 @@ const rectangleSideA = 70;
|
|||||||
const rectangleSideB = 200;
|
const rectangleSideB = 200;
|
||||||
const rectangleRotation = 40;
|
const rectangleRotation = 40;
|
||||||
|
|
||||||
|
const frontlinePointsA = [
|
||||||
|
{ x: 120, y: 400 },
|
||||||
|
{ x: 200, y: 100 },
|
||||||
|
{ x: 350, y: 200 },
|
||||||
|
{ x: 350, y: 400 },
|
||||||
|
{ x: 450, y: 480 },
|
||||||
|
{ x: 550, y: 440 },
|
||||||
|
{ x: 600, y: 300 },
|
||||||
|
];
|
||||||
|
|
||||||
|
const frontlinePointsB = [
|
||||||
|
{ x: 420, y: 280 },
|
||||||
|
{ x: 430, y: 380 },
|
||||||
|
{ x: 500, y: 400 },
|
||||||
|
{ x: 520, y: 300 },
|
||||||
|
];
|
||||||
|
|
||||||
|
const frontlinePointsC = [
|
||||||
|
{ x: 450, y: 200 },
|
||||||
|
{ x: 500, y: 250 },
|
||||||
|
{ x: 550, y: 250 },
|
||||||
|
{ x: 550, y: 200 }
|
||||||
|
];
|
||||||
|
|
||||||
const pointsA = [
|
const pointsA = [
|
||||||
{ x: 50, y: 400 },
|
{ x: 50, y: 400 },
|
||||||
{ x: 150, y: 100 },
|
{ x: 150, y: 100 },
|
||||||
{ x: 300, y: 200 },
|
{ x: 300, y: 200 },
|
||||||
{ x: 300, y: 400 },
|
{ x: 300, y: 500 },
|
||||||
];
|
];
|
||||||
|
|
||||||
const pointsB = [
|
const pointsB = [
|
||||||
{ x: 310, y: 300 },
|
{ x: 310, y: 300 },
|
||||||
{ x: 380, y: 350 },
|
{ x: 380, y: 350 },
|
||||||
{ x: 450, y: 450 },
|
{ x: 450, y: 450 },
|
||||||
{ x: 650, y: 430 }
|
{ x: 380, y: 530 }
|
||||||
];
|
];
|
||||||
|
|
||||||
const pointsC = [
|
const pointsC = [
|
||||||
@ -42,10 +68,45 @@ const pointsC = [
|
|||||||
{ x: 100, y: 100 },
|
{ x: 100, y: 100 },
|
||||||
{ x: 180, y: 95 }
|
{ x: 180, y: 95 }
|
||||||
];
|
];
|
||||||
|
const frontlineDataA = {
|
||||||
|
points: frontlinePointsA,
|
||||||
|
splineStep: 0.08,
|
||||||
|
spacing: 10,
|
||||||
|
offsetDistance: 10,
|
||||||
|
protrusionLength: 15,
|
||||||
|
protrusionStartSize: 5,
|
||||||
|
protrusionEndSize: 2,
|
||||||
|
protrusionGap: 20,
|
||||||
|
style: LEFT_SIDE,
|
||||||
|
};
|
||||||
|
|
||||||
|
const frontlineDataB = {
|
||||||
|
points: frontlinePointsB,
|
||||||
|
splineStep: 0.02,
|
||||||
|
spacing: 10,
|
||||||
|
offsetDistance: 10,
|
||||||
|
protrusionLength: 15,
|
||||||
|
protrusionStartSize: 5,
|
||||||
|
protrusionEndSize: 5,
|
||||||
|
protrusionGap: 20,
|
||||||
|
style: RIGHT_SIDE,
|
||||||
|
};
|
||||||
|
|
||||||
|
const frontlineDataC = {
|
||||||
|
points: frontlinePointsC,
|
||||||
|
splineStep: 0.02,
|
||||||
|
spacing: 10,
|
||||||
|
offsetDistance: 10,
|
||||||
|
protrusionLength: 15,
|
||||||
|
protrusionStartSize: 5,
|
||||||
|
protrusionEndSize: 0,
|
||||||
|
protrusionGap: 20,
|
||||||
|
style: BOTH_SIDES,
|
||||||
|
};
|
||||||
|
|
||||||
const arrowDataA = {
|
const arrowDataA = {
|
||||||
points: pointsA,
|
points: pointsA,
|
||||||
density: 0.02,
|
splineStep: 0.02,
|
||||||
spacing: 20,
|
spacing: 20,
|
||||||
offsetDistance: 50
|
offsetDistance: 50
|
||||||
};
|
};
|
||||||
@ -60,7 +121,7 @@ const arrowDataA = {
|
|||||||
};
|
};
|
||||||
const arrowDataB = {
|
const arrowDataB = {
|
||||||
points: pointsB,
|
points: pointsB,
|
||||||
density: 0.02,
|
splineStep: 0.02,
|
||||||
spacing: 1,
|
spacing: 1,
|
||||||
offsetDistance: 80,
|
offsetDistance: 80,
|
||||||
};
|
};
|
||||||
@ -75,7 +136,7 @@ const arrowDataA = {
|
|||||||
};
|
};
|
||||||
const arrowDataC = {
|
const arrowDataC = {
|
||||||
points: pointsC,
|
points: pointsC,
|
||||||
density: 0.02,
|
splineStep: 0.02,
|
||||||
spacing: 5,
|
spacing: 5,
|
||||||
offsetDistance: 10,
|
offsetDistance: 10,
|
||||||
};
|
};
|
||||||
@ -83,6 +144,7 @@ const arrowDataA = {
|
|||||||
calculation: ARROW_BODY_STYLE_CONSTANT,
|
calculation: ARROW_BODY_STYLE_CONSTANT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const arrowPolygonA = getArrowPolygon(arrowDataA, styleA, arrowHeadDataA);
|
const arrowPolygonA = getArrowPolygon(arrowDataA, styleA, arrowHeadDataA);
|
||||||
const arrowPolygonB = getArrowPolygon(arrowDataB, styleB, arrowHeadDataB);
|
const arrowPolygonB = getArrowPolygon(arrowDataB, styleB, arrowHeadDataB);
|
||||||
const arrowPolygonC = getArrowPolygon(arrowDataC, styleC);
|
const arrowPolygonC = getArrowPolygon(arrowDataC, styleC);
|
||||||
@ -100,11 +162,36 @@ const mergedRectangle = mergeTurfPolygons(circlePolygon, circlePolygonB);
|
|||||||
const rectanglePoly = getRectanglePolygon(circleCenter, rectangleSideA, rectangleSideB, rectangleRotation*-1);
|
const rectanglePoly = getRectanglePolygon(circleCenter, rectangleSideA, rectangleSideB, rectangleRotation*-1);
|
||||||
const rectangleToTurfPoly = toTurfPolygon(rectanglePoly);
|
const rectangleToTurfPoly = toTurfPolygon(rectanglePoly);
|
||||||
|
|
||||||
console.log(mergedTurfPolyRectangle);
|
const frontlinePolygonA = getFrontline(frontlineDataA);
|
||||||
console.log(mergedRectangle);
|
let frontlinePolygonMergedA = mergeTurfPolygons(frontlinePolygonA.body,frontlinePolygonA.protrusions[0]);
|
||||||
|
for (let i = 1; i < frontlinePolygonA.protrusions.length; i++)
|
||||||
|
{
|
||||||
|
frontlinePolygonMergedA = addTurfPolygonToMerge(frontlinePolygonMergedA, frontlinePolygonA.protrusions[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const frontlinePolygonB = getFrontline(frontlineDataB);
|
||||||
|
let frontlinePolygonMergedB = mergeTurfPolygons(frontlinePolygonB.body,frontlinePolygonB.protrusions[0]);
|
||||||
|
for (let i = 1; i < frontlinePolygonB.protrusions.length; i++)
|
||||||
|
{
|
||||||
|
frontlinePolygonMergedB = addTurfPolygonToMerge(frontlinePolygonMergedB, frontlinePolygonB.protrusions[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const frontlinePolygonC = getFrontline(frontlineDataC);
|
||||||
|
|
||||||
|
let frontlinePolygonMergedLeft = mergeTurfPolygons(frontlinePolygonC.bodyLeft, frontlinePolygonC.protrusionsLeft[0]);
|
||||||
|
for (let i = 1; i < frontlinePolygonC.protrusionsLeft.length; i++) {
|
||||||
|
frontlinePolygonMergedLeft = addTurfPolygonToMerge(frontlinePolygonMergedLeft, frontlinePolygonC.protrusionsLeft[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
let frontlinePolygonMergedRight = mergeTurfPolygons(frontlinePolygonC.bodyRight, frontlinePolygonC.protrusionsRight[0]);
|
||||||
|
for (let i = 1; i < frontlinePolygonC.protrusionsRight.length; i++) {
|
||||||
|
frontlinePolygonMergedRight = addTurfPolygonToMerge(frontlinePolygonMergedRight, frontlinePolygonC.protrusionsRight[i]);
|
||||||
|
}
|
||||||
|
|
||||||
drawPolygon(mergedTurfPolyRectangle, "rgba(255, 0, 0, 0.5)", canvas);
|
drawPolygon(mergedTurfPolyRectangle, "rgba(255, 0, 0, 0.5)", canvas);
|
||||||
drawPolygon(mergedRectangle, "rgba(0, 255, 0, 0.5)", canvas);
|
drawPolygon(mergedRectangle, "rgba(0, 255, 0, 0.5)", canvas);
|
||||||
drawPolygon(rectangleToTurfPoly, "rgba(234, 0, 255, 0.5)", canvas);
|
drawPolygon(rectangleToTurfPoly, "rgba(234, 0, 255, 0.5)", canvas);
|
||||||
|
drawPolygon(frontlinePolygonMergedA, "rgba(0, 13, 255, 0.5)", canvas);
|
||||||
|
drawPolygon(frontlinePolygonMergedB, "rgba(82, 0, 94, 0.5)", canvas);
|
||||||
|
drawPolygon(frontlinePolygonMergedLeft, "rgba(255, 166, 0, 0.5)", canvas);
|
||||||
|
drawPolygon(frontlinePolygonMergedRight, "rgba(251, 0, 255, 0.5)", canvas);
|
||||||
2
package-lock.json
generated
2
package-lock.json
generated
@ -2718,7 +2718,7 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/athena-utils": {
|
"node_modules/athena-utils": {
|
||||||
"resolved": "git+https://git.projectathena.ca/andyaxxe/athena-utils.git#1fc49c63a2",
|
"resolved": "git+https://git.projectathena.ca/andyaxxe/athena-utils.git#03f16f45f2",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@turf/turf": "7.2.0"
|
"@turf/turf": "7.2.0"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user