Public
Edited
Feb 16, 2023
2 forks
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// To draw a new scribble, click the play button over there ----------->
canvas = {
const w = width + 28, h = height;
const context = DOM.context2d(w, h, 1);
const image = context.getImageData(0, 0, w, h);
const indexes = [];
let frame = 0;

context.canvas.style.margin = "0 -14px";

const s = new SimplexNoise(myseed.value)
var x = w >> 1, y = h >> 1;
var newx = x, newy = y;

const resolution = 1000
var points = scribble(resolution)
for (var i = 0; i < points.length; i++) {
newx = (w/2) + (w/3) * points[i][0]
newy = (h/2) + (w/3) * points[i][1]
context.beginPath();
context.lineWidth = 1 + Math.abs(4 * s.noise3D(points[i][0], points[i][1], -1))
context.moveTo(x, y);
context.lineTo(newx, newy);
if (i > 0) {
context.stroke();
}
x = newx
y = newy
if (!(++frame % (resolution / 200))) {
yield context.canvas;
}
}

yield context.canvas;
}
Insert cell
scribble = (resolution = 1000) => {
const s = new SimplexNoise(myseed.value + Math.random())
// const s = new SimplexNoise(myseed.value)
return arcs01(resolution).map(t => {
const angle = t * Math.PI * 2;
// const freq = 1.0
// const amplitude = 0.75;
const x = Math.cos(angle) * freq.value;
const y = Math.sin(angle) * freq.value;
return [
amplitude.value * s.noise3D(x, y, -1),
amplitude.value * s.noise3D(x, y, 1)
];
});
}
Insert cell
// s = new SimplexNoise(Math.random)
Insert cell
Insert cell
Insert cell
Insert cell
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