mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-02-04 17:41:23 +01:00
chore: add biome for linting/formatting + CI action for linting in SRC folder (#1284)
* chore: add npm + vite for progressive enhancement * fix: update Dockerfile to copy only the dist folder contents * fix: update Dockerfile to use multi-stage build for optimized production image * fix: correct nginx config file copy command in Dockerfile * chore: add netlify configuration for build and redirects * fix: add NODE_VERSION to environment in Netlify configuration * remove wrong dist folder * Update package.json Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: split public and src * migrating all util files from js to ts * feat: Implement HeightmapGenerator and Voronoi module - Added HeightmapGenerator class for generating heightmaps with various tools (Hill, Pit, Range, Trough, Strait, etc.). - Introduced Voronoi class for creating Voronoi diagrams using Delaunator. - Updated index.html to include new modules. - Created index.ts to manage module imports. - Enhanced arrayUtils and graphUtils with type definitions and improved functionality. - Added utility functions for generating grids and calculating Voronoi cells. * chore: add GitHub Actions workflow for deploying to GitHub Pages * fix: update branch name in GitHub Actions workflow from 'main' to 'master' * chore: update package.json to specify Node.js engine version and remove unused launch.json * Initial plan * Update copilot guidelines to reflect NPM/Vite/TypeScript migration Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com> * Update src/modules/heightmap-generator.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/utils/graphUtils.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/heightmap-generator.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat: Add TIME and ERROR variables to global scope in HeightmapGenerator * fix: Update base path in vite.config.ts for Netlify deployment * refactor: Migrate features to a new module and remove legacy script reference * refactor: Update feature interfaces and improve type safety in FeatureModule * refactor: Add documentation for markupPack and defineGroups methods in FeatureModule * refactor: Remove legacy ocean-layers.js and migrate functionality to ocean-layers.ts * refactor: Remove river-generator.js script reference and migrate river generation logic to river-generator.ts * refactor: Remove river-generator.js reference and add biomes module * refactor: Migrate lakes functionality to lakes.ts and update related interfaces * refactor: clean up global variable declarations and improve type definitions * refactor: update shoreline calculation and improve type imports in PackedGraph * fix: e2e tests * chore: add biome for linting/formatting * chore: add linting workflow using Biome * refactor: improve code readability by standardizing string quotes and simplifying function calls --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Azgaar <maxganiev@yandex.com> Co-authored-by: Azgaar <azgaar.fmg@yandex.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
This commit is contained in:
parent
e37fce1eed
commit
9db40a5230
31 changed files with 2001 additions and 782 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import {curveBundle, line, max, min} from "d3";
|
||||
import { normalize } from "./numberUtils";
|
||||
import { getGridPolygon } from "./graphUtils";
|
||||
import { curveBundle, line, max, min } from "d3";
|
||||
import { C_12 } from "./colorUtils";
|
||||
import { getGridPolygon } from "./graphUtils";
|
||||
import { normalize } from "./numberUtils";
|
||||
import { round } from "./stringUtils";
|
||||
|
||||
/**
|
||||
|
|
@ -19,7 +19,7 @@ export const drawCellsValue = (data: any[], packedGraph: any): void => {
|
|||
.attr("x", (_d: any, i: number) => packedGraph.cells.p[i][0])
|
||||
.attr("y", (_d: any, i: number) => packedGraph.cells.p[i][1])
|
||||
.text((d: any) => d);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Drawing polygons colored according to data values for debugging purposes
|
||||
* @param {number[]} data - Array of numerical values corresponding to each cell
|
||||
|
|
@ -28,9 +28,11 @@ export const drawCellsValue = (data: any[], packedGraph: any): void => {
|
|||
export const drawPolygons = (data: number[], terrs: any, grid: any): void => {
|
||||
const maximum: number = max(data) as number;
|
||||
const minimum: number = min(data) as number;
|
||||
const scheme = window.getColorScheme(terrs.select("#landHeights").attr("scheme"));
|
||||
const scheme = window.getColorScheme(
|
||||
terrs.select("#landHeights").attr("scheme"),
|
||||
);
|
||||
|
||||
data = data.map(d => 1 - normalize(d, minimum, maximum));
|
||||
data = data.map((d) => 1 - normalize(d, minimum, maximum));
|
||||
window.debug.selectAll("polygon").remove();
|
||||
window.debug
|
||||
.selectAll("polygon")
|
||||
|
|
@ -40,7 +42,7 @@ export const drawPolygons = (data: number[], terrs: any, grid: any): void => {
|
|||
.attr("points", (_d: number, i: number) => getGridPolygon(i, grid))
|
||||
.attr("fill", (d: number) => scheme(d))
|
||||
.attr("stroke", (d: number) => scheme(d));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Drawing route connections for debugging purposes
|
||||
|
|
@ -48,7 +50,10 @@ export const drawPolygons = (data: number[], terrs: any, grid: any): void => {
|
|||
*/
|
||||
export const drawRouteConnections = (packedGraph: any): void => {
|
||||
window.debug.select("#connections").remove();
|
||||
const routes = window.debug.append("g").attr("id", "connections").attr("stroke-width", 0.8);
|
||||
const routes = window.debug
|
||||
.append("g")
|
||||
.attr("id", "connections")
|
||||
.attr("stroke-width", 0.8);
|
||||
|
||||
const points = packedGraph.cells.p;
|
||||
const links = packedGraph.cells.routes;
|
||||
|
|
@ -70,7 +75,7 @@ export const drawRouteConnections = (packedGraph: any): void => {
|
|||
.attr("stroke", C_12[routeId % 12]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Drawing a point for debugging purposes
|
||||
|
|
@ -79,9 +84,17 @@ export const drawRouteConnections = (packedGraph: any): void => {
|
|||
* @param {string} options.color - Color of the point
|
||||
* @param {number} options.radius - Radius of the point
|
||||
*/
|
||||
export const drawPoint = ([x, y]: [number, number], {color = "red", radius = 0.5}): void => {
|
||||
window.debug.append("circle").attr("cx", x).attr("cy", y).attr("r", radius).attr("fill", color);
|
||||
}
|
||||
export const drawPoint = (
|
||||
[x, y]: [number, number],
|
||||
{ color = "red", radius = 0.5 },
|
||||
): void => {
|
||||
window.debug
|
||||
.append("circle")
|
||||
.attr("cx", x)
|
||||
.attr("cy", y)
|
||||
.attr("r", radius)
|
||||
.attr("fill", color);
|
||||
};
|
||||
|
||||
/**
|
||||
* Drawing a path for debugging purposes
|
||||
|
|
@ -90,7 +103,10 @@ export const drawPoint = ([x, y]: [number, number], {color = "red", radius = 0.5
|
|||
* @param {string} options.color - Color of the path
|
||||
* @param {number} options.width - Stroke width of the path
|
||||
*/
|
||||
export const drawPath = (points: [number, number][], {color = "red", width = 0.5}): void => {
|
||||
export const drawPath = (
|
||||
points: [number, number][],
|
||||
{ color = "red", width = 0.5 },
|
||||
): void => {
|
||||
const lineGen = line().curve(curveBundle);
|
||||
window.debug
|
||||
.append("path")
|
||||
|
|
@ -98,17 +114,17 @@ export const drawPath = (points: [number, number][], {color = "red", width = 0.5
|
|||
.attr("stroke", color)
|
||||
.attr("stroke-width", width)
|
||||
.attr("fill", "none");
|
||||
}
|
||||
};
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
debug: any;
|
||||
getColorScheme: (name: string) => (t: number) => string;
|
||||
|
||||
|
||||
drawCellsValue: typeof drawCellsValue;
|
||||
drawPolygons: typeof drawPolygons;
|
||||
drawRouteConnections: typeof drawRouteConnections;
|
||||
drawPoint: typeof drawPoint;
|
||||
drawPath: typeof drawPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue