mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-02-06 10:31:23 +01:00
feat: slider-input web component - Brush size
This commit is contained in:
parent
92243bb48c
commit
ce304fc5eb
9 changed files with 69 additions and 220 deletions
|
|
@ -383,7 +383,7 @@ function editBiomes() {
|
|||
}
|
||||
|
||||
function dragBiomeBrush() {
|
||||
const r = +biomesManuallyBrush.value;
|
||||
const r = +biomesBrush.value;
|
||||
|
||||
d3.event.on("drag", () => {
|
||||
if (!d3.event.dx && !d3.event.dy) return;
|
||||
|
|
@ -425,7 +425,7 @@ function editBiomes() {
|
|||
function moveBiomeBrush() {
|
||||
showMainTip();
|
||||
const point = d3.mouse(this);
|
||||
const radius = +biomesManuallyBrush.value;
|
||||
const radius = +biomesBrush.value;
|
||||
moveCircle(point[0], point[1], radius);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ function editHeightmap(options) {
|
|||
return;
|
||||
}
|
||||
|
||||
moveCircle(x, y, brushRadius.valueAsNumber, "#333");
|
||||
moveCircle(x, y, heightmapBrushRadius.valueAsNumber, "#333");
|
||||
}
|
||||
|
||||
// get user-friendly (real-world) height value from map data
|
||||
|
|
@ -664,7 +664,7 @@ function editHeightmap(options) {
|
|||
const fromCell = +lineCircle.attr("data-cell");
|
||||
debug.selectAll("*").remove();
|
||||
|
||||
const power = byId("linePower").valueAsNumber;
|
||||
const power = byId("heightmapLinePower").valueAsNumber;
|
||||
if (power === 0) return tip("Power should not be zero", false, "error");
|
||||
|
||||
const heights = grid.cells.h;
|
||||
|
|
@ -686,7 +686,7 @@ function editHeightmap(options) {
|
|||
}
|
||||
|
||||
function dragBrush() {
|
||||
const r = brushRadius.valueAsNumber;
|
||||
const r = heightmapBrushRadius.valueAsNumber;
|
||||
const [x, y] = d3.mouse(this);
|
||||
const start = findGridCell(x, y, grid);
|
||||
|
||||
|
|
@ -704,7 +704,7 @@ function editHeightmap(options) {
|
|||
}
|
||||
|
||||
function changeHeightForSelection(selection, start) {
|
||||
const power = brushPower.valueAsNumber;
|
||||
const power = heightmapBrushPower.valueAsNumber;
|
||||
|
||||
const interpolate = d3.interpolateRound(power, 1);
|
||||
const land = changeOnlyLand.checked;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ function handleKeyup(event) {
|
|||
else if (code === "Tab") toggleOptions(event);
|
||||
else if (code === "Escape") closeAllDialogs();
|
||||
else if (code === "Delete") removeElementOnKey();
|
||||
else if (code === "KeyO" && document.getElementById("canvas3d")) toggle3dOptions();
|
||||
else if (code === "KeyO" && byId("canvas3d")) toggle3dOptions();
|
||||
else if (ctrl && code === "KeyQ") toggleSaveReminder();
|
||||
else if (ctrl && code === "KeyS") saveMap("machine");
|
||||
else if (ctrl && code === "KeyC") saveMap("dropbox");
|
||||
|
|
@ -123,24 +123,21 @@ function allowHotkeys() {
|
|||
function handleSizeChange(key) {
|
||||
let brush = null;
|
||||
|
||||
if (document.getElementById("brushRadius")?.offsetParent) brush = document.getElementById("brushRadius");
|
||||
else if (document.getElementById("linePower")?.offsetParent) brush = document.getElementById("linePower");
|
||||
else if (document.getElementById("biomesManuallyBrush")?.offsetParent)
|
||||
brush = document.getElementById("biomesManuallyBrush");
|
||||
else if (document.getElementById("statesManuallyBrush")?.offsetParent)
|
||||
brush = document.getElementById("statesManuallyBrush");
|
||||
else if (document.getElementById("provincesManuallyBrush")?.offsetParent)
|
||||
brush = document.getElementById("provincesManuallyBrush");
|
||||
else if (document.getElementById("culturesManuallyBrush")?.offsetParent)
|
||||
brush = document.getElementById("culturesManuallyBrush");
|
||||
else if (document.getElementById("zonesBrush")?.offsetParent) brush = document.getElementById("zonesBrush");
|
||||
else if (document.getElementById("religionsManuallyBrush")?.offsetParent)
|
||||
brush = document.getElementById("religionsManuallyBrush");
|
||||
if (byId("heightmapBrushRadius")?.offsetParent) brush = byId("heightmapBrushRadius");
|
||||
else if (byId("heightmapLinePower")?.offsetParent) brush = byId("heightmapLinePower");
|
||||
else if (byId("biomesBrush")?.offsetParent) brush = byId("biomesBrush");
|
||||
else if (byId("culturesBrush")?.offsetParent) brush = byId("culturesBrush");
|
||||
else if (byId("statesBrush")?.offsetParent) brush = byId("statesBrush");
|
||||
else if (byId("provincesBrush")?.offsetParent) brush = byId("provincesBrush");
|
||||
else if (byId("religionsBrush")?.offsetParent) brush = byId("religionsBrush");
|
||||
else if (byId("zonesBrush")?.offsetParent) brush = byId("zonesBrush");
|
||||
|
||||
if (brush) {
|
||||
const change = key === "-" ? -5 : 5;
|
||||
const value = minmax(+brush.value + change, +brush.min, +brush.max);
|
||||
brush.value = document.getElementById(brush.id + "Number").value = value;
|
||||
const min = +brush.getAttribute("min") || 5;
|
||||
const max = +brush.getAttribute("max") || 100;
|
||||
const value = +brush.value + change;
|
||||
brush.value = minmax(value, min, max);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -879,7 +879,7 @@ function editProvinces() {
|
|||
}
|
||||
|
||||
function dragBrush() {
|
||||
const r = +provincesManuallyBrush.value;
|
||||
const r = +provincesBrush.value;
|
||||
|
||||
d3.event.on("drag", () => {
|
||||
if (!d3.event.dx && !d3.event.dy) return;
|
||||
|
|
@ -937,7 +937,7 @@ function editProvinces() {
|
|||
function moveBrush() {
|
||||
showMainTip();
|
||||
const point = d3.mouse(this);
|
||||
const radius = +provincesManuallyBrush.value;
|
||||
const radius = +provincesBrush.value;
|
||||
moveCircle(point[0], point[1], radius);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue