mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
1.8 KiB
1.8 KiB
External Dependencies for features.js
The refactored features.js module requires the following external dependencies to be imported:
Module Dependencies
Lakes module
- Functions used:
Lakes.getHeight(feature)- Calculate height for lake featuresLakes.getName(feature)- Generate names for lake features
Utility Functions Required
The following utility functions need to be passed via the utils parameter:
Core Utilities
INT8_MAX- Maximum value for Int8 arraysrn(value)- Rounding functionisLand(cellId)- Check if a cell is landisWater(cellId)- Check if a cell is waterdist2(point1, point2)- Calculate squared distance between two pointsclipPoly(vertices)- Clip polygon verticesunique(array)- Remove duplicates from arraycreateTypedArray({maxValue, length})- Create appropriately typed arrayconnectVertices({vertices, startingVertex, ofSameType, closeRing})- Connect vertices to form paths
D3.js Integration
d3.polygonArea(points)- Calculate polygon area (accessed viautils.d3.polygonArea)
Configuration Dependencies
The following configuration values need to be passed via the config parameter:
Timing and Randomization
TIME- Boolean flag to enable/disable timing logsseed- Random seed value for reproducible generationaleaPRNG- Pseudo-random number generator function
Module Integration
The module should be imported and used as follows:
import { markupGrid, markupPack, specify } from './features.js';
import { Lakes } from './lakes.js';
// Usage example
const updatedGrid = markupGrid(grid, config, utils);
const updatedPack = markupPack(pack, grid, config, utils, { Lakes });
const finalPack = specify(updatedPack, grid, { Lakes });