From 847251df580aaadcce285116199d032580725a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Montero=20Lamas?= Date: Fri, 14 Jan 2022 19:56:07 +0100 Subject: [PATCH] Color picker hatches 14-60 Added hatches to number 14 to 60. Updated the code of the color picker to accept multiples rows of hatches. Changed the size of fillRectPointer from 0.9 em to 1.5 em. Added an Update code to upgrade maps to 1.72 to have a grid of 60 svg hatches. Without the update, loaded files appeared with the rectangles for hatches 14-60 empty. --- index.html | 188 ++++++++++++++++++++++++++++++++++--- main.js | 2 +- modules/load.js | 13 ++- modules/ui/editors.js | 17 ++-- modules/ui/zones-editor.js | 6 +- 5 files changed, 196 insertions(+), 30 deletions(-) diff --git a/index.html b/index.html index 27d27e9e..e65765be 100644 --- a/index.html +++ b/index.html @@ -169,31 +169,189 @@ - - - - + - + + + + + + + - + - + - + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -226,7 +384,7 @@
Azgaar's
Fantasy Map Generator
-
v. 1.71
+
v. 1.72

LOADING...

diff --git a/main.js b/main.js index e3cd39f7..4de5b137 100644 --- a/main.js +++ b/main.js @@ -2,7 +2,7 @@ // https://github.com/Azgaar/Fantasy-Map-Generator "use strict"; -const version = "1.71"; // generator version +const version = "1.72"; // generator version document.title += " v" + version; // Switches to disable/enable logging features diff --git a/modules/load.js b/modules/load.js index 67596ba9..4c10c48b 100644 --- a/modules/load.js +++ b/modules/load.js @@ -190,7 +190,7 @@ function parseLoadedData(data) { if (customizationMenu.offsetParent) styleTab.click(); const reliefIcons = document.getElementById("defs-relief").innerHTML; // save relief icons - const hatching = document.getElementById("hatching").cloneNode(true); // save hatching + const newHatching = document.getElementById("hatching").cloneNode(true); // save hatching void (function parseParameters() { const params = data[0].split("|"); @@ -474,7 +474,7 @@ function parseLoadedData(data) { if (!layerIsOn("toggleStates")) regions.attr("display", "none").selectAll("path").remove(); // 1.0 adds hatching - document.getElementsByTagName("defs")[0].appendChild(hatching); + document.getElementsByTagName("defs")[0].appendChild(newHatching); // 1.0 adds zones layer zones = viewbox.insert("g", "#borders").attr("id", "zones").attr("display", "none"); @@ -929,6 +929,13 @@ function parseLoadedData(data) { if (layerIsOn("markers")) drawMarkers(); } } + + if (version < 1.72) { + // v 1.72 changed hatching data + document.getElementById("hatching").remove(); + document.getElementsByTagName("defs")[0].appendChild(newHatching); + }; + })(); void (function checkDataIntegrity() { @@ -1039,7 +1046,7 @@ function parseLoadedData(data) { // sort markers by index pack.markers.sort((a, b) => a.i - b.i); } - })(); + })(); changeMapSize(); diff --git a/modules/ui/editors.js b/modules/ui/editors.js index 368339ad..abd2b6c2 100644 --- a/modules/ui/editors.js +++ b/modules/ui/editors.js @@ -492,8 +492,8 @@ function createPicker() { .attr("id", "picker_" + d) .attr("fill", d) .attr("class", i ? "" : "selected") - .attr("x", i * 22 + 4) - .attr("y", 40) + .attr("x", (i % 15) * 22 + 4) + .attr("y", 40 + Math.floor(i / 15)*20) .attr("width", 16) .attr("height", 16); }); @@ -503,10 +503,11 @@ function createPicker() { .append("rect") .attr("id", "picker_" + this.id) .attr("fill", "url(#" + this.id + ")") - .attr("x", i * 22 + 4) - .attr("y", 61) + .attr("x", (i % 15) * 22 + 4) + .attr("y", Math.floor(i / 15)*20 + (number * 2)) .attr("width", 16) - .attr("height", 16); + .attr("height", 16) + .on("mousemove", () => tip("Click to fill with the hatching " + this.id)); }); colors @@ -516,7 +517,7 @@ function createPicker() { hatches .selectAll("rect") .on("click", pickerFillClicked) - .on("mousemove", () => tip("Click to fill with the hatching")); + //.on("mousemove", () => tip("Click to fill with the hatching " + #("#picker_" + hatch.id) )); // append box const bbox = picker.node().getBBox(); @@ -532,10 +533,10 @@ function createPicker() { .attr("fill", "#ffffff") .attr("stroke", "#5d4651") .on("mousemove", pos); - picker.insert("text", ":first-child").attr("x", 291).attr("y", -10).attr("id", "pickerCloseText").text("✕"); + picker.insert("text", ":first-child").attr("x", width-20).attr("y", -10).attr("id", "pickerCloseText").text("✕"); picker .insert("rect", ":first-child") - .attr("x", 288) + .attr("x", width-23) .attr("y", -21) .attr("id", "pickerCloseRect") .attr("width", 14) diff --git a/modules/ui/zones-editor.js b/modules/ui/zones-editor.js index 00ea9196..79a64e53 100644 --- a/modules/ui/zones-editor.js +++ b/modules/ui/zones-editor.js @@ -80,7 +80,7 @@ function editZones() { const focused = defs.select("#fog #focus" + this.id).size(); lines += `
- +
${c.length}
@@ -344,12 +344,12 @@ function editZones() { function addZonesLayer() { const id = getNextId("zone"); const description = "Unknown zone"; - const fill = "url(#hatch" + (id.slice(4) % 14) + ")"; + const fill = "url(#hatch" + (id.slice(4) % 60) + ")"; zones.append("g").attr("id", id).attr("data-description", description).attr("data-cells", "").attr("fill", fill); const unit = areaUnit.value === "square" ? " " + distanceUnitInput.value + "²" : " " + areaUnit.value; const line = `
- +
0