Public
Edited
Mar 22
4 forks
1 star
Insert cell
Insert cell
Insert cell
cm.raster2D({
width: 580,
height: 450,
fill: (x, y, width, height) => {
x = cm.map(x, 0, width, -2, 1);
y = cm.map(y, 0, height, -1.164, 1.164);
for (var i = 0, a = 0, b = 0, n = max; i < n; i++) {
[a, b] = [a ** 2 - b ** 2 + x, 2 * a * b + y];
if (a ** 2 + b ** 2 > 4) break;
}
return colors[i];
}
})
Insert cell
colors = Array.from({ length: max }, (_, i) => {
const d = d3.interpolateTurbo(i / max);
const { r, g, b, opacity } = d3.color(d).rgb();
return [r, g, b, opacity * 255];
})
Insert cell
Insert cell
Insert cell
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