xxxxxxxxxx
39
samples = [];
function setup() {
createCanvas(400, 400);
drawRandom();
}
function draw() {
background(220, 20, 120);
push();
stroke(0);
translate(0, height / 2);
for (let i = 0; i < width; i++) {
line(i, 0, i, samples[i]);
ellipse(i, samples[i], 10, 10);
}
pop();
stroke(255);
for (let i = -3; i <= 3; i++) {
let y = height / 2 + i * (height / 6);
line(0, y, width, y);
}
}
function drawRandom() {
samples.length = 0;
for (let i = 0; i < width; i++) {
let y = randomGaussian(0, height / 6);
samples.push(y);
}
}
function mouseClicked() {
drawRandom();
}