Public
Edited
Jan 29, 2023
Importers
Insert cell
Insert cell
Insert cell
function noise(a,b,c){
switch (arguments.length){
case 0:
return (simplex.noise2D(0,0)+1)/2
break;
case 1:
return (simplex.noise2D(a,0)+1)/2
break;
case 2:
return (simplex.noise2D(a,b)+1)/2
break;
default:
return (simplex.noise3D(a,b,c)+1)/2
}
}
Insert cell
simplex = new simplexNoise(42)
Insert cell
simplexNoise = require('simplex-noise@2.4.0')
Insert cell
Insert cell
function random(max) {
return ~~(Math.random() * max);
}
Insert cell
---
## A function to emulate P5.js map() function using D3
Insert cell
function map (value, start1, stop1, start2, stop2) {
return d3.scaleLinear()
.domain([start1, stop1])
.range([start2, stop2])(value)
}
Insert cell
function bool() {
return Math.random() > 0.5; // random bool
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {Vector} from "@esperanc/2d-geometry-utils"
Insert cell
a = new Vector(10,20)
Insert cell
b = new Vector(1,20)
Insert cell
a.add(b)
Insert cell
Insert cell
PI = Math.PI
Insert cell
TAU = PI*2
Insert cell
Insert cell
function recursiveRandom(count) {
let n = 1;
while (count > 0) {
n *= Math.random();
count--;
}
return n
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more