Published
Edited
Apr 1, 2021
1 fork
Insert cell
Insert cell
function frag1(x, y) {
let n = 0;
for (let i = -2; i < 2; i++) {
const noiseScale = Math.exp(i * 2);
n += simplexNoise.noise3D(x * noiseScale, y * noiseScale, i);
}
return greyShade(n / 2 + 0.5);
}
Insert cell
function saturate(x) {
return Math.max(0, Math.min(1, x));
}
Insert cell
function hue(h) {
const r = Math.abs(h * 6 - 3) - 1;
const g = 2 - Math.abs(h * 6 - 2);
const b = 2 - Math.abs(h * 6 - 4);
return [saturate(r), saturate(g), saturate(b)];
}

Insert cell
base = 1.5
Insert cell
e0 = Math.log(distance / zoomTransform.k) / Math.log(base) - 1;
Insert cell
e1s = {
const a = {};
for (let i = -14; i <= 17; i++) {
a[i] = Math.floor(e0) + i;
}
return a;
}
Insert cell
len1s = {
const a = {};
for (let i = -14; i <= 17; i++) {
a[i] = Math.pow(base, e1s[i]);
}
return a;
}
Insert cell
ampl1s = {
const a = {};
for (let i = -14; i <= 17; i++) {
const e1 = e1s[i];
const de = e1 - e0;
a[i] = Math.exp(-de*de / (110));
}
return a;
}
Insert cell
Insert cell
distance = 550;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function shallowCompare(newObj, prevObj) {
for (const key in newObj) {
if (newObj[key] !== prevObj[key]) return true;
}
return false;
}
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