mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
v. 0.59.09b
This commit is contained in:
parent
1fcef32b20
commit
5bfe920eed
2 changed files with 20 additions and 23 deletions
|
|
@ -32,8 +32,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.59.08b"/>
|
<link rel="stylesheet" type="text/css" href="index.css?version=0.59.09b"/>
|
||||||
<link rel="stylesheet" type="text/css" href="icons.css?version=0.59.08b"/>
|
<link rel="stylesheet" type="text/css" href="icons.css?version=0.59.09b"/>
|
||||||
<link rel="stylesheet" type="text/css" href="libs/jquery-ui.css"/>
|
<link rel="stylesheet" type="text/css" href="libs/jquery-ui.css"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
@ -551,7 +551,7 @@
|
||||||
<div id="customizeOptions">
|
<div id="customizeOptions">
|
||||||
<input id="renderOcean" class="checkbox" type="checkbox">
|
<input id="renderOcean" class="checkbox" type="checkbox">
|
||||||
<label for="renderOcean" onmouseover="tip('Render cells below sea level')" class="checkbox-label">Render ocean cells</label>
|
<label for="renderOcean" onmouseover="tip('Render cells below sea level')" class="checkbox-label">Render ocean cells</label>
|
||||||
<input id="changeHeights" class="checkbox" type="checkbox" checked>
|
<input id="changeHeights" class="checkbox" type="checkbox">
|
||||||
<label for="changeHeights" onmouseover="tip('Allow system to change custom heights if reasonable')" class="checkbox-label">Change heights</label>
|
<label for="changeHeights" onmouseover="tip('Allow system to change custom heights if reasonable')" class="checkbox-label">Change heights</label>
|
||||||
</div>
|
</div>
|
||||||
<label onmouseover="tip('Number of Land cells and landmass/ocean ratio')">Landmass:
|
<label onmouseover="tip('Number of Land cells and landmass/ocean ratio')">Landmass:
|
||||||
|
|
@ -1143,5 +1143,5 @@
|
||||||
<input type="file" accept=".txt" id="namesbaseToLoad">
|
<input type="file" accept=".txt" id="namesbaseToLoad">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="script.js?version=0.59.08b"></script>
|
<script src="script.js?version=0.59.09b"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
35
script.js
35
script.js
|
|
@ -7424,7 +7424,7 @@ function fantasyMap() {
|
||||||
if (i === 0) width = "4px";
|
if (i === 0) width = "4px";
|
||||||
var clr = color(1-i/100);
|
var clr = color(1-i/100);
|
||||||
var style = "background-color: " + clr + "; width: " + width;
|
var style = "background-color: " + clr + "; width: " + width;
|
||||||
div.append("div").attr("data-color", i/100).attr("style", style);
|
div.append("div").attr("data-color", i).attr("style", style);
|
||||||
}
|
}
|
||||||
div.selectAll("*").on("touchmove mousemove", showHeight).on("click", assignHeight);
|
div.selectAll("*").on("touchmove mousemove", showHeight).on("click", assignHeight);
|
||||||
}
|
}
|
||||||
|
|
@ -7474,8 +7474,8 @@ function fantasyMap() {
|
||||||
colors.push([r, g, b]);
|
colors.push([r, g, b]);
|
||||||
});
|
});
|
||||||
var cmap = MMCQ.quantize(colors, count);
|
var cmap = MMCQ.quantize(colors, count);
|
||||||
|
heights = new Uint8Array(points.length);
|
||||||
polygons.map(function(i, d) {
|
polygons.map(function(i, d) {
|
||||||
cells[d].height = undefined;
|
|
||||||
var nearest = cmap.nearest(colors[d]);
|
var nearest = cmap.nearest(colors[d]);
|
||||||
var rgb = "rgb(" + nearest[0] + ", " + nearest[1] + ", " + nearest[2] + ")";
|
var rgb = "rgb(" + nearest[0] + ", " + nearest[1] + ", " + nearest[2] + ")";
|
||||||
var hex = toHEX(rgb);
|
var hex = toHEX(rgb);
|
||||||
|
|
@ -7509,7 +7509,7 @@ function fantasyMap() {
|
||||||
if (el.attr("data-height")) {
|
if (el.attr("data-height")) {
|
||||||
var height = el.attr("data-height");
|
var height = el.attr("data-height");
|
||||||
$("#colorScheme div[data-color='" + height + "']").addClass("hoveredColor");
|
$("#colorScheme div[data-color='" + height + "']").addClass("hoveredColor");
|
||||||
$("#colorsSelectValue").text(rn(height * 100));
|
$("#colorsSelectValue").text(height);
|
||||||
}
|
}
|
||||||
var color = "#" + d3.select(this).attr("id");
|
var color = "#" + d3.select(this).attr("id");
|
||||||
landmass.selectAll("path").classed("selectedCell", 0);
|
landmass.selectAll("path").classed("selectedCell", 0);
|
||||||
|
|
@ -7518,8 +7518,8 @@ function fantasyMap() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function showHeight() {
|
function showHeight() {
|
||||||
var el = d3.select(this);
|
let el = d3.select(this);
|
||||||
var height = rn(el.attr("data-color") * 100);
|
let height = el.attr("data-color");
|
||||||
$("#colorsSelectValue").text(height);
|
$("#colorsSelectValue").text(height);
|
||||||
$("#colorScheme .hoveredColor").removeClass("hoveredColor");
|
$("#colorScheme .hoveredColor").removeClass("hoveredColor");
|
||||||
el.classed("hoveredColor", 1);
|
el.classed("hoveredColor", 1);
|
||||||
|
|
@ -7528,7 +7528,7 @@ function fantasyMap() {
|
||||||
function assignHeight() {
|
function assignHeight() {
|
||||||
var sel = $(".selectedColor")[0];
|
var sel = $(".selectedColor")[0];
|
||||||
var height = +d3.select(this).attr("data-color");
|
var height = +d3.select(this).attr("data-color");
|
||||||
var rgb = color(1-height);
|
var rgb = color(1 - height / 100);
|
||||||
var hex = toHEX(rgb);
|
var hex = toHEX(rgb);
|
||||||
sel.style.backgroundColor = rgb;
|
sel.style.backgroundColor = rgb;
|
||||||
sel.setAttribute("data-height", height);
|
sel.setAttribute("data-height", height);
|
||||||
|
|
@ -7536,8 +7536,8 @@ function fantasyMap() {
|
||||||
sel.id = hex.substr(1);
|
sel.id = hex.substr(1);
|
||||||
landmass.selectAll(".selectedCell").each(function() {
|
landmass.selectAll(".selectedCell").each(function() {
|
||||||
d3.select(this).attr("fill", hex).attr("stroke", hex);
|
d3.select(this).attr("fill", hex).attr("stroke", hex);
|
||||||
var i = +d3.select(this).attr("data-i");
|
let i = +d3.select(this).attr("data-i");
|
||||||
cells[i].height = height;
|
heights[i] = height;
|
||||||
});
|
});
|
||||||
var parent = sel.parentNode;
|
var parent = sel.parentNode;
|
||||||
if (parent.id === "colorsUnassigned") {
|
if (parent.id === "colorsUnassigned") {
|
||||||
|
|
@ -7569,11 +7569,10 @@ function fantasyMap() {
|
||||||
$("#landmass > path, .color-div").remove();
|
$("#landmass > path, .color-div").remove();
|
||||||
$("#colorsAssigned").fadeIn();
|
$("#colorsAssigned").fadeIn();
|
||||||
$("#colorsUnassigned").fadeOut();
|
$("#colorsUnassigned").fadeOut();
|
||||||
var heights = [];
|
polygons.forEach(function(i, d) {
|
||||||
polygons.map(function(i, d) {
|
|
||||||
var x = rn(i.data[0]), y = rn(i.data[1]);
|
var x = rn(i.data[0]), y = rn(i.data[1]);
|
||||||
if (y == svgHeight) {y--;}
|
if (y == svgHeight) y--;
|
||||||
if (x == svgWidth) {x--;}
|
if (x == svgWidth) x--;
|
||||||
var p = (x + y * svgWidth) * 4;
|
var p = (x + y * svgWidth) * 4;
|
||||||
var r = data[p], g = data[p + 1], b = data[p + 2];
|
var r = data[p], g = data[p + 1], b = data[p + 2];
|
||||||
var lab = d3.lab("rgb(" + r + ", " + g + ", " + b + ")");
|
var lab = d3.lab("rgb(" + r + ", " + g + ", " + b + ")");
|
||||||
|
|
@ -7582,18 +7581,16 @@ function fantasyMap() {
|
||||||
} else {
|
} else {
|
||||||
var normalized = rn(normalize(lab.l, 0, 100), 2);
|
var normalized = rn(normalize(lab.l, 0, 100), 2);
|
||||||
}
|
}
|
||||||
heights.push(normalized);
|
|
||||||
var rgb = color(1 - normalized);
|
var rgb = color(1 - normalized);
|
||||||
var hex = toHEX(rgb);
|
var hex = toHEX(rgb);
|
||||||
cells[d].height = normalized * 100;
|
heights[d] = normalized * 100;
|
||||||
landmass.append("path").attr("d", "M" + i.join("L") + "Z").attr("data-i", d).attr("fill", hex).attr("stroke", hex);
|
landmass.append("path").attr("d", "M" + i.join("L") + "Z").attr("data-i", d).attr("fill", hex).attr("stroke", hex);
|
||||||
});
|
});
|
||||||
heights.sort(function(a, b) {return a - b;});
|
let unique = [...new Set(heights)].sort();
|
||||||
var unique = [...new Set(heights)];
|
unique.forEach(function(h) {
|
||||||
unique.map(function(i) {
|
var rgb = color(1 - h / 100);
|
||||||
var rgb = color(1 - i);
|
|
||||||
var hex = toHEX(rgb);
|
var hex = toHEX(rgb);
|
||||||
$("#colorsAssigned").append('<div class="color-div" id="' + hex.substr(1) + '" data-height="' + i + '" style="background-color: ' + hex + ';"/>');
|
$("#colorsAssigned").append('<div class="color-div" id="' + hex.substr(1) + '" data-height="' + h + '" style="background-color: ' + hex + ';"/>');
|
||||||
});
|
});
|
||||||
$(".color-div").click(selectColor);
|
$(".color-div").click(selectColor);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue