Public
Edited
Feb 2, 2023
Insert cell
Insert cell
Insert cell
p5((s) => {
let system, x, y, n, nf, kn, j, x_shift, shift;
nf = 0;

// Color
let clr = 0;
let bg = s.color(0);

s.setup = function () {
s.createCanvas(W, H);
s.background(bg);
s.noStroke();
};
s.draw = function () {
s.background(bg);
drawLightRect(W * 0.4, H * 0.2, 600, 100);
nf += 0.0001;
};

const drawLightRect = (x, y, h, w) => {
s.push();
s.translate(x, y);
for (let i = 0; i < w; i += s.random(3)) {
for (let j = 0; j < h; j += s.random(3)) {
if (s.random(1) * s.random(1) < j / h) {
s.fill(255);
s.ellipse(i + 50 * s.noise((x + i) * nf, (y + j) * nf), j, 1, 1);
}
}
}

s.pop();
};
})
Insert cell
Insert cell
Insert cell
H = form.height
Insert cell
nf = Math.random()
Insert cell
Insert cell
Insert cell
import { p5 } from "@tmcw/p5"
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