mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-03-23 07:37:24 +01:00
fix: type issues
This commit is contained in:
parent
54ba228fb6
commit
064e4d83e3
11 changed files with 21 additions and 22 deletions
3
package-lock.json
generated
3
package-lock.json
generated
|
|
@ -9,7 +9,6 @@
|
|||
"version": "1.113.5",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/lineclip": "^2.0.0",
|
||||
"alea": "^1.0.1",
|
||||
"d3": "^7.9.0",
|
||||
"delaunator": "^5.0.1",
|
||||
|
|
@ -21,6 +20,7 @@
|
|||
"@playwright/test": "^1.57.0",
|
||||
"@types/d3": "^7.4.3",
|
||||
"@types/delaunator": "^5.0.3",
|
||||
"@types/lineclip": "^2.0.0",
|
||||
"@types/node": "^25.0.10",
|
||||
"@types/polylabel": "^1.1.3",
|
||||
"@vitest/browser": "^4.0.18",
|
||||
|
|
@ -1353,6 +1353,7 @@
|
|||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/lineclip/-/lineclip-2.0.0.tgz",
|
||||
"integrity": "sha512-LsPRWfV5kC41YgraYhnAMNSNhdJwFlCsUPueSw7sG5UvMqSMxMcaOA9LWN8mZiCUe9jVIAKnLfsNiXpvnd7gKQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
"@playwright/test": "^1.57.0",
|
||||
"@types/d3": "^7.4.3",
|
||||
"@types/delaunator": "^5.0.3",
|
||||
"@types/lineclip": "^2.0.0",
|
||||
"@types/node": "^25.0.10",
|
||||
"@types/polylabel": "^1.1.3",
|
||||
"@vitest/browser": "^4.0.18",
|
||||
|
|
@ -38,7 +39,6 @@
|
|||
"vitest": "^4.0.18"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/lineclip": "^2.0.0",
|
||||
"alea": "^1.0.1",
|
||||
"d3": "^7.9.0",
|
||||
"delaunator": "^5.0.1",
|
||||
|
|
|
|||
|
|
@ -1304,7 +1304,7 @@ class CulturesModule {
|
|||
cells.culture[cellId] = 0;
|
||||
}
|
||||
} else {
|
||||
cells.culture = new Uint16Array(cells.i.length) as unknown as number[];
|
||||
cells.culture = new Uint16Array(cells.i.length);
|
||||
}
|
||||
|
||||
for (const culture of cultures) {
|
||||
|
|
|
|||
|
|
@ -234,6 +234,8 @@ class FeatureModule {
|
|||
const [startCell, featureVertices] = getCellsData(type, firstCell);
|
||||
const points = clipPoly(
|
||||
featureVertices.map((vertex: number) => vertices.p[vertex]),
|
||||
graphWidth,
|
||||
graphHeight,
|
||||
);
|
||||
const area = polygonArea(points); // feature perimiter area
|
||||
const absArea = Math.abs(rn(area));
|
||||
|
|
|
|||
|
|
@ -59,14 +59,12 @@ class Resampler {
|
|||
grid.cells.temp = new Int8Array(grid.points.length);
|
||||
grid.cells.prec = new Uint8Array(grid.points.length);
|
||||
|
||||
const parentPackQ = quadtree(parentMap.pack.cells.p.map(([x, y], i) => [x, y, i]));
|
||||
const parentPackQ = quadtree(
|
||||
parentMap.pack.cells.p.map(([x, y], i) => [x, y, i]),
|
||||
);
|
||||
grid.points.forEach(([x, y]: [number, number], newGridCell: number) => {
|
||||
const [parentX, parentY] = inverse(x, y);
|
||||
const parentPackCell = parentPackQ.find(
|
||||
parentX,
|
||||
parentY,
|
||||
Infinity,
|
||||
)?.[2];
|
||||
const parentPackCell = parentPackQ.find(parentX, parentY, Infinity)?.[2];
|
||||
if (parentPackCell === undefined) return;
|
||||
const parentGridCell = parentMap.pack.cells.g[parentPackCell];
|
||||
|
||||
|
|
@ -441,16 +439,14 @@ class Resampler {
|
|||
parentMap: ParentMapDefinition,
|
||||
inverse: (x: number, y: number) => [number, number],
|
||||
) {
|
||||
const parentPackQ = quadtree(parentMap.pack.cells.p.map(([x, y], i) => [x, y, i]));
|
||||
const parentPackQ = quadtree(
|
||||
parentMap.pack.cells.p.map(([x, y], i) => [x, y, i]),
|
||||
);
|
||||
pack.features.forEach((feature) => {
|
||||
if (!feature) return;
|
||||
const [x, y] = pack.cells.p[feature.firstCell];
|
||||
const [parentX, parentY] = inverse(x, y);
|
||||
const parentCell = parentPackQ.find(
|
||||
parentX,
|
||||
parentY,
|
||||
Infinity,
|
||||
)?.[2];
|
||||
const parentCell = parentPackQ.find(parentX, parentY, Infinity)?.[2];
|
||||
if (parentCell === undefined) return;
|
||||
const parentFeature =
|
||||
parentMap.pack.features[parentMap.pack.cells.f[parentCell]];
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ function featurePathRenderer(feature: PackedGraphFeature): string {
|
|||
}
|
||||
|
||||
const simplifiedPoints = simplify(points, 0.3);
|
||||
const clippedPoints = clipPoly(simplifiedPoints, graphWidth, graphHeight, 1);
|
||||
const clippedPoints = clipPoly(simplifiedPoints, graphWidth, graphHeight);
|
||||
|
||||
const lineGen = line().curve(curveBasisClosed);
|
||||
const path = `${round(lineGen(clippedPoints) || "")}Z`;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { curveNatural, line, max, select } from "d3";
|
||||
import type { TypedArray } from "../types/PackedGraph";
|
||||
import {
|
||||
drawPath,
|
||||
drawPoint,
|
||||
|
|
@ -400,7 +401,7 @@ const stateLabelsRenderer = (list?: number[]): void => {
|
|||
angleRad: number,
|
||||
halfwidth: number,
|
||||
halfheight: number,
|
||||
stateIds: number[],
|
||||
stateIds: TypedArray,
|
||||
stateId: number,
|
||||
): boolean {
|
||||
const bbox = textElement.getBBox();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import type { Route } from "../modules/routes-generator";
|
|||
import type { State } from "../modules/states-generator";
|
||||
import type { Zone } from "../modules/zones-generator";
|
||||
|
||||
type TypedArray =
|
||||
export type TypedArray =
|
||||
| Uint8Array
|
||||
| Uint16Array
|
||||
| Uint32Array
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import { rand } from "./probabilityUtils";
|
|||
* @param points - Array of points [[x1, y1], [x2, y2], ...]
|
||||
* @param graphWidth - Width of the graph
|
||||
* @param graphHeight - Height of the graph
|
||||
* @param secure - Secure clipping to avoid edge artifacts
|
||||
* @returns Clipped polygon points
|
||||
*/
|
||||
export const clipPoly = (
|
||||
|
|
|
|||
|
|
@ -228,8 +228,8 @@ import {
|
|||
wiki,
|
||||
} from "./commonUtils";
|
||||
|
||||
window.clipPoly = (points: [number, number][], secure?: number) =>
|
||||
clipPoly(points, graphWidth, graphHeight, secure);
|
||||
window.clipPoly = (points: [number, number][]) =>
|
||||
clipPoly(points, graphWidth, graphHeight);
|
||||
window.getSegmentId = getSegmentId;
|
||||
window.debounce = debounce;
|
||||
window.throttle = throttle;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue