diff --git a/index.html b/index.html index 5fc64660..299ad0fa 100644 --- a/index.html +++ b/index.html @@ -629,14 +629,23 @@ - + - + - + + + + + + + + + + Fill opacity diff --git a/main.js b/main.js index 59e4ed41..33350732 100644 --- a/main.js +++ b/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); landmass.attr("opacity", 1).attr("fill", "#eef6fb").attr("filter", null); 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); 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"); @@ -331,11 +332,12 @@ function applyDefaultStyle() { 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("#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 function focusOn() { - const url = new URL(window.location.href); + const url = new URL(window.location.href); const params = url.searchParams; if (params.get("from") === "MFCG") { @@ -480,7 +482,7 @@ function invokeActiveZooming() { } // rescale map markers - if (markers.style("display") !== "none") { + if (styleRescaleMarkers.checked && markers.style("display") !== "none") { markers.selectAll("use").each(function(d) { const x = +this.dataset.x, y = +this.dataset.y, desired = +this.dataset.size; const size = Math.max(desired * 5 + 25 / scale, 1); diff --git a/modules/cultures-generator.js b/modules/cultures-generator.js index bf52033d..9472fa65 100644 --- a/modules/cultures-generator.js +++ b/modules/cultures-generator.js @@ -10,7 +10,7 @@ console.time('generateCultures'); cells = pack.cells; 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 if (populated.length < count * 25) { @@ -38,8 +38,8 @@ } } - pack.cultures = d3.shuffle(getDefault()).slice(0, count); - const centers = d3.quadtree(); + pack.cultures = getRandomCultures(count); + const centers = d3.quadtree(); const colors = getColors(count); pack.cultures.forEach(function(culture, i) { @@ -60,6 +60,17 @@ const invalidBase = pack.cultures.some(c => !nameBase[c.base]); 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 function placeCultureCenter() { let center, spacing = (graphWidth + graphHeight) / count; @@ -99,36 +110,38 @@ const getDefault = function() { return [ - {name:"Shwazen", base:0}, - {name:"Angshire", base:1}, - {name:"Luari", base:2}, - {name:"Tallian", base:3}, - {name:"Astellian", base:4}, - {name:"Slovan", base:5}, - {name:"Norse", base:6}, - {name:"Elladan", base:7}, - {name:"Romian", base:8}, - {name:"Soumi", base:9}, - {name:"Koryo", base:10}, - {name:"Hantzu", base:11}, - {name:"Yamoto", base:12}, - {name:"Portuzian", base:13}, - {name:"Nawatli", base:14}, - {name:"Vengrian", base: 15}, - {name:"Turchian", base: 16}, - {name:"Berberan", base: 17}, - {name:"Eurabic", base: 18}, - {name:"Inuk", base: 19}, - {name:"Euskati", base: 20}, - {name:"Negarian", base: 21}, - {name:"Keltan", base: 22}, - {name:"Efratic", base: 23}, - {name:"Tehrani", base: 24}, - {name:"Maui", base: 25}, - {name:"Carnatic", base: 26}, - {name:"Inqan", base: 27}, - {name:"Kiswaili", base: 28}, - {name:"Vietic", base: 29} + {name:"Shwazen", base:0, odd: .7}, + {name:"Angshire", base:1, odd: 1}, + {name:"Luari", base:2, odd: .6}, + {name:"Tallian", base:3, odd: .6}, + {name:"Astellian", base:4, odd: .6}, + {name:"Slovan", base:5, odd: .7}, + {name:"Norse", base:6, odd: .7}, + {name:"Elladan", base:7, odd: .7}, + {name:"Romian", base:8, odd: .7}, + {name:"Soumi", base:9, odd: .4}, + {name:"Koryo", base:10, odd: .5}, + {name:"Hantzu", base:11, odd: .5}, + {name:"Yamoto", base:12, odd: .5}, + {name:"Portuzian", base:13, odd: .4}, + {name:"Nawatli", base:14, odd: .2}, + {name:"Vengrian", base: 15, odd: .2}, + {name:"Turchian", base: 16, odd: .2}, + {name:"Berberan", base: 17, odd: .2}, + {name:"Eurabic", base: 18, odd: .2}, + {name:"Inuk", base: 19, odd: .1}, + {name:"Euskati", base: 20, odd: .1}, + {name:"Negarian", base: 21, odd: .05}, + {name:"Keltan", base: 22, odd: .1}, + {name:"Efratic", base: 23, odd: .1}, + {name:"Tehrani", base: 24, odd: .1}, + {name:"Maui", base: 25, odd: .05}, + {name:"Carnatic", base: 26, odd: .1}, + {name:"Inqan", base: 27, odd: .1}, + {name:"Kiswaili", base: 28, odd: .1}, + {name:"Vietic", base: 29, odd: .1}//, + //{name:"Guantzu", base:30, odd: 1}, + //{name:"Ulus", base:31, odd: .1} ]; } diff --git a/modules/ui/cultures-editor.js b/modules/ui/cultures-editor.js index ad687064..69cbf86e 100644 --- a/modules/ui/cultures-editor.js +++ b/modules/ui/cultures-editor.js @@ -378,7 +378,7 @@ function editCultures() { } function addCulture() { - const defaultCultures = Cultures.getDefault(); + const defaultCultures = Cultures.getDefault(); let culture, base, name; if (pack.cultures.length < defaultCultures.length) { // add one of the default cultures diff --git a/modules/ui/layers.js b/modules/ui/layers.js index 6b2abec4..89ede07e 100644 --- a/modules/ui/layers.js +++ b/modules/ui/layers.js @@ -337,9 +337,6 @@ function togglePopulation() { function drawPopulation() { population.selectAll("line").remove(); 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 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]) .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") .attr("x1", d => d[0]).attr("y1", d => d[1]) .attr("x2", d => d[0]).attr("y2", d => d[1]) diff --git a/modules/ui/options.js b/modules/ui/options.js index a9455569..fd96ba6e 100644 --- a/modules/ui/options.js +++ b/modules/ui/options.js @@ -167,7 +167,8 @@ function selectStyleElement() { if (sel === "gridOverlay") styleGrid.style.display = "block"; if (sel === "terrain") styleRelief.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") { stylePopulation.style.display = "block";