mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
refactor(es modules): migrate numberUtils
This commit is contained in:
parent
b425a9daf6
commit
ad252b54e6
63 changed files with 97 additions and 56 deletions
|
|
@ -1,10 +1,16 @@
|
|||
import {TIME} from "../config/logging";
|
||||
import {createTypedArray} from "./arrayUtils";
|
||||
import {rn} from "./numberUtils";
|
||||
import {byId} from "./shorthands";
|
||||
|
||||
const Delaunator = window.Delaunator;
|
||||
const Voronoi = window.Voronoi;
|
||||
const graphWidth = window.graphWidth;
|
||||
const graphHeight = window.graphHeight;
|
||||
|
||||
// check if new grid graph should be generated or we can use the existing one
|
||||
export function shouldRegenerateGrid(grid) {
|
||||
const cellsDesired = +byId("pointsInput").dataset.cells;
|
||||
const cellsDesired = Number(byId("pointsInput")?.dataset.cells);
|
||||
if (cellsDesired !== grid.cellsDesired) return true;
|
||||
|
||||
const newSpacing = rn(Math.sqrt((graphWidth * graphHeight) / cellsDesired), 2);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue