From 5722540076f8cae788c9ebd9ce745a014be80815 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Fri, 13 Sep 2019 14:58:43 +0300 Subject: [PATCH] v1.0.30 --- index.html | 2 +- modules/ui/heightmap-editor.js | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/index.html b/index.html index 7a87d9a5..685e0ee3 100644 --- a/index.html +++ b/index.html @@ -2975,7 +2975,7 @@ - + diff --git a/modules/ui/heightmap-editor.js b/modules/ui/heightmap-editor.js index ed33a980..510fe449 100644 --- a/modules/ui/heightmap-editor.js +++ b/modules/ui/heightmap-editor.js @@ -1150,25 +1150,25 @@ function getHeight(h) { document.body.insertBefore(canvas, optionsContainer); ctx.drawImage(img, 0, 0, svgWidth, svgHeight); - const simplex = new SimplexNoise(); // SimplexNoise by Jonas Wagner - const noise = (nx, ny) => simplex.noise2D(nx, ny) / 2 + .5; + // const simplex = new SimplexNoise(); // SimplexNoise by Jonas Wagner + // const noise = (nx, ny) => simplex.noise2D(nx, ny) / 2 + .5; - const imageData = ctx.getImageData(0, 0, svgWidth, svgHeight); - for (let i=0; i < imageData.data.length; i+=4) { - const v = imageData.data[i]; - if (v < 51) { - // water - imageData.data[i] = imageData.data[i+1] = imageData.data[i+2] = 46; - continue; - } + // const imageData = ctx.getImageData(0, 0, svgWidth, svgHeight); + // for (let i=0; i < imageData.data.length; i+=4) { + // const v = imageData.data[i]; + // if (v < 51) { + // // water + // // imageData.data[i] = imageData.data[i+1] = imageData.data[i+2] = 46; + // continue; + // } - const x = i / 4 % svgWidth, y = Math.floor(i / 4 / svgWidth); - const nx = x / svgWidth - .5, ny = y / svgHeight - .5; - const n = noise(4 * nx, 4 * ny) / 4 + noise(16 * nx, 16 * ny) / 16; - const nv = Math.max(Math.min((v + 255 * n) / 2, 255), 51); - imageData.data[i] = imageData.data[i+1] = imageData.data[i+2] = nv; - } - ctx.putImageData(imageData, 0, 0); + // const x = i / 4 % svgWidth, y = Math.floor(i / 4 / svgWidth); + // const nx = x / svgWidth - .5, ny = y / svgHeight - .5; + // const n = noise(4 * nx, 4 * ny) / 4 + noise(16 * nx, 16 * ny) / 16; + // const nv = Math.max(Math.min((v + 255 * n) / 2, 255), 51); + // imageData.data[i] = imageData.data[i+1] = imageData.data[i+2] = nv; + // } + // ctx.putImageData(imageData, 0, 0); const imgBig = canvas.toDataURL("image/png"); const link = document.createElement("a");