3 Commits

Author SHA1 Message Date
Tomas Richtar
bdbdcb5397 Fix -> Style rework 2025-05-09 16:24:58 +02:00
Tomas Richtar
b4ebab5d54 Import fix 2025-05-04 11:51:39 +02:00
Tomas Richtar
0e7f5f4739 Added Linear and Exponential calculations 2025-05-04 11:31:59 +02:00
2 changed files with 72 additions and 31 deletions

View File

@@ -1,33 +1,14 @@
const canvas = document.getElementById("canvas"); const canvas = document.getElementById("canvas");
// Compute arrow polygon // Compute arrow polygon
import { getArrowPolygon } from "athena-utils/Arrow.js"; import { getArrowPolygon } from "athena-utils/shape/Arrow.js";
import { getCirclePolygon } from "athena-utils/BasicShapes.js"; import { ARROW_BODY_STYLE_CONSTANT, ARROW_BODY_STYLE_LINEAR, ARROW_BODY_STYLE_EXPONENTIAL } from "athena-utils/shape/Arrow.js";
import { getRectanglePolygon } from "athena-utils/BasicShapes.js"; import { getCirclePolygon } from "athena-utils/shape/BasicShapes.js";
import { getRectanglePolygon } from "athena-utils/shape/BasicShapes.js";
// Polygon merge using Turf library // Polygon merge using Turf library
import {mergeTurfPolygons} from "athena-utils/Polygon.js"; import {mergeTurfPolygons} from "athena-utils/shape/Polygon.js";
import {addTurfPolygonToMerge} from "athena-utils/Polygon.js"; import {addTurfPolygonToMerge} from "athena-utils/shape/Polygon.js";
import {toTurfPolygon} from "athena-utils/Polygon.js"; import {toTurfPolygon} from "athena-utils/shape/Polygon.js";
import {drawPolygon} from "athena-utils/PolygonVisuals.js"; import {drawPolygon} from "athena-utils/shape/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 circleCenter = {x:320, y:180}; const circleCenter = {x:320, y:180};
const circleRadius = 70; const circleRadius = 70;
@@ -42,9 +23,69 @@ const rectangleSideA = 70;
const rectangleSideB = 200; const rectangleSideB = 200;
const rectangleRotation = 40; const rectangleRotation = 40;
const arrowPolygonA = getArrowPolygon(points, 0.02, 50, 10, true, 40, 35); const pointsA = [
const arrowPolygonB = getArrowPolygon(pointsB, 0.02, 10, 10, true, 40, 35); { x: 50, y: 400 },
const arrowPolygonC = getArrowPolygon(pointsC, 0.02, 50, 10, false, 40, 35); { x: 150, y: 100 },
{ x: 300, y: 200 },
{ x: 300, y: 400 },
];
const pointsB = [
{ x: 310, y: 300 },
{ x: 380, y: 350 },
{ x: 450, y: 450 },
{ x: 650, y: 430 }
];
const pointsC = [
{ x: 50, y: 100 },
{ x: 100, y: 100 },
{ x: 180, y: 95 }
];
const arrowDataA = {
points: pointsA,
density: 0.02,
spacing: 20,
offsetDistance: 50
};
const styleA = {
calculation: ARROW_BODY_STYLE_LINEAR,
range: 1,
minValue: 0.1
};
const arrowHeadDataA = {
widthArrow: 40,
lengthArrow: 35
};
const arrowDataB = {
points: pointsB,
density: 0.02,
spacing: 1,
offsetDistance: 80,
};
const styleB = {
calculation: ARROW_BODY_STYLE_EXPONENTIAL,
range: 5,
minValue: 0.1
};
const arrowHeadDataB = {
widthArrow: 40,
lengthArrow: 35
};
const arrowDataC = {
points: pointsC,
density: 0.02,
spacing: 5,
offsetDistance: 10,
};
const styleC = {
calculation: ARROW_BODY_STYLE_CONSTANT,
};
const arrowPolygonA = getArrowPolygon(arrowDataA, styleA, arrowHeadDataA);
const arrowPolygonB = getArrowPolygon(arrowDataB, styleB, arrowHeadDataB);
const arrowPolygonC = getArrowPolygon(arrowDataC, styleC);
const circlePolygon = getCirclePolygon(circleCenter, circleRadius, circleDensity); const circlePolygon = getCirclePolygon(circleCenter, circleRadius, circleDensity);
const circlePolygonB = getCirclePolygon(circleCenterB, circleRadiusB, circleDensityB); const circlePolygonB = getCirclePolygon(circleCenterB, circleRadiusB, circleDensityB);

2
package-lock.json generated
View File

@@ -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#7f60a2dac4990ff675ca659b1d9dd97dc2074149", "resolved": "git+https://git.projectathena.ca/andyaxxe/athena-utils.git#1fc49c63a2",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@turf/turf": "7.2.0" "@turf/turf": "7.2.0"