mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
refactor(es modules): continue migration
This commit is contained in:
parent
bc65e0e207
commit
97f2b213c4
42 changed files with 252 additions and 222 deletions
BIN
.DS_Store
vendored
Normal file
BIN
.DS_Store
vendored
Normal file
Binary file not shown.
86
index.html
86
index.html
|
|
@ -7795,13 +7795,12 @@
|
||||||
<script type="module" src="modules/military-generator.js"></script>
|
<script type="module" src="modules/military-generator.js"></script>
|
||||||
<script type="module" src="modules/markers-generator.js"></script>
|
<script type="module" src="modules/markers-generator.js"></script>
|
||||||
<script type="module" src="modules/coa-generator.js"></script>
|
<script type="module" src="modules/coa-generator.js"></script>
|
||||||
<script src="modules/submap.js"></script>
|
<script type="module" src="modules/submap.js"></script>
|
||||||
<script src="libs/polylabel.min.js"></script>
|
<script src="libs/polylabel.min.js"></script>
|
||||||
<script src="libs/lineclip.min.js"></script>
|
<script src="libs/lineclip.min.js"></script>
|
||||||
<script src="libs/alea.min.js"></script>
|
<script src="libs/alea.min.js"></script>
|
||||||
<script src="modules/fonts.js"></script>
|
<script src="modules/fonts.js"></script>
|
||||||
<script type="module" src="modules/ui/layers.js"></script>
|
<script type="module" src="modules/ui/layers.js"></script>
|
||||||
<script src="modules/ui/measurers.js?v=1.87.02"></script>
|
|
||||||
<script src="modules/ui/stylePresets.js"></script>
|
<script src="modules/ui/stylePresets.js"></script>
|
||||||
<script type="module" src="modules/ui/general.js?v=1.87.00"></script>
|
<script type="module" src="modules/ui/general.js?v=1.87.00"></script>
|
||||||
<script type="module" src="modules/ui/options.js?v=1.87.00"></script>
|
<script type="module" src="modules/ui/options.js?v=1.87.00"></script>
|
||||||
|
|
@ -7813,53 +7812,54 @@
|
||||||
<script type="module" src="/src/main.ts"></script>
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
|
||||||
<script type="module" src="modules/activeZooming.js"></script>
|
<script type="module" src="modules/activeZooming.js"></script>
|
||||||
<script defer src="modules/relief-icons.js"></script>
|
<script type="module" src="modules/relief-icons.js"></script>
|
||||||
<script type="module" src="modules/ui/style.js"></script>
|
<script type="module" src="modules/ui/style.js"></script>
|
||||||
<script defer src="modules/ui/editors.js?v=1.87.01"></script>
|
<script type="module" src="modules/ui/editors.js?v=1.87.01"></script>
|
||||||
<script defer src="modules/ui/tools.js?v=1.87.03"></script>
|
<script type="module" src="modules/ui/tools.js?v=1.87.03"></script>
|
||||||
<script defer src="modules/ui/world-configurator.js"></script>
|
<script type="module" src="modules/ui/world-configurator.js"></script>
|
||||||
<script defer src="modules/ui/heightmap-editor.js"></script>
|
<script type="module" src="modules/ui/heightmap-editor.js"></script>
|
||||||
<script defer src="modules/ui/provinces-editor.js"></script>
|
<script type="module" src="modules/ui/provinces-editor.js"></script>
|
||||||
<script defer src="modules/ui/biomes-editor.js"></script>
|
<script type="module" src="modules/ui/biomes-editor.js"></script>
|
||||||
<script defer src="modules/ui/namesbase-editor.js"></script>
|
<script type="module" src="modules/ui/namesbase-editor.js"></script>
|
||||||
<script defer src="modules/ui/elevation-profile.js"></script>
|
<script type="module" src="modules/ui/elevation-profile.js"></script>
|
||||||
<script defer src="modules/ui/temperature-graph.js"></script>
|
<script type="module" src="modules/ui/temperature-graph.js"></script>
|
||||||
<script defer src="modules/ui/routes-editor.js"></script>
|
<script type="module" src="modules/ui/routes-editor.js"></script>
|
||||||
<script defer src="modules/ui/ice-editor.js"></script>
|
<script type="module" src="modules/ui/ice-editor.js"></script>
|
||||||
<script defer src="modules/ui/lakes-editor.js"></script>
|
<script type="module" src="modules/ui/lakes-editor.js"></script>
|
||||||
<script defer src="modules/ui/coastline-editor.js"></script>
|
<script type="module" src="modules/ui/coastline-editor.js"></script>
|
||||||
<script defer src="modules/ui/labels-editor.js"></script>
|
<script type="module" src="modules/ui/labels-editor.js"></script>
|
||||||
<script defer src="modules/ui/rivers-editor.js"></script>
|
<script type="module" src="modules/ui/rivers-editor.js"></script>
|
||||||
<script defer src="modules/ui/rivers-creator.js"></script>
|
<script type="module" src="modules/ui/rivers-creator.js"></script>
|
||||||
<script defer src="modules/ui/relief-editor.js"></script>
|
<script type="module" src="modules/ui/relief-editor.js"></script>
|
||||||
<script defer src="modules/ui/burg-editor.js"></script>
|
<script type="module" src="modules/ui/burg-editor.js"></script>
|
||||||
<script defer src="modules/ui/units-editor.js"></script>
|
<script type="module" src="modules/ui/units-editor.js"></script>
|
||||||
<script type="module" src="modules/ui/notes-editor.js"></script>
|
<script type="module" src="modules/ui/notes-editor.js"></script>
|
||||||
<script defer src="modules/ui/diplomacy-editor.js"></script>
|
<script type="module" src="modules/ui/diplomacy-editor.js"></script>
|
||||||
<script defer src="modules/ui/zones-editor.js"></script>
|
<script type="module" src="modules/ui/zones-editor.js"></script>
|
||||||
<script defer src="modules/ui/burgs-overview.js"></script>
|
<script type="module" src="modules/ui/burgs-overview.js"></script>
|
||||||
<script defer src="modules/ui/rivers-overview.js"></script>
|
<script type="module" src="modules/ui/rivers-overview.js"></script>
|
||||||
<script defer src="modules/ui/military-overview.js"></script>
|
<script type="module" src="modules/ui/military-overview.js"></script>
|
||||||
<script defer src="modules/ui/regiments-overview.js"></script>
|
<script type="module" src="modules/ui/regiments-overview.js"></script>
|
||||||
<script defer src="modules/ui/markers-overview.js"></script>
|
<script type="module" src="modules/ui/markers-overview.js"></script>
|
||||||
<script defer src="modules/ui/regiment-editor.js"></script>
|
<script type="module" src="modules/ui/regiment-editor.js"></script>
|
||||||
<script defer src="modules/ui/battle-screen.js"></script>
|
<script type="module" src="modules/ui/battle-screen.js"></script>
|
||||||
<script defer src="modules/ui/emblems-editor.js"></script>
|
<script type="module" src="modules/ui/emblems-editor.js"></script>
|
||||||
<script defer src="modules/ui/markers-editor.js"></script>
|
<script type="module" src="modules/ui/markers-editor.js"></script>
|
||||||
<script defer src="modules/ui/3d.js"></script>
|
<script type="module" src="modules/ui/3d.js"></script>
|
||||||
<script defer src="modules/ui/submap.js"></script>
|
<script type="module" src="modules/ui/submap.js"></script>
|
||||||
<script defer src="modules/ui/hotkeys.js?v=1.87.00"></script>
|
<script type="module" src="modules/ui/hotkeys.js?v=1.87.00"></script>
|
||||||
<script defer src="modules/coa-renderer.js"></script>
|
<script type="module" src="modules/coa-renderer.js"></script>
|
||||||
<script defer src="libs/rgbquant.min.js"></script>
|
<script defer src="libs/rgbquant.min.js"></script>
|
||||||
<script defer src="libs/jquery.ui.touch-punch.min.js"></script>
|
<script defer src="libs/jquery.ui.touch-punch.min.js"></script>
|
||||||
|
|
||||||
<script defer src="modules/io/save.js"></script>
|
<script type="module" src="modules/io/save.js"></script>
|
||||||
<script defer src="modules/io/load.js?v=1.87.00"></script>
|
<script type="module" src="modules/io/load.js?v=1.87.00"></script>
|
||||||
<script defer src="modules/io/cloud.js"></script>
|
<script type="module" src="modules/io/cloud.js"></script>
|
||||||
<script defer src="modules/io/export.js"></script>
|
<script type="module" src="modules/io/export.js"></script>
|
||||||
<script defer src="modules/io/formats.js"></script>
|
<script type="module" src="modules/io/formats.js"></script>
|
||||||
|
|
||||||
<!-- Web Components -->
|
<!-- Web Components -->
|
||||||
<script defer src="components/fill-box.js"></script>
|
<script src="components/fill-box.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
f
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
"use strict";
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
|
|
||||||
// update old .map version to the current one
|
// update old .map version to the current one
|
||||||
export function resolveVersionConflicts(version) {
|
export function resolveVersionConflicts(version) {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
||||||
|
|
||||||
const $body = insertEditorHtml();
|
const $body = insertEditorHtml();
|
||||||
addListeners();
|
addListeners();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
||||||
|
|
||||||
const $body = insertEditorHtml();
|
const $body = insertEditorHtml();
|
||||||
addListeners();
|
addListeners();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
||||||
|
|
||||||
const $body = insertEditorHtml();
|
const $body = insertEditorHtml();
|
||||||
addListeners();
|
addListeners();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {shouldRegenerateGrid, generateGrid} from "/src/utils/graphUtils";
|
||||||
|
|
||||||
const initialSeed = generateSeed();
|
const initialSeed = generateSeed();
|
||||||
let graph = getGraph(grid);
|
let graph = getGraph(grid);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import {rollups} from "../../../utils/functionUtils.js";
|
import {rollups} from "../../../utils/functionUtils.js";
|
||||||
|
import {isWater} from "/src/utils/graphUtils";
|
||||||
|
|
||||||
const entitiesMap = {
|
const entitiesMap = {
|
||||||
states: {
|
states: {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import {TIME} from "/src/config/logging";
|
import {TIME} from "/src/config/logging";
|
||||||
import {createTypedArray} from "/src/utils";
|
import {createTypedArray} from "/src/utils/arrayUtils";
|
||||||
import {findGridCell} from "/src/utils/graphUtils";
|
import {findGridCell} from "/src/utils/graphUtils";
|
||||||
|
|
||||||
window.HeightmapGenerator = (function () {
|
window.HeightmapGenerator = (function () {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
"use strict";
|
import {getGridPolygon} from "/src/utils/graphUtils";
|
||||||
// Functions to export map to image or data files
|
|
||||||
|
|
||||||
// download map as SVG
|
// download map as SVG
|
||||||
async function saveSVG() {
|
async function saveSVG() {
|
||||||
|
|
@ -10,7 +9,12 @@ async function saveSVG() {
|
||||||
link.href = url;
|
link.href = url;
|
||||||
link.click();
|
link.click();
|
||||||
|
|
||||||
tip(`${link.download} is saved. Open "Downloads" screen (crtl + J) to check. You can set image scale in options`, true, "success", 5000);
|
tip(
|
||||||
|
`${link.download} is saved. Open "Downloads" screen (crtl + J) to check. You can set image scale in options`,
|
||||||
|
true,
|
||||||
|
"success",
|
||||||
|
5000
|
||||||
|
);
|
||||||
TIME && console.timeEnd("saveSVG");
|
TIME && console.timeEnd("saveSVG");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,7 +40,12 @@ async function savePNG() {
|
||||||
window.setTimeout(function () {
|
window.setTimeout(function () {
|
||||||
canvas.remove();
|
canvas.remove();
|
||||||
window.URL.revokeObjectURL(link.href);
|
window.URL.revokeObjectURL(link.href);
|
||||||
tip(`${link.download} is saved. Open "Downloads" screen (crtl + J) to check. You can set image scale in options`, true, "success", 5000);
|
tip(
|
||||||
|
`${link.download} is saved. Open "Downloads" screen (crtl + J) to check. You can set image scale in options`,
|
||||||
|
true,
|
||||||
|
"success",
|
||||||
|
5000
|
||||||
|
);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -140,7 +149,15 @@ async function saveTiles() {
|
||||||
|
|
||||||
// parse map svg to object url
|
// parse map svg to object url
|
||||||
async function getMapURL(type, options = {}) {
|
async function getMapURL(type, options = {}) {
|
||||||
const {debug = false, globe = false, noLabels = false, noWater = false, noScaleBar = false, noIce = false, fullMap = false} = options;
|
const {
|
||||||
|
debug = false,
|
||||||
|
globe = false,
|
||||||
|
noLabels = false,
|
||||||
|
noWater = false,
|
||||||
|
noScaleBar = false,
|
||||||
|
noIce = false,
|
||||||
|
fullMap = false
|
||||||
|
} = options;
|
||||||
|
|
||||||
if (fullMap) drawScaleBar(1);
|
if (fullMap) drawScaleBar(1);
|
||||||
|
|
||||||
|
|
@ -315,7 +332,8 @@ async function getMapURL(type, options = {}) {
|
||||||
|
|
||||||
clone.remove();
|
clone.remove();
|
||||||
|
|
||||||
const serialized = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>` + new XMLSerializer().serializeToString(cloneEl);
|
const serialized =
|
||||||
|
`<?xml version="1.0" encoding="UTF-8" standalone="no"?>` + new XMLSerializer().serializeToString(cloneEl);
|
||||||
const blob = new Blob([serialized], {type: "image/svg+xml;charset=utf-8"});
|
const blob = new Blob([serialized], {type: "image/svg+xml;charset=utf-8"});
|
||||||
const url = window.URL.createObjectURL(blob);
|
const url = window.URL.createObjectURL(blob);
|
||||||
window.setTimeout(() => window.URL.revokeObjectURL(url), 5000);
|
window.setTimeout(() => window.URL.revokeObjectURL(url), 5000);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
"use strict";
|
import {calculateVoronoi, findCell} from "/src/utils/graphUtils";
|
||||||
// Functions to load and parse .map files
|
|
||||||
|
|
||||||
function quickLoad() {
|
function quickLoad() {
|
||||||
ldb.get("lastMap", blob => {
|
ldb.get("lastMap", blob => {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import {TIME} from "/src/config/logging";
|
import {TIME} from "/src/config/logging";
|
||||||
|
import {getFriendlyHeight} from "./ui/general";
|
||||||
|
|
||||||
window.Markers = (function () {
|
window.Markers = (function () {
|
||||||
let config = [];
|
let config = [];
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
"use strict";
|
import {getPackPolygon} from "/src/utils/graphUtils";
|
||||||
|
|
||||||
window.ReliefIcons = (function () {
|
window.ReliefIcons = (function () {
|
||||||
const ReliefIcons = function () {
|
const ReliefIcons = function () {
|
||||||
|
|
@ -124,5 +124,67 @@ window.ReliefIcons = (function () {
|
||||||
return "#relief-" + getOldIcon(type) + "-1"; // simple
|
return "#relief-" + getOldIcon(type) + "-1"; // simple
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mbostock's poissonDiscSampler
|
||||||
|
function* poissonDiscSampler(x0, y0, x1, y1, r, k = 3) {
|
||||||
|
if (!(x1 >= x0) || !(y1 >= y0) || !(r > 0)) throw new Error();
|
||||||
|
|
||||||
|
const width = x1 - x0;
|
||||||
|
const height = y1 - y0;
|
||||||
|
const r2 = r * r;
|
||||||
|
const r2_3 = 3 * r2;
|
||||||
|
const cellSize = r * Math.SQRT1_2;
|
||||||
|
const gridWidth = Math.ceil(width / cellSize);
|
||||||
|
const gridHeight = Math.ceil(height / cellSize);
|
||||||
|
const grid = new Array(gridWidth * gridHeight);
|
||||||
|
const queue = [];
|
||||||
|
|
||||||
|
function far(x, y) {
|
||||||
|
const i = (x / cellSize) | 0;
|
||||||
|
const j = (y / cellSize) | 0;
|
||||||
|
const i0 = Math.max(i - 2, 0);
|
||||||
|
const j0 = Math.max(j - 2, 0);
|
||||||
|
const i1 = Math.min(i + 3, gridWidth);
|
||||||
|
const j1 = Math.min(j + 3, gridHeight);
|
||||||
|
for (let j = j0; j < j1; ++j) {
|
||||||
|
const o = j * gridWidth;
|
||||||
|
for (let i = i0; i < i1; ++i) {
|
||||||
|
const s = grid[o + i];
|
||||||
|
if (s) {
|
||||||
|
const dx = s[0] - x;
|
||||||
|
const dy = s[1] - y;
|
||||||
|
if (dx * dx + dy * dy < r2) return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sample(x, y) {
|
||||||
|
queue.push((grid[gridWidth * ((y / cellSize) | 0) + ((x / cellSize) | 0)] = [x, y]));
|
||||||
|
return [x + x0, y + y0];
|
||||||
|
}
|
||||||
|
|
||||||
|
yield sample(width / 2, height / 2);
|
||||||
|
|
||||||
|
pick: while (queue.length) {
|
||||||
|
const i = (Math.random() * queue.length) | 0;
|
||||||
|
const parent = queue[i];
|
||||||
|
|
||||||
|
for (let j = 0; j < k; ++j) {
|
||||||
|
const a = 2 * Math.PI * Math.random();
|
||||||
|
const r = Math.sqrt(Math.random() * r2_3 + r2);
|
||||||
|
const x = parent[0] + r * Math.cos(a);
|
||||||
|
const y = parent[1] + r * Math.sin(a);
|
||||||
|
if (0 <= x && x < width && 0 <= y && y < height && far(x, y)) {
|
||||||
|
yield sample(x, y);
|
||||||
|
continue pick;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const r = queue.pop();
|
||||||
|
if (i < queue.length) queue[i] = r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ReliefIcons;
|
return ReliefIcons;
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,4 @@
|
||||||
"use strict";
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
/*
|
|
||||||
Cell resampler module used by submapper and resampler (transform)
|
|
||||||
main function: resample(options);
|
|
||||||
*/
|
|
||||||
|
|
||||||
window.Submap = (function () {
|
window.Submap = (function () {
|
||||||
const isWater = (pack, id) => pack.cells.h[id] < 20;
|
const isWater = (pack, id) => pack.cells.h[id] < 20;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
||||||
function editBiomes() {
|
|
||||||
|
export function editBiomes() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
closeDialogs("#biomesEditor, .stable");
|
closeDialogs("#biomesEditor, .stable");
|
||||||
if (!layerIsOn("toggleBiomes")) toggleBiomes();
|
if (!layerIsOn("toggleBiomes")) toggleBiomes();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
function editBurg(id) {
|
|
||||||
|
export function editBurg(id) {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
closeDialogs(".stable");
|
closeDialogs(".stable");
|
||||||
if (!layerIsOn("toggleIcons")) toggleIcons();
|
if (!layerIsOn("toggleIcons")) toggleIcons();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
function overviewBurgs() {
|
|
||||||
|
export function overviewBurgs() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
closeDialogs("#burgsOverview, .stable");
|
closeDialogs("#burgsOverview, .stable");
|
||||||
if (!layerIsOn("toggleIcons")) toggleIcons();
|
if (!layerIsOn("toggleIcons")) toggleIcons();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {getPackPolygon} from "/src/utils/graphUtils";
|
||||||
function editCoastline(node = d3.event.target) {
|
|
||||||
|
export function editCoastline(node = d3.event.target) {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
closeDialogs(".stable");
|
closeDialogs(".stable");
|
||||||
if (layerIsOn("toggleCells")) toggleCells();
|
if (layerIsOn("toggleCells")) toggleCells();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
function editDiplomacy() {
|
|
||||||
|
export function editDiplomacy() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
if (pack.states.filter(s => s.i && !s.removed).length < 2)
|
if (pack.states.filter(s => s.i && !s.removed).length < 2)
|
||||||
return tip("There should be at least 2 states to edit the diplomacy", false, "error");
|
return tip("There should be at least 2 states to edit the diplomacy", false, "error");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
// module stub to store common functions for ui editors
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
"use strict";
|
|
||||||
|
|
||||||
// restore default viewbox events
|
// restore default viewbox events
|
||||||
function restoreDefaultEvents() {
|
function restoreDefaultEvents() {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use strict";
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
|
|
||||||
function showEPForRoute(node) {
|
export function showEPForRoute(node) {
|
||||||
const points = [];
|
const points = [];
|
||||||
debug
|
debug
|
||||||
.select("#controlPoints")
|
.select("#controlPoints")
|
||||||
|
|
@ -14,7 +14,7 @@ function showEPForRoute(node) {
|
||||||
showElevationProfile(points, routeLen, false);
|
showElevationProfile(points, routeLen, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showEPForRiver(node) {
|
export function showEPForRiver(node) {
|
||||||
const points = [];
|
const points = [];
|
||||||
debug
|
debug
|
||||||
.select("#controlPoints")
|
.select("#controlPoints")
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import {findCell} from "/src/utils/graphUtils";
|
import {findCell, findGridCell} from "/src/utils/graphUtils";
|
||||||
import {MOBILE} from "/src/constants";
|
import {MOBILE} from "/src/constants";
|
||||||
|
|
||||||
// fit full-screen map if window is resized
|
// fit full-screen map if window is resized
|
||||||
|
|
@ -305,7 +305,7 @@ function getDepth(f, p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get user-friendly (real-world) height value from map data
|
// get user-friendly (real-world) height value from map data
|
||||||
function getFriendlyHeight([x, y]) {
|
export function getFriendlyHeight([x, y]) {
|
||||||
const packH = pack.cells.h[findCell(x, y)];
|
const packH = pack.cells.h[findCell(x, y)];
|
||||||
const gridH = grid.cells.h[findGridCell(x, y, grid)];
|
const gridH = grid.cells.h[findGridCell(x, y, grid)];
|
||||||
const h = packH < 20 ? gridH : packH;
|
const h = packH < 20 ? gridH : packH;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use strict";
|
import {findGridCell, findGridAll, findCell, getPackPolygon, getGridPolygon} from "/src/utils/graphUtils";
|
||||||
|
|
||||||
function editHeightmap(options) {
|
export function editHeightmap(options) {
|
||||||
const {mode, tool} = options || {};
|
const {mode, tool} = options || {};
|
||||||
restartHistory();
|
restartHistory();
|
||||||
viewbox.insert("g", "#terrs").attr("id", "heights");
|
viewbox.insert("g", "#terrs").attr("id", "heights");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {findGridCell, getGridPolygon} from "/src/utils/graphUtils";
|
||||||
function editIce() {
|
|
||||||
|
export function editIce() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
closeDialogs(".stable");
|
closeDialogs(".stable");
|
||||||
if (!layerIsOn("toggleIce")) toggleIce();
|
if (!layerIsOn("toggleIce")) toggleIce();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
function editLabel() {
|
|
||||||
|
export function editLabel() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
closeDialogs();
|
closeDialogs();
|
||||||
if (!layerIsOn("toggleLabels")) toggleLabels();
|
if (!layerIsOn("toggleLabels")) toggleLabels();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {getPackPolygon} from "/src/utils/graphUtils";
|
||||||
function editLake() {
|
|
||||||
|
export function editLake() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
closeDialogs(".stable");
|
closeDialogs(".stable");
|
||||||
if (layerIsOn("toggleCells")) toggleCells();
|
if (layerIsOn("toggleCells")) toggleCells();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import {TIME} from "/src/config/logging";
|
import {TIME} from "/src/config/logging";
|
||||||
import {invokeActiveZooming} from "../activeZooming";
|
import {invokeActiveZooming} from "../activeZooming";
|
||||||
|
import {getGridPolygon} from "/src/utils/graphUtils";
|
||||||
|
|
||||||
let presets = {}; // global object
|
let presets = {}; // global object
|
||||||
restoreCustomPresets(); // run on-load
|
restoreCustomPresets(); // run on-load
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
function editMarker(markerI) {
|
|
||||||
|
export function editMarker(markerI) {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
closeDialogs(".stable");
|
closeDialogs(".stable");
|
||||||
|
|
||||||
|
|
@ -97,7 +98,18 @@ function editMarker(markerI) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateInputs() {
|
function updateInputs() {
|
||||||
const {icon, type = "", size = 30, dx = 50, dy = 50, px = 12, stroke = "#000000", fill = "#ffffff", pin = "bubble", lock} = marker;
|
const {
|
||||||
|
icon,
|
||||||
|
type = "",
|
||||||
|
size = 30,
|
||||||
|
dx = 50,
|
||||||
|
dy = 50,
|
||||||
|
px = 12,
|
||||||
|
stroke = "#000000",
|
||||||
|
fill = "#ffffff",
|
||||||
|
pin = "bubble",
|
||||||
|
lock
|
||||||
|
} = marker;
|
||||||
|
|
||||||
markerType.value = type;
|
markerType.value = type;
|
||||||
markerIcon.value = icon;
|
markerIcon.value = icon;
|
||||||
|
|
@ -241,7 +253,7 @@ function editMarker(markerI) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteMarker() {
|
function deleteMarker() {
|
||||||
Markers.deleteMarker(marker.i)
|
Markers.deleteMarker(marker.i);
|
||||||
element.remove();
|
element.remove();
|
||||||
$("#markerEditor").dialog("close");
|
$("#markerEditor").dialog("close");
|
||||||
if (document.getElementById("markersOverviewRefresh").offsetParent) markersOverviewRefresh.click();
|
if (document.getElementById("markersOverviewRefresh").offsetParent) markersOverviewRefresh.click();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
||||||
function editProvinces() {
|
|
||||||
|
export function editProvinces() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
closeDialogs("#provincesEditor, .stable");
|
closeDialogs("#provincesEditor, .stable");
|
||||||
if (!layerIsOn("toggleProvinces")) toggleProvinces();
|
if (!layerIsOn("toggleProvinces")) toggleProvinces();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
function editRegiment(selector) {
|
|
||||||
|
export function editRegiment(selector) {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
closeDialogs(".stable");
|
closeDialogs(".stable");
|
||||||
if (!layerIsOn("toggleMilitary")) toggleMilitary();
|
if (!layerIsOn("toggleMilitary")) toggleMilitary();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
function overviewRegiments(state) {
|
|
||||||
|
export function overviewRegiments(state) {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
closeDialogs(".stable");
|
closeDialogs(".stable");
|
||||||
if (!layerIsOn("toggleMilitary")) toggleMilitary();
|
if (!layerIsOn("toggleMilitary")) toggleMilitary();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
function editReliefIcon() {
|
|
||||||
|
export function editReliefIcon() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
closeDialogs(".stable");
|
closeDialogs(".stable");
|
||||||
if (!layerIsOn("toggleRelief")) toggleRelief();
|
if (!layerIsOn("toggleRelief")) toggleRelief();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {getPackPolygon, findCell} from "/src/utils/graphUtils";
|
||||||
function createRiver() {
|
|
||||||
|
export function createRiver() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
closeDialogs();
|
closeDialogs();
|
||||||
if (!layerIsOn("toggleRivers")) toggleRivers();
|
if (!layerIsOn("toggleRivers")) toggleRivers();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {findCell, getPackPolygon} from "/src/utils/graphUtils";
|
||||||
function editRiver(id) {
|
|
||||||
|
export function editRiver(id) {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
if (elSelected && id === elSelected.attr("id")) return;
|
if (elSelected && id === elSelected.attr("id")) return;
|
||||||
closeDialogs(".stable");
|
closeDialogs(".stable");
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
"use strict";
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
|
|
||||||
// module to control the Tools options (click to edit, to re-geenerate, tp add)
|
// module to control the Tools options (click to edit, to re-geenerate, tp add)
|
||||||
|
|
||||||
toolsContent.addEventListener("click", function (event) {
|
toolsContent.addEventListener("click", function (event) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
function editUnits() {
|
|
||||||
|
export function editUnits() {
|
||||||
closeDialogs("#unitsEditor, .stable");
|
closeDialogs("#unitsEditor, .stable");
|
||||||
$("#unitsEditor").dialog();
|
$("#unitsEditor").dialog();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use strict";
|
import {findAll, findCell, getPackPolygon} from "/src/utils/graphUtils";
|
||||||
|
|
||||||
function editZones() {
|
export function editZones() {
|
||||||
closeDialogs();
|
closeDialogs();
|
||||||
if (!layerIsOn("toggleZones")) toggleZones();
|
if (!layerIsOn("toggleZones")) toggleZones();
|
||||||
const body = document.getElementById("zonesBodySection");
|
const body = document.getElementById("zonesBodySection");
|
||||||
|
|
|
||||||
21
src/main.ts
21
src/main.ts
|
|
@ -3,14 +3,22 @@
|
||||||
|
|
||||||
import {PRODUCTION, UINT16_MAX} from "./constants";
|
import {PRODUCTION, UINT16_MAX} from "./constants";
|
||||||
import {INFO, TIME, WARN, ERROR} from "./config/logging";
|
import {INFO, TIME, WARN, ERROR} from "./config/logging";
|
||||||
import {createTypedArray} from "./utils";
|
import {
|
||||||
import {shouldRegenerateGrid, generateGrid, calculateVoronoi, getPackPolygon, isLand} from "./utils/graphUtils";
|
shouldRegenerateGrid,
|
||||||
|
generateGrid,
|
||||||
|
calculateVoronoi,
|
||||||
|
getPackPolygon,
|
||||||
|
isLand,
|
||||||
|
findCell
|
||||||
|
} from "./utils/graphUtils";
|
||||||
|
import {createTypedArray} from "./utils/arrayUtils";
|
||||||
import {drawRivers, drawStates, drawBorders} from "../modules/ui/layers";
|
import {drawRivers, drawStates, drawBorders} from "../modules/ui/layers";
|
||||||
import {invokeActiveZooming} from "../modules/activeZooming";
|
import {invokeActiveZooming} from "../modules/activeZooming";
|
||||||
import {applyStoredOptions, applyMapSize, randomizeOptions} from "../modules/ui/options";
|
import {applyStoredOptions, applyMapSize, randomizeOptions} from "../modules/ui/options";
|
||||||
import {locked} from "../modules/ui/general";
|
import {locked} from "../modules/ui/general";
|
||||||
|
import {Rulers, Ruler, drawScaleBar} from "./modules/measurers";
|
||||||
|
|
||||||
globalThis.fmg = {
|
window.fmg = {
|
||||||
modules: {}
|
modules: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -931,10 +939,9 @@ function drawCoastline() {
|
||||||
TIME && console.time("drawCoastline");
|
TIME && console.time("drawCoastline");
|
||||||
reMarkFeatures();
|
reMarkFeatures();
|
||||||
|
|
||||||
const cells = pack.cells,
|
const {cells, vertices, features} = pack;
|
||||||
vertices = pack.vertices,
|
const n = cells.i.length;
|
||||||
n = cells.i.length,
|
|
||||||
features = pack.features;
|
|
||||||
const used = new Uint8Array(features.length); // store connected features
|
const used = new Uint8Array(features.length); // store connected features
|
||||||
const largestLand = d3.scan(
|
const largestLand = d3.scan(
|
||||||
features.map(f => (f.land ? f.cells : 0)),
|
features.map(f => (f.land ? f.cells : 0)),
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
class Rulers {
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
|
|
||||||
|
export class Rulers {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.data = [];
|
this.data = [];
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +115,7 @@ class Measurer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Ruler extends Measurer {
|
export class Ruler extends Measurer {
|
||||||
constructor(points) {
|
constructor(points) {
|
||||||
super(points);
|
super(points);
|
||||||
}
|
}
|
||||||
|
|
@ -275,7 +277,7 @@ class Ruler extends Measurer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Opisometer extends Measurer {
|
export class Opisometer extends Measurer {
|
||||||
constructor(points) {
|
constructor(points) {
|
||||||
super(points);
|
super(points);
|
||||||
}
|
}
|
||||||
|
|
@ -365,7 +367,7 @@ class Opisometer extends Measurer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RouteOpisometer extends Measurer {
|
export class RouteOpisometer extends Measurer {
|
||||||
constructor(points) {
|
constructor(points) {
|
||||||
super(points);
|
super(points);
|
||||||
if (pack.cells) {
|
if (pack.cells) {
|
||||||
|
|
@ -495,7 +497,7 @@ class RouteOpisometer extends Measurer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Planimeter extends Measurer {
|
export class Planimeter extends Measurer {
|
||||||
constructor(points) {
|
constructor(points) {
|
||||||
super(points);
|
super(points);
|
||||||
}
|
}
|
||||||
|
|
@ -533,8 +535,7 @@ class Planimeter extends Measurer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scale bar
|
export function drawScaleBar(scaleLevel) {
|
||||||
function drawScaleBar(scaleLevel) {
|
|
||||||
if (scaleBar.style("display") === "none") return; // no need to re-draw hidden element
|
if (scaleBar.style("display") === "none") return; // no need to re-draw hidden element
|
||||||
scaleBar.selectAll("*").remove(); // fully redraw every time
|
scaleBar.selectAll("*").remove(); // fully redraw every time
|
||||||
|
|
||||||
|
|
@ -621,7 +622,7 @@ function drawScaleBar(scaleLevel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fit ScaleBar to canvas size
|
// fit ScaleBar to canvas size
|
||||||
function fitScaleBar() {
|
export function fitScaleBar() {
|
||||||
if (!scaleBar.select("rect").size() || scaleBar.style("display") === "none") return;
|
if (!scaleBar.select("rect").size() || scaleBar.style("display") === "none") return;
|
||||||
const px = isNaN(+barPosX.value) ? 0.99 : barPosX.value / 100;
|
const px = isNaN(+barPosX.value) ? 0.99 : barPosX.value / 100;
|
||||||
const py = isNaN(+barPosY.value) ? 0.99 : barPosY.value / 100;
|
const py = isNaN(+barPosY.value) ? 0.99 : barPosY.value / 100;
|
||||||
8
src/types/global.d.ts
vendored
8
src/types/global.d.ts
vendored
|
|
@ -4,4 +4,12 @@ interface Navigator {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Window {
|
||||||
|
fmg: {
|
||||||
|
modules: {
|
||||||
|
[key: string]: boolean;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
type UnknownObject = {[key: string]: unknown};
|
type UnknownObject = {[key: string]: unknown};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import {TIME} from "../config/logging";
|
import {TIME} from "../config/logging";
|
||||||
import {createTypedArray} from ".";
|
import {createTypedArray} from "./arrayUtils";
|
||||||
|
|
||||||
// check if new grid graph should be generated or we can use the existing one
|
// check if new grid graph should be generated or we can use the existing one
|
||||||
export function shouldRegenerateGrid(grid) {
|
export function shouldRegenerateGrid(grid) {
|
||||||
|
|
@ -103,7 +103,7 @@ export function findGridCell(x, y, grid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// return array of cell indexes in radius on a regular square grid
|
// return array of cell indexes in radius on a regular square grid
|
||||||
function findGridAll(x, y, radius) {
|
export function findGridAll(x, y, radius) {
|
||||||
const c = grid.cells.c;
|
const c = grid.cells.c;
|
||||||
let r = Math.floor(radius / grid.spacing);
|
let r = Math.floor(radius / grid.spacing);
|
||||||
let found = [findGridCell(x, y, grid)];
|
let found = [findGridCell(x, y, grid)];
|
||||||
|
|
@ -128,11 +128,6 @@ function findGridAll(x, y, radius) {
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return closest pack points quadtree datum
|
|
||||||
function find(x, y, radius = Infinity) {
|
|
||||||
return pack.cells.q.find(x, y, radius);
|
|
||||||
}
|
|
||||||
|
|
||||||
// return array of cell indexes in radius
|
// return array of cell indexes in radius
|
||||||
export function findAll(x, y, radius) {
|
export function findAll(x, y, radius) {
|
||||||
const found = pack.cells.q.findAll(x, y, radius);
|
const found = pack.cells.q.findAll(x, y, radius);
|
||||||
|
|
@ -151,72 +146,10 @@ export function findCell(x, y, radius = Infinity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get polygon points for initial cells knowing cell id
|
// get polygon points for initial cells knowing cell id
|
||||||
function getGridPolygon(i) {
|
export function getGridPolygon(i) {
|
||||||
return grid.cells.v[i].map(v => grid.vertices.p[v]);
|
return grid.cells.v[i].map(v => grid.vertices.p[v]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mbostock's poissonDiscSampler
|
|
||||||
function* poissonDiscSampler(x0, y0, x1, y1, r, k = 3) {
|
|
||||||
if (!(x1 >= x0) || !(y1 >= y0) || !(r > 0)) throw new Error();
|
|
||||||
|
|
||||||
const width = x1 - x0;
|
|
||||||
const height = y1 - y0;
|
|
||||||
const r2 = r * r;
|
|
||||||
const r2_3 = 3 * r2;
|
|
||||||
const cellSize = r * Math.SQRT1_2;
|
|
||||||
const gridWidth = Math.ceil(width / cellSize);
|
|
||||||
const gridHeight = Math.ceil(height / cellSize);
|
|
||||||
const grid = new Array(gridWidth * gridHeight);
|
|
||||||
const queue = [];
|
|
||||||
|
|
||||||
function far(x, y) {
|
|
||||||
const i = (x / cellSize) | 0;
|
|
||||||
const j = (y / cellSize) | 0;
|
|
||||||
const i0 = Math.max(i - 2, 0);
|
|
||||||
const j0 = Math.max(j - 2, 0);
|
|
||||||
const i1 = Math.min(i + 3, gridWidth);
|
|
||||||
const j1 = Math.min(j + 3, gridHeight);
|
|
||||||
for (let j = j0; j < j1; ++j) {
|
|
||||||
const o = j * gridWidth;
|
|
||||||
for (let i = i0; i < i1; ++i) {
|
|
||||||
const s = grid[o + i];
|
|
||||||
if (s) {
|
|
||||||
const dx = s[0] - x;
|
|
||||||
const dy = s[1] - y;
|
|
||||||
if (dx * dx + dy * dy < r2) return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function sample(x, y) {
|
|
||||||
queue.push((grid[gridWidth * ((y / cellSize) | 0) + ((x / cellSize) | 0)] = [x, y]));
|
|
||||||
return [x + x0, y + y0];
|
|
||||||
}
|
|
||||||
|
|
||||||
yield sample(width / 2, height / 2);
|
|
||||||
|
|
||||||
pick: while (queue.length) {
|
|
||||||
const i = (Math.random() * queue.length) | 0;
|
|
||||||
const parent = queue[i];
|
|
||||||
|
|
||||||
for (let j = 0; j < k; ++j) {
|
|
||||||
const a = 2 * Math.PI * Math.random();
|
|
||||||
const r = Math.sqrt(Math.random() * r2_3 + r2);
|
|
||||||
const x = parent[0] + r * Math.cos(a);
|
|
||||||
const y = parent[1] + r * Math.sin(a);
|
|
||||||
if (0 <= x && x < width && 0 <= y && y < height && far(x, y)) {
|
|
||||||
yield sample(x, y);
|
|
||||||
continue pick;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const r = queue.pop();
|
|
||||||
if (i < queue.length) queue[i] = r;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// filter land cells
|
// filter land cells
|
||||||
export function isLand(i) {
|
export function isLand(i) {
|
||||||
return pack.cells.h[i] >= 20;
|
return pack.cells.h[i] >= 20;
|
||||||
|
|
@ -308,34 +241,3 @@ void (function addFindAll() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// helper function non-used for the generation
|
|
||||||
function drawCellsValue(data) {
|
|
||||||
debug.selectAll("text").remove();
|
|
||||||
debug
|
|
||||||
.selectAll("text")
|
|
||||||
.data(data)
|
|
||||||
.enter()
|
|
||||||
.append("text")
|
|
||||||
.attr("x", (d, i) => pack.cells.p[i][0])
|
|
||||||
.attr("y", (d, i) => pack.cells.p[i][1])
|
|
||||||
.text(d => d);
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper function non-used for the generation
|
|
||||||
function drawPolygons(data) {
|
|
||||||
const max = d3.max(data),
|
|
||||||
min = d3.min(data),
|
|
||||||
scheme = getColorScheme(terrs.attr("scheme"));
|
|
||||||
data = data.map(d => 1 - normalize(d, min, max));
|
|
||||||
|
|
||||||
debug.selectAll("polygon").remove();
|
|
||||||
debug
|
|
||||||
.selectAll("polygon")
|
|
||||||
.data(data)
|
|
||||||
.enter()
|
|
||||||
.append("polygon")
|
|
||||||
.attr("points", (d, i) => getPackPolygon(i))
|
|
||||||
.attr("fill", d => scheme(d))
|
|
||||||
.attr("stroke", d => scheme(d));
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export {last, unique, createTypedArray} from "./arrayUtils";
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue