Explain what this does.
// Code that does it. class Slider { constructor(elementId, callback) { const update = () => { this.value = this.slider.valueAsNumber; this.updateOutputs(); callback(); }; this.elementId = elementId; this.slider = document.getElementById(elementId); this.slider.addEventListener('change', update, false); this.slider.addEventListener('input', update, false); this.digits = 2; this.value = this.slider.valueAsNumber; } updateOutputs() { for (let el of document.querySelectorAll("." + this.elementId)) { el.textContent = this.value.toFixed(this.digits); } } }
See Slider.
In the frame below we can view the results.
//wiki.ralfbarkow.ch/assets/pages/js-snippet-template/esm.html HEIGHT 400
~
wget https://www.redblobgames.com/maps/terrain-from-noise/simplemapgen.js
// From https://www.redblobgames.com/maps/terrain-from-noise/ // Copyright 2015 Red Blob Games <redblobgames@gmail.com> // License: Apache v2.0 <https://www.apache.org/licenses/LICENSE-2.0.html> console.info("I'm happy to answer questions about the code; email me at redblobgames@gmail.com"); import SimplexNoise from "simplex-noise"; import SvgRemappingChart from "./visualize-reshaper"; import Map2D from "./map2d"; import Renderer2D from "./render2d"; import Renderer3D from "./render3d"; import RendererBoth from "./renderboth"; import {SEED, makeNoise, fillNoise, mixNoise, reshapeNoiseExponent} from "./noise-utils"; import * as Colormap from "./colormap"
`wget` all imports, except `simplex-noise.ts`:
[rgb@wiki:~/.wiki/127.0.0.1/assets/pages/terrain-from-noise]$ wget https://www.redblobgames.com/maps/terrain-from-noise/node_modules/simplex-noise/simplex-noise.ts --2022-05-08 08:15:39-- https://www.redblobgames.com/maps/terrain-from-noise/node_modules/simplex-noise/simplex-noise.ts Resolving www.redblobgames.com (www.redblobgames.com)... 34.198.241.65, 2600:1f18:1ddd:5500:7259:747f:cbe0:9b5f Connecting to www.redblobgames.com (www.redblobgames.com)|34.198.241.65|:443... connected. HTTP request sent, awaiting response... 404 Not Found 2022-05-08 08:15:39 ERROR 404: Not Found.
pages/terrain-from-noise
See
~
DOT strict digraph rankdir=LR node [style=filled fillcolor=lightyellow penwidth=3 color=black fontname="Helvetica"] HERE NODE node [style=filled fillcolor=lightblue] WHERE /^Next/ LINKS HERE -> NODE node [style=filled fillcolor=white] HERE NODE WHERE /^Next/ LINKS HERE -> NODE node [style=filled fillcolor=white penwidth=3 color=black] LINKS HERE -> NODE node [style=filled fillcolor=white penwidth=1 color=black] HERE NODE LINKS HERE -> NODE node [style="filled,rounded,dotted" fillcolor=white] edge [style=dotted] HERE NODE BACKLINKS NODE -> HERE