mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 18:11:24 +01:00
Merge branch 'master' of https://github.com/Azgaar/Fantasy-Map-Generator into zones-generator
This commit is contained in:
commit
f618892068
5 changed files with 57 additions and 68 deletions
|
|
@ -558,6 +558,11 @@ input[type="color"]::-webkit-color-swatch-wrapper {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#options input[type="number"] {
|
||||||
|
appearance: textfield;
|
||||||
|
-moz-appearance: textfield;
|
||||||
|
}
|
||||||
|
|
||||||
#options input[type="number"]:hover {
|
#options input[type="number"]:hover {
|
||||||
outline: 1px solid var(--dark-solid);
|
outline: 1px solid var(--dark-solid);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
index.html
14
index.html
|
|
@ -138,7 +138,7 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<link rel="preload" href="index.css?v=1.99.05" as="style" onload="this.onload=null; this.rel='stylesheet'" />
|
<link rel="preload" href="index.css?v=1.99.11" as="style" onload="this.onload=null; this.rel='stylesheet'" />
|
||||||
<link rel="preload" href="icons.css" as="style" onload="this.onload=null; this.rel='stylesheet'" />
|
<link rel="preload" href="icons.css" as="style" onload="this.onload=null; this.rel='stylesheet'" />
|
||||||
<link rel="preload" href="libs/jquery-ui.css" as="style" onload="this.onload=null; this.rel='stylesheet'" />
|
<link rel="preload" href="libs/jquery-ui.css" as="style" onload="this.onload=null; this.rel='stylesheet'" />
|
||||||
</head>
|
</head>
|
||||||
|
|
@ -5894,10 +5894,10 @@
|
||||||
|
|
||||||
<div style="margin: 1em 0 0.3em; font-weight: bold">Export to GeoJSON</div>
|
<div style="margin: 1em 0 0.3em; font-weight: bold">Export to GeoJSON</div>
|
||||||
<div>
|
<div>
|
||||||
<button onclick="saveGeoJSON_Cells()" data-tip="Download cells data in GeoJSON format">cells</button>
|
<button onclick="saveGeoJsonCells()" data-tip="Download cells data in GeoJSON format">cells</button>
|
||||||
<button onclick="saveGeoJSON_Routes()" data-tip="Download routes data in GeoJSON format">routes</button>
|
<button onclick="saveGeoJsonRoutes()" data-tip="Download routes data in GeoJSON format">routes</button>
|
||||||
<button onclick="saveGeoJSON_Rivers()" data-tip="Download rivers data in GeoJSON format">rivers</button>
|
<button onclick="saveGeoJsonRivers()" data-tip="Download rivers data in GeoJSON format">rivers</button>
|
||||||
<button onclick="saveGeoJSON_Markers()" data-tip="Download markers data in GeoJSON format">markers</button>
|
<button onclick="saveGeoJsonMarkers()" data-tip="Download markers data in GeoJSON format">markers</button>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
GeoJSON format is used in GIS tools such as QGIS. Check out
|
GeoJSON format is used in GIS tools such as QGIS. Check out
|
||||||
|
|
@ -8024,7 +8024,7 @@
|
||||||
<script src="main.js?v=1.100.00"></script>
|
<script src="main.js?v=1.100.00"></script>
|
||||||
|
|
||||||
<script defer src="modules/relief-icons.js?v=1.99.05"></script>
|
<script defer src="modules/relief-icons.js?v=1.99.05"></script>
|
||||||
<script defer src="modules/ui/style.js?v=1.99.10"></script>
|
<script defer src="modules/ui/style.js?v=1.99.12"></script>
|
||||||
<script defer src="modules/ui/editors.js?v=1.99.05"></script>
|
<script defer src="modules/ui/editors.js?v=1.99.05"></script>
|
||||||
<script defer src="modules/ui/tools.js?v=1.100.00"></script>
|
<script defer src="modules/ui/tools.js?v=1.100.00"></script>
|
||||||
<script defer src="modules/ui/world-configurator.js?v=1.99.00"></script>
|
<script defer src="modules/ui/world-configurator.js?v=1.99.00"></script>
|
||||||
|
|
@ -8062,7 +8062,7 @@
|
||||||
<script defer src="modules/ui/markers-editor.js?v=1.99.00"></script>
|
<script defer src="modules/ui/markers-editor.js?v=1.99.00"></script>
|
||||||
<script defer src="modules/ui/3d.js?v=1.99.00"></script>
|
<script defer src="modules/ui/3d.js?v=1.99.00"></script>
|
||||||
<script defer src="modules/ui/submap.js?v=1.99.10"></script>
|
<script defer src="modules/ui/submap.js?v=1.99.10"></script>
|
||||||
<script defer src="modules/ui/hotkeys.js?v=1.99.05"></script>
|
<script defer src="modules/ui/hotkeys.js?v=1.99.15"></script>
|
||||||
<script defer src="modules/coa-renderer.js?v=1.99.00"></script>
|
<script defer src="modules/coa-renderer.js?v=1.99.00"></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>
|
||||||
|
|
|
||||||
|
|
@ -440,14 +440,24 @@ function inlineStyle(clone) {
|
||||||
emptyG.remove();
|
emptyG.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveGeoJSON_Cells() {
|
function saveGeoJsonCells() {
|
||||||
|
const {cells, vertices} = pack;
|
||||||
const json = {type: "FeatureCollection", features: []};
|
const json = {type: "FeatureCollection", features: []};
|
||||||
const cells = pack.cells;
|
|
||||||
const getPopulation = i => {
|
const getPopulation = i => {
|
||||||
const [r, u] = getCellPopulation(i);
|
const [r, u] = getCellPopulation(i);
|
||||||
return rn(r + u);
|
return rn(r + u);
|
||||||
};
|
};
|
||||||
const getHeight = i => parseInt(getFriendlyHeight([cells.p[i][0], cells.p[i][1]]));
|
|
||||||
|
const getHeight = i => parseInt(getFriendlyHeight([...cells.p[i]]));
|
||||||
|
|
||||||
|
function getCellCoordinates(cellVertices) {
|
||||||
|
const coordinates = cellVertices.map(vertex => {
|
||||||
|
const [x, y] = vertices.p[vertex];
|
||||||
|
return getCoordinates(x, y, 4);
|
||||||
|
});
|
||||||
|
return [[...coordinates, coordinates[0]]];
|
||||||
|
}
|
||||||
|
|
||||||
cells.i.forEach(i => {
|
cells.i.forEach(i => {
|
||||||
const coordinates = getCellCoordinates(cells.v[i]);
|
const coordinates = getCellCoordinates(cells.v[i]);
|
||||||
|
|
@ -470,20 +480,14 @@ function saveGeoJSON_Cells() {
|
||||||
downloadFile(JSON.stringify(json), fileName, "application/json");
|
downloadFile(JSON.stringify(json), fileName, "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveGeoJSON_Routes() {
|
function saveGeoJsonRoutes() {
|
||||||
const {cells, burgs} = pack;
|
const features = pack.routes.map(({i, points, group, name = null}) => {
|
||||||
let points = cells.p.map(([x, y], cellId) => {
|
const coordinates = points.map(([x, y]) => getCoordinates(x, y, 4));
|
||||||
const burgId = cells.burg[cellId];
|
const id = `route${i}`;
|
||||||
if (burgId) return [burgs[burgId].x, burgs[burgId].y];
|
|
||||||
return [x, y];
|
|
||||||
});
|
|
||||||
|
|
||||||
const features = pack.routes.map(route => {
|
|
||||||
const coordinates = route.points || getRoutePoints(route, points);
|
|
||||||
return {
|
return {
|
||||||
type: "Feature",
|
type: "Feature",
|
||||||
geometry: {type: "LineString", coordinates},
|
geometry: {type: "LineString", coordinates},
|
||||||
properties: {id: route.id, group: route.group}
|
properties: {id, group, name}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
const json = {type: "FeatureCollection", features};
|
const json = {type: "FeatureCollection", features};
|
||||||
|
|
@ -492,24 +496,27 @@ function saveGeoJSON_Routes() {
|
||||||
downloadFile(JSON.stringify(json), fileName, "application/json");
|
downloadFile(JSON.stringify(json), fileName, "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveGeoJSON_Rivers() {
|
function saveGeoJsonRivers() {
|
||||||
const json = {type: "FeatureCollection", features: []};
|
const features = pack.rivers.map(
|
||||||
|
({i, cells, points, source, mouth, parent, basin, widthFactor, sourceWidth, discharge, name, type}) => {
|
||||||
rivers.selectAll("path").each(function () {
|
if (!cells || cells.length < 2) return;
|
||||||
const river = pack.rivers.find(r => r.i === +this.id.slice(5));
|
const meanderedPoints = Rivers.addMeandering(cells, points);
|
||||||
if (!river) return;
|
const coordinates = meanderedPoints.map(([x, y]) => getCoordinates(x, y, 4));
|
||||||
|
const id = `river${i}`;
|
||||||
const coordinates = getRiverPoints(this);
|
return {
|
||||||
const properties = {...river, id: this.id};
|
type: "Feature",
|
||||||
const feature = {type: "Feature", geometry: {type: "LineString", coordinates}, properties};
|
geometry: {type: "LineString", coordinates},
|
||||||
json.features.push(feature);
|
properties: {id, source, mouth, parent, basin, widthFactor, sourceWidth, discharge, name, type}
|
||||||
});
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const json = {type: "FeatureCollection", features};
|
||||||
|
|
||||||
const fileName = getFileName("Rivers") + ".geojson";
|
const fileName = getFileName("Rivers") + ".geojson";
|
||||||
downloadFile(JSON.stringify(json), fileName, "application/json");
|
downloadFile(JSON.stringify(json), fileName, "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveGeoJSON_Markers() {
|
function saveGeoJsonMarkers() {
|
||||||
const features = pack.markers.map(marker => {
|
const features = pack.markers.map(marker => {
|
||||||
const {i, type, icon, x, y, size, fill, stroke} = marker;
|
const {i, type, icon, x, y, size, fill, stroke} = marker;
|
||||||
const coordinates = getCoordinates(x, y, 4);
|
const coordinates = getCoordinates(x, y, 4);
|
||||||
|
|
@ -524,22 +531,3 @@ function saveGeoJSON_Markers() {
|
||||||
const fileName = getFileName("Markers") + ".geojson";
|
const fileName = getFileName("Markers") + ".geojson";
|
||||||
downloadFile(JSON.stringify(json), fileName, "application/json");
|
downloadFile(JSON.stringify(json), fileName, "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCellCoordinates(vertices) {
|
|
||||||
const p = pack.vertices.p;
|
|
||||||
const coordinates = vertices.map(n => getCoordinates(p[n][0], p[n][1], 2));
|
|
||||||
return [coordinates.concat([coordinates[0]])];
|
|
||||||
}
|
|
||||||
|
|
||||||
function getRiverPoints(node) {
|
|
||||||
let points = [];
|
|
||||||
const l = node.getTotalLength() / 2; // half-length
|
|
||||||
const increment = 0.25; // defines density of points
|
|
||||||
for (let i = l, c = i; i >= 0; i -= increment, c += increment) {
|
|
||||||
const p1 = node.getPointAtLength(i);
|
|
||||||
const p2 = node.getPointAtLength(c);
|
|
||||||
const [x, y] = getCoordinates((p1.x + p2.x) / 2, (p1.y + p2.y) / 2, 4);
|
|
||||||
points.push([x, y]);
|
|
||||||
}
|
|
||||||
return points;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,9 @@ function handleKeyup(event) {
|
||||||
|
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
const {code, key, ctrlKey, metaKey, shiftKey, altKey} = event;
|
const {code, key, ctrlKey, metaKey, shiftKey} = event;
|
||||||
const ctrl = ctrlKey || metaKey || key === "Control";
|
const ctrl = ctrlKey || metaKey || key === "Control";
|
||||||
const shift = shiftKey || key === "Shift";
|
const shift = shiftKey || key === "Shift";
|
||||||
const alt = altKey || key === "Alt";
|
|
||||||
|
|
||||||
if (code === "F1") showInfo();
|
if (code === "F1") showInfo();
|
||||||
else if (code === "F2") regeneratePrompt();
|
else if (code === "F2") regeneratePrompt();
|
||||||
|
|
@ -60,11 +59,6 @@ function handleKeyup(event) {
|
||||||
else if (key === "#") toggleAddRiver();
|
else if (key === "#") toggleAddRiver();
|
||||||
else if (key === "$") createRoute();
|
else if (key === "$") createRoute();
|
||||||
else if (key === "%") toggleAddMarker();
|
else if (key === "%") toggleAddMarker();
|
||||||
else if (alt && code === "KeyB") console.table(pack.burgs);
|
|
||||||
else if (alt && code === "KeyS") console.table(pack.states);
|
|
||||||
else if (alt && code === "KeyC") console.table(pack.cultures);
|
|
||||||
else if (alt && code === "KeyR") console.table(pack.religions);
|
|
||||||
else if (alt && code === "KeyF") console.table(pack.features);
|
|
||||||
else if (code === "KeyX") toggleTexture();
|
else if (code === "KeyX") toggleTexture();
|
||||||
else if (code === "KeyH") toggleHeight();
|
else if (code === "KeyH") toggleHeight();
|
||||||
else if (code === "KeyB") toggleBiomes();
|
else if (code === "KeyB") toggleBiomes();
|
||||||
|
|
|
||||||
|
|
@ -147,15 +147,17 @@ function selectStyleElement() {
|
||||||
// clipping
|
// clipping
|
||||||
if (
|
if (
|
||||||
[
|
[
|
||||||
"cells",
|
|
||||||
"gridOverlay",
|
|
||||||
"coordinates",
|
|
||||||
"compass",
|
|
||||||
"terrain",
|
|
||||||
"temperature",
|
|
||||||
"routes",
|
|
||||||
"texture",
|
|
||||||
"biomes",
|
"biomes",
|
||||||
|
"cells",
|
||||||
|
"compass",
|
||||||
|
"coordinates",
|
||||||
|
"gridOverlay",
|
||||||
|
"population",
|
||||||
|
"prec",
|
||||||
|
"routes",
|
||||||
|
"temperature",
|
||||||
|
"terrain",
|
||||||
|
"texture",
|
||||||
"zones"
|
"zones"
|
||||||
].includes(styleElement)
|
].includes(styleElement)
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue