From 8531bc6c3a06a335c4b746ecebf0a7b974501b1c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 27 Oct 2023 19:41:21 +0200 Subject: [PATCH] Add v6 biomes flags --- index.html | 19 +++++ mibpov.js | 221 ++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 177 insertions(+), 63 deletions(-) diff --git a/index.html b/index.html index c74f4c0..703bbae 100644 --- a/index.html +++ b/index.html @@ -89,6 +89,25 @@ A Voronoi diagram is supposed to be here but for some reason it cannot be displa + +

Diagram view settings

diff --git a/mibpov.js b/mibpov.js index afcc0d8..9a93775 100644 --- a/mibpov.js +++ b/mibpov.js @@ -131,7 +131,7 @@ let viewY = 0; let v6_flag_snowbiomes = true; let v6_flag_jungles = true; -let v6_freq_desert = 0.5; +let v6_freq_desert = 0.45; // Biome noise settings const NOISE_OFFSET_DEFAULT = 50; @@ -1148,7 +1148,7 @@ function drawV6() { return false; } - if (v6_flag_snowbiomes) { + if (true) { let cx, cy; @@ -1157,62 +1157,115 @@ function drawV6() { let cx_snow, cx_hot, cx_snow2, cy_snow2, cx_hot2, cy_hot2; let _; // unused variable - // Temperate <-> Taiga/Tundra - [cx_snow, _] = biomeCoordsToCanvasPixelCoords(MGV6_FREQ_SNOW, 0); - // Temperate <-> Desert/Jungle - [cx_hot, _] = biomeCoordsToCanvasPixelCoords(MGV6_FREQ_HOT, 0); + let freq_jungle, freq_hot; + if (v6_flag_snowbiomes) { + freq_jungle = MGV6_FREQ_JUNGLE; + freq_hot = MGV6_FREQ_HOT; + // Temperate <-> Taiga/Tundra + [cx_snow, _] = biomeCoordsToCanvasPixelCoords(MGV6_FREQ_SNOW, 0); + // Temperate <-> Desert/Jungle + [cx_hot, _] = biomeCoordsToCanvasPixelCoords(freq_hot, 0); + + } else { + // Temperate <-> Desert/Jungle + freq_hot = v6_freq_desert; + [cx_hot, _] = biomeCoordsToCanvasPixelCoords(freq_hot, 0); + freq_jungle = 0.75; + } + // Taiga <-> Tundra <-> Temperate [cx_snow2, cy_snow2] = biomeCoordsToCanvasPixelCoords(MGV6_FREQ_SNOW, MGV6_FREQ_TAIGA); // Desert <-> Jungle <-> Temperate - [cx_hot2, cy_hot2] = biomeCoordsToCanvasPixelCoords(MGV6_FREQ_HOT, MGV6_FREQ_JUNGLE); + [cx_hot2, cy_hot2] = biomeCoordsToCanvasPixelCoords(freq_hot, freq_jungle); if (showCellColors) { // Render biome areas context.fillStyle = CELL_COLOR_V6_NORMAL; - // Temperate - context.beginPath(); - context.moveTo(cx_snow, 0); - context.lineTo(cx_snow, h); - context.lineTo(cx_hot, h); - context.lineTo(cx_hot, 0); - context.closePath(); - context.fill(); - // Tundra - context.fillStyle = CELL_COLOR_V6_TUNDRA; - context.beginPath(); - context.moveTo(0, 0); - context.lineTo(cx_snow2, 0); - context.lineTo(cx_snow2, cy_snow2); - context.lineTo(0, cy_snow2); - context.closePath(); - context.fill(); - // Taiga - context.fillStyle = CELL_COLOR_V6_TAIGA; - context.beginPath(); - context.moveTo(cx_snow2, cy_snow2); - context.lineTo(cx_snow2, h); - context.lineTo(0, h); - context.lineTo(0, cy_snow2); - context.closePath(); - context.fill(); - // Jungle - context.fillStyle = CELL_COLOR_V6_JUNGLE; - context.beginPath(); - context.moveTo(w, 0); - context.lineTo(cx_hot2, 0); - context.lineTo(cx_hot2, cy_hot2); - context.lineTo(w, cy_hot2); - context.closePath(); - context.fill(); - // Desert - context.fillStyle = CELL_COLOR_V6_DESERT; - context.beginPath(); - context.moveTo(cx_hot2, cy_hot2); - context.lineTo(cx_hot2, h); - context.lineTo(w, h); - context.lineTo(w, cy_snow2); - context.closePath(); - context.fill(); + if (v6_flag_snowbiomes) { + // Temperate + context.beginPath(); + context.moveTo(cx_snow, 0); + context.lineTo(cx_snow, h); + context.lineTo(cx_hot, h); + context.lineTo(cx_hot, 0); + context.closePath(); + context.fill(); + // Tundra + context.fillStyle = CELL_COLOR_V6_TUNDRA; + context.beginPath(); + context.moveTo(0, 0); + context.lineTo(cx_snow2, 0); + context.lineTo(cx_snow2, cy_snow2); + context.lineTo(0, cy_snow2); + context.closePath(); + context.fill(); + // Taiga + context.fillStyle = CELL_COLOR_V6_TAIGA; + context.beginPath(); + context.moveTo(cx_snow2, cy_snow2); + context.lineTo(cx_snow2, h); + context.lineTo(0, h); + context.lineTo(0, cy_snow2); + context.closePath(); + context.fill(); + // Jungle + context.fillStyle = CELL_COLOR_V6_JUNGLE; + context.beginPath(); + context.moveTo(w, 0); + context.lineTo(cx_hot2, 0); + context.lineTo(cx_hot2, cy_hot2); + context.lineTo(w, cy_hot2); + context.closePath(); + context.fill(); + // Desert + context.fillStyle = CELL_COLOR_V6_DESERT; + context.beginPath(); + context.moveTo(cx_hot2, cy_hot2); + context.lineTo(cx_hot2, h); + context.lineTo(w, h); + context.lineTo(w, cy_hot2); + context.closePath(); + context.fill(); + } else { + // Temperate + context.beginPath(); + context.moveTo(0, 0); + context.lineTo(0, h); + context.lineTo(cx_hot, h); + context.lineTo(cx_hot, 0); + context.closePath(); + context.fill(); + if (v6_flag_jungles) { + // Jungle + context.fillStyle = CELL_COLOR_V6_JUNGLE; + context.beginPath(); + context.moveTo(0, 0); + context.lineTo(w, 0); + context.lineTo(w, cy_hot2); + context.lineTo(0, cy_hot2); + context.closePath(); + context.fill(); + // Desert + context.fillStyle = CELL_COLOR_V6_DESERT; + context.beginPath(); + context.moveTo(cx_hot2, cy_hot2); + context.lineTo(cx_hot2, h); + context.lineTo(w, h); + context.lineTo(w, cy_hot2); + context.closePath(); + context.fill(); + } else { + // Desert + context.fillStyle = CELL_COLOR_V6_DESERT; + context.beginPath(); + context.moveTo(cx_hot2, 0); + context.lineTo(cx_hot2, h); + context.lineTo(w, h); + context.lineTo(w, 0); + context.closePath(); + context.fill(); + } + } } else { // Use a "neutral" background color for the whole area if cell colors are disabled context.fillStyle = CELL_COLOR_NEUTRAL; @@ -1224,20 +1277,30 @@ function drawV6() { context.strokeStyle = EDGE_COLOR; context.beginPath(); - // Temperate <-> Taiga/Tundra - context.moveTo(cx_snow, 0); - context.lineTo(cx_snow, h); + if (v6_flag_snowbiomes) { + // Temperate <-> Taiga/Tundra + context.moveTo(cx_snow, 0); + context.lineTo(cx_snow, h); + // Taiga <-> Tundra + context.moveTo(cx_snow2, cy_snow2); + context.lineTo(0, cy_snow2); + } // Temperate <-> Desert/Jungle - context.moveTo(cx_hot, 0); - context.lineTo(cx_hot, h); - - // Taiga <-> Tundra - context.moveTo(cx_snow2, cy_snow2); - context.lineTo(0, cy_snow2); - + if (v6_flag_snowbiomes || (!v6_flag_jungles)) { + context.moveTo(cx_hot, 0); + context.lineTo(cx_hot, h); + } else { + context.moveTo(cx_hot, cy_hot2); + context.lineTo(cx_hot, h); + } // Desert <-> Jungle - context.moveTo(cx_hot2, cy_hot2); - context.lineTo(w, cy_hot2); + if (v6_flag_snowbiomes) { + context.moveTo(cx_hot2, cy_hot2); + context.lineTo(w, cy_hot2); + } else if (v6_flag_jungles) { + context.moveTo(0, cy_hot2); + context.lineTo(w, cy_hot2); + } context.closePath(); context.stroke(); @@ -1335,6 +1398,14 @@ function updateWidgetStates() { inputNoiseHumidityScale.value = noises.humidity.scale; inputNoiseHumidityOctaves.value = noises.humidity.octaves; inputNoiseHumidityPersistence.value = noises.humidity.persistence; + + if (v6_flag_snowbiomes) { + inputV6FreqDesert.disabled = true; + inputCheckboxV6Jungles.disabled = true; + } else { + inputV6FreqDesert.disabled = false; + inputCheckboxV6Jungles.disabled = false; + } } /* To be called when a biome value like heat was changed. @@ -1586,6 +1657,8 @@ function checkboxVarsInit() { showCellColors = inputCheckboxCellColors.checked; showGrid = inputCheckboxGrid.checked; showAxes = inputCheckboxAxes.checked; + v6_flag_snowbiomes = inputCheckboxV6Snowbiomes.checked; + v6_flag_jungles = inputCheckboxV6Jungles.checked; } /* Collapses/Expands a config section */ @@ -1917,6 +1990,23 @@ inputCheckboxAxes.onchange = function() { showAxes = this.checked; draw(false); } +inputCheckboxV6Snowbiomes.onchange = function() { + v6_flag_snowbiomes = this.checked; + updateWidgetStates(); + draw(false); +} +inputCheckboxV6Jungles.onchange = function() { + v6_flag_jungles = this.checked; + draw(false); +} +inputV6FreqDesert.oninput = function() { + let f = +this.value; + if (f === null) { + return; + } + v6_freq_desert = f; + draw(true); +} /* Noise parameters events */ @@ -2221,6 +2311,7 @@ inputImportSubmit.onclick = function() { modernModeButton.onclick = function() { biomeMode = "modern"; biomeConfigContainerOuter.hidden = false; + biomeV6ConfigContainerOuter.hidden = true; importContainerOuter.hidden = false; exportContainerOuter.hidden = false; inputCheckboxPoints.disabled = false; @@ -2235,6 +2326,7 @@ modernModeButton.onclick = function() { v6ModeButton.onclick = function() { biomeMode = "v6"; biomeConfigContainerOuter.hidden = true; + biomeV6ConfigContainerOuter.hidden = false; importContainerOuter.hidden = true; exportContainerOuter.hidden = true; inputCheckboxPoints.disabled = true; @@ -2252,6 +2344,9 @@ v6ModeButton.onclick = function() { biomeConfigHeaderLink.onclick = function() { toggleConfigSectionDisplay(this, biomeConfigContainer); } +biomeV6ConfigHeaderLink.onclick = function() { + toggleConfigSectionDisplay(this, biomeV6ConfigContainer); +} viewConfigHeaderLink.onclick = function() { toggleConfigSectionDisplay(this, viewConfigContainer); }