StorymapperArrow fixed

This commit is contained in:
Tomas Richtar
2025-03-28 20:55:10 +01:00
parent 2e67a699fb
commit ab2b2a6956
10 changed files with 3395 additions and 0 deletions

39
ArrowPoints.js Normal file
View File

@@ -0,0 +1,39 @@
const canvas = document.getElementById("canvas");
// Compute arrow polygon
import { computeAll } from "athena-utils/Arrow.js";
// Polygon merge using Turf library
import {mergeTurfPolygons} from "athena-utils/Polygon.js";
import {addTurfPolygonToMerge} from "athena-utils/Polygon.js";
import {drawPolygon} from "athena-utils/PolygonVisuals.js";
const points = [
{ x: 50, y: 400 },
{ x: 150, y: 100 },
{ x: 300, y: 200 },
{ x: 300, y: 400 },
];
const pointsB = [
{ x: 310, y: 300 },
{ x: 380, y: 350 },
{ x: 400, y: 300 },
{ x: 450, y: 330 }
];
const pointsC = [
{ x: 50, y: 100 },
{ x: 100, y: 100 },
{ x: 180, y: 95 }
];
const arrowPolygonA = computeAll(points, 0.02, 50, 10, true, 40, 35);
const arrowPolygonB = computeAll(pointsB, 0.02, 10, 10, true, 40, 35);
const arrowPolygonC = computeAll(pointsC, 0.02, 50, 10, false, 40, 35);
const mergedTurfPoly = mergeTurfPolygons(arrowPolygonA, arrowPolygonC);
const mergedTurfPolyAll = addTurfPolygonToMerge(mergedTurfPoly, arrowPolygonB);
console.log(mergedTurfPolyAll);
drawPolygon(mergedTurfPolyAll, "rgba(255, 0, 0, 0.5)", canvas);