v. 0.58.13b

This commit is contained in:
Azgaar 2018-08-10 02:06:46 +03:00
parent bc3b421959
commit 42dcae94bb
3 changed files with 49 additions and 31 deletions

View file

@ -1,14 +1,12 @@
# Fantasy Map Generator # Fantasy Map Generator
Azgaar's _Fantasy Map Generator_. Online tool generating maps based on [D3](https://d3js.org) Voronoi diagram rendered in svg. Azgaar's _Fantasy Map Generator_. Online tool generating interactive svg maps based on [D3](https://d3js.org) voronoi diagram.
Project goal is a procedurally generated map for my *Medieval Dynasty* simulator. Map should be interactive, scalable, fast and plausible. Initial intend was to place at least 500 burgs within 7 cultural areas and imagined land area about 1 million km<sup>2</sup>. As for now all these parameters are customizable and Generator is mostly used for a homebrew DnD campaign maps. Project is under active development, check out the work in progress version [here](https://azgaar.github.io/Fantasy-Map-Generator). Refer to the [project wiki](https://github.com/Azgaar/Fantasy-Map-Generator/wiki) for a guidance. Some details are covered in my blog [_Fantasy Maps for fun and glory_](https://azgaar.wordpress.com), you may also keep an eye on my [Trello devboard](https://trello.com/b/7x832DG4/fantasy-map-generator).
[![alt tag](https://i0.wp.com/azgaar.files.wordpress.com/2017/03/80k-part.png)](https://azgaar.wordpress.com) [![alt tag](https://i0.wp.com/azgaar.files.wordpress.com/2017/03/80k-part.png)](https://azgaar.wordpress.com)
Project is under active development, check out the work in progress version [here](https://azgaar.github.io/Fantasy-Map-Generator). See the [changelog](https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Changelog) for archived versions. Refer to the [project wiki](https://github.com/Azgaar/Fantasy-Map-Generator/wiki) for a quick guidance. Some details are covered in my blog [_Fantasy Maps for fun and glory_](https://azgaar.wordpress.com), you may also keep an eye on my [Trello devboard](https://trello.com/b/7x832DG4/fantasy-map-generator). Join our [Reddit community](https://www.reddit.com/r/FantasyMapGenerator) to share the created maps, discuss the Generator, suggest ideas and get a most recent updates. You may also contact me directly via [email](mailto:maxganiev@yandex.com). For bug reports please use the project [issues page](https://github.com/Azgaar/Fantasy-Map-Generator/issues). If you face performance issues, please try to open the page in a small window and use the default graph size only. In Firefox fast map zooming may cause browser crush.
Join our [Reddit community](https://www.reddit.com/r/FantasyMapGenerator) to share the created maps, discuss the Generator, suggest ideas and get a most recent updates. You may also contact me directly via [email](mailto:maxganiev@yandex.com). For bug reports please use the project [issues page](https://github.com/Azgaar/Fantasy-Map-Generator/issues). If you find the Demo performance low, open the page in a much smaller window and use the default graph size only. The best performance is observed in Chrome, there are also some reports about different features not working on Mac OS.
_Inspiration:_ _Inspiration:_

View file

@ -31,8 +31,8 @@
<script src="libs/quantize.min.js" defer></script> <script src="libs/quantize.min.js" defer></script>
<script src="libs/d3-hexbin.v0.2.min.js" defer></script> <script src="libs/d3-hexbin.v0.2.min.js" defer></script>
<script src="libs/jquery.ui.touch-punch.min.js" defer></script> <script src="libs/jquery.ui.touch-punch.min.js" defer></script>
<link rel="stylesheet" type="text/css" href="index.css?version=0.58.12b"/> <link rel="stylesheet" type="text/css" href="index.css?version=0.58.13b"/>
<link rel="stylesheet" type="text/css" href="icons.css?version=0.58.12b"/> <link rel="stylesheet" type="text/css" href="icons.css?version=0.58.13b"/>
<link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"/> <link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"/>
</head> </head>
<body> <body>
@ -1109,5 +1109,5 @@
<input type="file" accept=".txt" id="namesbaseToLoad"> <input type="file" accept=".txt" id="namesbaseToLoad">
</div> </div>
<script src="script.js?version=0.58.12b"></script> <script src="script.js?version=0.58.13b"></script>
</body> </body>

View file

@ -1,4 +1,8 @@
// Fantasy Map Generator main script // Fantasy Map Generator main script
// Azgaar (Max Haniyeu). Minsk, 2017-2018
// https://github.com/Azgaar/Fantasy-Map-Generator
// GNU General Public License v3.0
"use strict;" "use strict;"
fantasyMap(); fantasyMap();
function fantasyMap() { function fantasyMap() {
@ -2068,6 +2072,7 @@ function fantasyMap() {
// add lakes on depressed points on river course // add lakes on depressed points on river course
function addLakes() { function addLakes() {
console.time('addLakes'); console.time('addLakes');
let smallLakes = 0;
for (let i=0; i < land.length; i++) { for (let i=0; i < land.length; i++) {
// elavate all big lakes // elavate all big lakes
if (land[i].lake === 1) { if (land[i].lake === 1) {
@ -2075,11 +2080,12 @@ function fantasyMap() {
land[i].ctype = -1; land[i].ctype = -1;
} }
// define eligible small lakes // define eligible small lakes
if (land[i].lake === 2) { if (land[i].lake === 2 && smallLakes < 100) {
if (land[i].river !== undefined) { if (land[i].river !== undefined) {
land[i].height = 0.19; land[i].height = 0.19;
land[i].ctype = -1; land[i].ctype = -1;
land[i].fn = -1; land[i].fn = -1;
smallLakes++;
} else { } else {
land[i].lake = undefined; land[i].lake = undefined;
land[i].neighbors.forEach(function(n) { land[i].neighbors.forEach(function(n) {
@ -2088,6 +2094,7 @@ function fantasyMap() {
cells[n].height = 0.19; cells[n].height = 0.19;
cells[n].ctype = -1; cells[n].ctype = -1;
cells[n].fn = -1; cells[n].fn = -1;
smallLakes++;
} else if (cells[n].lake === 2) { } else if (cells[n].lake === 2) {
cells[n].lake = undefined; cells[n].lake = undefined;
} }
@ -3989,9 +3996,16 @@ function fantasyMap() {
// generate random name using Markov's chain // generate random name using Markov's chain
function generateName(culture, base) { function generateName(culture, base) {
if (base === undefined) base = cultures[culture].base; if (base === undefined) {
if (!cultures[culture]) {
console.error("culture " + culture + " is not defined. Will load default cultures and set first culture");
generateCultures();
culture = 0;
}
base = cultures[culture].base;
}
if (!nameBases[base]) { if (!nameBases[base]) {
console.error("nameBase " + base + "is not defined. Will load default names data and first base"); console.error("nameBase " + base + " is not defined. Will load default names data and first base");
localStorage.removeItem("nameBase"); localStorage.removeItem("nameBase");
localStorage.removeItem("nameBases"); localStorage.removeItem("nameBases");
applyDefaultNamesData(); applyDefaultNamesData();
@ -4420,10 +4434,12 @@ function fantasyMap() {
if (!terrs.selectAll("path").size()) { if (!terrs.selectAll("path").size()) {
cells.map(function(i, d) { cells.map(function(i, d) {
let height = i.height; let height = i.height;
if (height < 0.2 && i.lake !== 2) return; if (height < 0.2 && !i.lake) return;
if (i.lake === 2) { if (i.lake) {
const heights = i.neighbors.map(function(e) {if (cells[e].height >= 0.2) return cells[e].height;}) const heights = i.neighbors.map(function(e) {if (cells[e].height >= 0.2) return cells[e].height;})
height = Math.trunc(d3.mean(heights) * 100) / 100; const mean = d3.mean(heights);
if (!mean) return;
height = Math.trunc(mean * 100) / 100;
if (height < 0.2 || isNaN(height)) height = 0.2; if (height < 0.2 || isNaN(height)) height = 0.2;
} }
const clr = hColor(1 - height); const clr = hColor(1 - height);
@ -5763,25 +5779,29 @@ function fantasyMap() {
$("#icons #capitals, #icons #towns").detach().appendTo($("#burgIcons")); $("#icons #capitals, #icons #towns").detach().appendTo($("#burgIcons"));
icons.select("#burgIcons").select("#capitals").attr("size", 1).attr("fill-opacity", .7).attr("stroke-opacity", 1); icons.select("#burgIcons").select("#capitals").attr("size", 1).attr("fill-opacity", .7).attr("stroke-opacity", 1);
icons.select("#burgIcons").select("#towns").attr("size", .5).attr("fill-opacity", .7).attr("stroke-opacity", 1); icons.select("#burgIcons").select("#towns").attr("size", .5).attr("fill-opacity", .7).attr("stroke-opacity", 1);
icons.select("#burgIcons").selectAll("circle").each(function() {
let id = this.getAttribute("id");
if (!id) return;
this.removeAttribute("id");
this.setAttribute("r", this.parentNode.getAttribute("size"));
this.setAttribute("data-id", +id.replace("manorIcon", ""));
});
icons.select("#capital-anchors").raise().attr("size", 2).attr("size", null);
icons.select("#capital-anchors").selectAll("use").each(function() {
this.setAttribute("width", "2");
this.setAttribute("height", "2");
});
icons.select("#town-anchors").raise().attr("size", 1).attr("size", null);
icons.select("#town-anchors").selectAll("use").each(function() {
this.setAttribute("width", "1");
this.setAttribute("height", "1");
});
} }
icons.selectAll("g").each(function(d) {
const size = this.getAttribute("font-size");
if (size === undefined) return;
this.removeAttribute("font-size");
this.setAttribute("size", size);
});
icons.select("#burgIcons").selectAll("circle").each(function() {
this.setAttribute("r", this.parentNode.getAttribute("size"));
const id = this.getAttribute("id");
if (!id) return;
this.removeAttribute("id");
this.setAttribute("data-id", +id.replace("manorIcon", ""));
});
icons.selectAll("use").each(function() {
const size = this.parentNode.getAttribute("size");
this.setAttribute("width", size);
this.setAttribute("height", size);
});
if (!labels.select("#countries").size()) { if (!labels.select("#countries").size()) {
labels.append("g").attr("id", "countries") labels.append("g").attr("id", "countries")
.attr("fill", "#3e3e4b").attr("opacity", 1) .attr("fill", "#3e3e4b").attr("opacity", 1)