mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
v 0.8.05b
This commit is contained in:
parent
9aa369b6df
commit
6cb21bbead
6 changed files with 66 additions and 44 deletions
15
index.html
15
index.html
|
|
@ -629,14 +629,23 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
<tbody id="styleCoastline">
|
<tbody id="styleCoastline">
|
||||||
<tr data-tip="">
|
<tr data-tip="Allow system to apply filter automatically based on zoom level">
|
||||||
<td colspan=2>
|
<td colspan=2>
|
||||||
<input id="styleCoastlineAuto" class="checkbox" type="checkbox" checked onchange="$('#styleFilter').toggle();">
|
<input id="styleCoastlineAuto" class="checkbox" type="checkbox" checked onchange="$('#styleFilter').toggle();">
|
||||||
<label for="styleCoastlineAuto" data-tip="Allow system to apply filter automatically based on zoom level" class="checkbox-label">Automatically change filter on zoom</label>
|
<label for="styleCoastlineAuto" class="checkbox-label">Automatically change filter on zoom</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
|
<tbody id="styleMarkers">
|
||||||
|
<tr data-tip="Rescale Markers on zoom change">
|
||||||
|
<td colspan=2>
|
||||||
|
<input id="styleRescaleMarkers" class="checkbox" type="checkbox" checked onchange="invokeActiveZooming()">
|
||||||
|
<label for="styleRescaleMarkers" class="checkbox-label">Rescale on zoom change</label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
|
||||||
<tbody id="styleTemperature">
|
<tbody id="styleTemperature">
|
||||||
<tr data-tip="Define transparency of temparature leyer. Set to 0 to make it fully transparent">
|
<tr data-tip="Define transparency of temparature leyer. Set to 0 to make it fully transparent">
|
||||||
<td>Fill opacity</td>
|
<td>Fill opacity</td>
|
||||||
|
|
|
||||||
6
main.js
6
main.js
|
|
@ -272,6 +272,7 @@ function applyDefaultStyle() {
|
||||||
icons.selectAll("g").attr("opacity", null).attr("fill", "#ffffff").attr("stroke", "#3e3e4b").attr("filter", null).attr("mask", null);
|
icons.selectAll("g").attr("opacity", null).attr("fill", "#ffffff").attr("stroke", "#3e3e4b").attr("filter", null).attr("mask", null);
|
||||||
landmass.attr("opacity", 1).attr("fill", "#eef6fb").attr("filter", null);
|
landmass.attr("opacity", 1).attr("fill", "#eef6fb").attr("filter", null);
|
||||||
markers.attr("opacity", null).attr("filter", "url(#dropShadow01)");
|
markers.attr("opacity", null).attr("filter", "url(#dropShadow01)");
|
||||||
|
styleRescaleMarkers.checked = true;
|
||||||
prec.attr("opacity", null).attr("stroke", "#000000").attr("stroke-width", .1).attr("fill", "#003dff").attr("filter", null);
|
prec.attr("opacity", null).attr("stroke", "#000000").attr("stroke-width", .1).attr("fill", "#003dff").attr("filter", null);
|
||||||
population.attr("opacity", null).attr("stroke-width", 1.6).attr("stroke-dasharray", null).attr("stroke-linecap", "butt").attr("filter", null);
|
population.attr("opacity", null).attr("stroke-width", 1.6).attr("stroke-dasharray", null).attr("stroke-linecap", "butt").attr("filter", null);
|
||||||
population.select("#rural").attr("stroke", "#0000ff");
|
population.select("#rural").attr("stroke", "#0000ff");
|
||||||
|
|
@ -331,11 +332,12 @@ function applyDefaultStyle() {
|
||||||
const stateLabelSize = Math.max(rn(24 - regionsInput.value / 6), 6);
|
const stateLabelSize = Math.max(rn(24 - regionsInput.value / 6), 6);
|
||||||
labels.select("#states").attr("fill", "#3e3e4b").attr("opacity", 1).attr("stroke", "#3a3a3a").attr("stroke-width", 0).attr("font-family", "Almendra SC").attr("data-font", "Almendra+SC").attr("font-size", stateLabelSize).attr("data-size", stateLabelSize).attr("filter", null);
|
labels.select("#states").attr("fill", "#3e3e4b").attr("opacity", 1).attr("stroke", "#3a3a3a").attr("stroke-width", 0).attr("font-family", "Almendra SC").attr("data-font", "Almendra+SC").attr("font-size", stateLabelSize).attr("data-size", stateLabelSize).attr("filter", null);
|
||||||
labels.select("#addedLabels").attr("fill", "#3e3e4b").attr("opacity", 1).attr("stroke", "#3a3a3a").attr("stroke-width", 0).attr("font-family", "Almendra SC").attr("data-font", "Almendra+SC").attr("font-size", 18).attr("data-size", 18).attr("filter", null);
|
labels.select("#addedLabels").attr("fill", "#3e3e4b").attr("opacity", 1).attr("stroke", "#3a3a3a").attr("stroke-width", 0).attr("font-family", "Almendra SC").attr("data-font", "Almendra+SC").attr("font-size", 18).attr("data-size", 18).attr("filter", null);
|
||||||
|
invokeActiveZooming();
|
||||||
}
|
}
|
||||||
|
|
||||||
// focus on coordinates, cell or burg provided in searchParams
|
// focus on coordinates, cell or burg provided in searchParams
|
||||||
function focusOn() {
|
function focusOn() {
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
const params = url.searchParams;
|
const params = url.searchParams;
|
||||||
|
|
||||||
if (params.get("from") === "MFCG") {
|
if (params.get("from") === "MFCG") {
|
||||||
|
|
@ -480,7 +482,7 @@ function invokeActiveZooming() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// rescale map markers
|
// rescale map markers
|
||||||
if (markers.style("display") !== "none") {
|
if (styleRescaleMarkers.checked && markers.style("display") !== "none") {
|
||||||
markers.selectAll("use").each(function(d) {
|
markers.selectAll("use").each(function(d) {
|
||||||
const x = +this.dataset.x, y = +this.dataset.y, desired = +this.dataset.size;
|
const x = +this.dataset.x, y = +this.dataset.y, desired = +this.dataset.size;
|
||||||
const size = Math.max(desired * 5 + 25 / scale, 1);
|
const size = Math.max(desired * 5 + 25 / scale, 1);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
console.time('generateCultures');
|
console.time('generateCultures');
|
||||||
cells = pack.cells;
|
cells = pack.cells;
|
||||||
cells.culture = new Int8Array(cells.i.length); // cell cultures
|
cells.culture = new Int8Array(cells.i.length); // cell cultures
|
||||||
let count = +culturesInput.value;
|
let count = +culturesInput.value;
|
||||||
|
|
||||||
const populated = cells.i.filter(i => cells.s[i]).sort((a, b) => cells.s[b] - cells.s[a]); // cells sorted by population
|
const populated = cells.i.filter(i => cells.s[i]).sort((a, b) => cells.s[b] - cells.s[a]); // cells sorted by population
|
||||||
if (populated.length < count * 25) {
|
if (populated.length < count * 25) {
|
||||||
|
|
@ -38,8 +38,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pack.cultures = d3.shuffle(getDefault()).slice(0, count);
|
pack.cultures = getRandomCultures(count);
|
||||||
const centers = d3.quadtree();
|
const centers = d3.quadtree();
|
||||||
const colors = getColors(count);
|
const colors = getColors(count);
|
||||||
|
|
||||||
pack.cultures.forEach(function(culture, i) {
|
pack.cultures.forEach(function(culture, i) {
|
||||||
|
|
@ -60,6 +60,17 @@
|
||||||
const invalidBase = pack.cultures.some(c => !nameBase[c.base]);
|
const invalidBase = pack.cultures.some(c => !nameBase[c.base]);
|
||||||
if (invalidBase) applyDefaultNamesData();
|
if (invalidBase) applyDefaultNamesData();
|
||||||
|
|
||||||
|
function getRandomCultures(c) {
|
||||||
|
const d = getDefault();
|
||||||
|
const cultures = [];
|
||||||
|
while (cultures.length < c) {
|
||||||
|
let culture = d[0];
|
||||||
|
do {culture = d[rand(d.length-1)];} while (Math.random() > culture.odd || cultures.find(c => c.name === culture.name))
|
||||||
|
cultures.push(culture);
|
||||||
|
}
|
||||||
|
return cultures;
|
||||||
|
}
|
||||||
|
|
||||||
// culture center tends to be placed in a density populated cell
|
// culture center tends to be placed in a density populated cell
|
||||||
function placeCultureCenter() {
|
function placeCultureCenter() {
|
||||||
let center, spacing = (graphWidth + graphHeight) / count;
|
let center, spacing = (graphWidth + graphHeight) / count;
|
||||||
|
|
@ -99,36 +110,38 @@
|
||||||
|
|
||||||
const getDefault = function() {
|
const getDefault = function() {
|
||||||
return [
|
return [
|
||||||
{name:"Shwazen", base:0},
|
{name:"Shwazen", base:0, odd: .7},
|
||||||
{name:"Angshire", base:1},
|
{name:"Angshire", base:1, odd: 1},
|
||||||
{name:"Luari", base:2},
|
{name:"Luari", base:2, odd: .6},
|
||||||
{name:"Tallian", base:3},
|
{name:"Tallian", base:3, odd: .6},
|
||||||
{name:"Astellian", base:4},
|
{name:"Astellian", base:4, odd: .6},
|
||||||
{name:"Slovan", base:5},
|
{name:"Slovan", base:5, odd: .7},
|
||||||
{name:"Norse", base:6},
|
{name:"Norse", base:6, odd: .7},
|
||||||
{name:"Elladan", base:7},
|
{name:"Elladan", base:7, odd: .7},
|
||||||
{name:"Romian", base:8},
|
{name:"Romian", base:8, odd: .7},
|
||||||
{name:"Soumi", base:9},
|
{name:"Soumi", base:9, odd: .4},
|
||||||
{name:"Koryo", base:10},
|
{name:"Koryo", base:10, odd: .5},
|
||||||
{name:"Hantzu", base:11},
|
{name:"Hantzu", base:11, odd: .5},
|
||||||
{name:"Yamoto", base:12},
|
{name:"Yamoto", base:12, odd: .5},
|
||||||
{name:"Portuzian", base:13},
|
{name:"Portuzian", base:13, odd: .4},
|
||||||
{name:"Nawatli", base:14},
|
{name:"Nawatli", base:14, odd: .2},
|
||||||
{name:"Vengrian", base: 15},
|
{name:"Vengrian", base: 15, odd: .2},
|
||||||
{name:"Turchian", base: 16},
|
{name:"Turchian", base: 16, odd: .2},
|
||||||
{name:"Berberan", base: 17},
|
{name:"Berberan", base: 17, odd: .2},
|
||||||
{name:"Eurabic", base: 18},
|
{name:"Eurabic", base: 18, odd: .2},
|
||||||
{name:"Inuk", base: 19},
|
{name:"Inuk", base: 19, odd: .1},
|
||||||
{name:"Euskati", base: 20},
|
{name:"Euskati", base: 20, odd: .1},
|
||||||
{name:"Negarian", base: 21},
|
{name:"Negarian", base: 21, odd: .05},
|
||||||
{name:"Keltan", base: 22},
|
{name:"Keltan", base: 22, odd: .1},
|
||||||
{name:"Efratic", base: 23},
|
{name:"Efratic", base: 23, odd: .1},
|
||||||
{name:"Tehrani", base: 24},
|
{name:"Tehrani", base: 24, odd: .1},
|
||||||
{name:"Maui", base: 25},
|
{name:"Maui", base: 25, odd: .05},
|
||||||
{name:"Carnatic", base: 26},
|
{name:"Carnatic", base: 26, odd: .1},
|
||||||
{name:"Inqan", base: 27},
|
{name:"Inqan", base: 27, odd: .1},
|
||||||
{name:"Kiswaili", base: 28},
|
{name:"Kiswaili", base: 28, odd: .1},
|
||||||
{name:"Vietic", base: 29}
|
{name:"Vietic", base: 29, odd: .1}//,
|
||||||
|
//{name:"Guantzu", base:30, odd: 1},
|
||||||
|
//{name:"Ulus", base:31, odd: .1}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -378,7 +378,7 @@ function editCultures() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addCulture() {
|
function addCulture() {
|
||||||
const defaultCultures = Cultures.getDefault();
|
const defaultCultures = Cultures.getDefault();
|
||||||
let culture, base, name;
|
let culture, base, name;
|
||||||
if (pack.cultures.length < defaultCultures.length) {
|
if (pack.cultures.length < defaultCultures.length) {
|
||||||
// add one of the default cultures
|
// add one of the default cultures
|
||||||
|
|
|
||||||
|
|
@ -337,9 +337,6 @@ function togglePopulation() {
|
||||||
function drawPopulation() {
|
function drawPopulation() {
|
||||||
population.selectAll("line").remove();
|
population.selectAll("line").remove();
|
||||||
const cells = pack.cells, p = cells.p, burgs = pack.burgs;
|
const cells = pack.cells, p = cells.p, burgs = pack.burgs;
|
||||||
|
|
||||||
// pack.cells.pop.reduce((s=0,v) => s+v)
|
|
||||||
// pack.burgs.map(b => b.population).reduce((s=0,v) => s+v)
|
|
||||||
const show = d3.transition().duration(2000).ease(d3.easeSinIn);
|
const show = d3.transition().duration(2000).ease(d3.easeSinIn);
|
||||||
|
|
||||||
const rural = Array.from(cells.i.filter(i => cells.pop[i] > 0), i => [p[i][0], p[i][1], p[i][1] - cells.pop[i] / 8]);
|
const rural = Array.from(cells.i.filter(i => cells.pop[i] > 0), i => [p[i][0], p[i][1], p[i][1] - cells.pop[i] / 8]);
|
||||||
|
|
@ -348,7 +345,7 @@ function drawPopulation() {
|
||||||
.attr("x2", d => d[0]).attr("y2", d => d[1])
|
.attr("x2", d => d[0]).attr("y2", d => d[1])
|
||||||
.transition(show).attr("y2", d => d[2]);
|
.transition(show).attr("y2", d => d[2]);
|
||||||
|
|
||||||
const urban = burgs.filter(b => b.i).map(b => [b.x, b.y, b.y - b.population / 8 * urbanization.value]);
|
const urban = burgs.filter(b => b.i && !b.removed).map(b => [b.x, b.y, b.y - b.population / 8 * urbanization.value]);
|
||||||
population.select("#urban").selectAll("line").data(urban).enter().append("line")
|
population.select("#urban").selectAll("line").data(urban).enter().append("line")
|
||||||
.attr("x1", d => d[0]).attr("y1", d => d[1])
|
.attr("x1", d => d[0]).attr("y1", d => d[1])
|
||||||
.attr("x2", d => d[0]).attr("y2", d => d[1])
|
.attr("x2", d => d[0]).attr("y2", d => d[1])
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,8 @@ function selectStyleElement() {
|
||||||
if (sel === "gridOverlay") styleGrid.style.display = "block";
|
if (sel === "gridOverlay") styleGrid.style.display = "block";
|
||||||
if (sel === "terrain") styleRelief.style.display = "block";
|
if (sel === "terrain") styleRelief.style.display = "block";
|
||||||
if (sel === "texture") styleTexture.style.display = "block";
|
if (sel === "texture") styleTexture.style.display = "block";
|
||||||
if (sel === "routes" || sel === "labels" || sel == "anchors" || sel == "burgIcons" || sel === "lakes") {styleGroup.style.display = "block";}
|
if (sel === "routes" || sel === "labels" || sel == "anchors" || sel == "burgIcons" || sel === "lakes") styleGroup.style.display = "block";
|
||||||
|
if (sel === "markers") styleMarkers.style.display = "block";
|
||||||
|
|
||||||
if (sel === "population") {
|
if (sel === "population") {
|
||||||
stylePopulation.style.display = "block";
|
stylePopulation.style.display = "block";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue