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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more