xxxxxxxxxx
31
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]);
}
pop();
}
function drawRandom() {
samples.length = 0;
for (let i = 0; i < width; i++) {
let y = randomGaussian(0, height / 6);
samples.push(y);
}
}
function mouseClicked() {
drawRandom();
}