xxxxxxxxxx
33
// Spread the distribution around 360 degrees
let distribution = new Array(360);
function setup() {
createCanvas(400, 400);
frameRate(5);
}
function draw() {
background(220);
stroke(random(255), random(255), random(255));
// Go around for each of the 360 degrees and create
// a random value that will be close to 0, but
// up to +- 15 difference. Floor will chop off
// the decimal so we have whole numbers and
// absolute value will ensure we only have positive #
for (let i = 0; i < distribution.length; i++) {
distribution[i] = abs(floor(randomGaussian(0, 15)));
}
// Move to center
translate(width / 2, width / 2);
// Draw each of the 360 rays going out at each angle
for (let i = 0; i < distribution.length; i++) {
// Rotate first, then draw a "straight" line
rotate(TWO_PI / distribution.length);
line(0, 0, distribution[i], 0);
}
}