xxxxxxxxxx
53
// Setting some constants
const bars = 5;
const circles = 5;
const margin = 100;
const circleMin = 20;
const circleMax = 150;
function setup() {
createCanvas(750, 750);
colorMode(RGB, 255, 255, 255, 100);
frameRate(1);
}
function draw() {
// clear the background
background(250,250,230);
// calculate some constants
const barSpacing = height / (bars + 1);
const barWidth = width - (2 * margin);
const circSpacing = barWidth / circles;
// Bar plotting loop
for (let i = 0; i < bars; i++) {
// set stroke colour, plot line
stroke(150);
line(margin, barSpacing + (barSpacing * i), // x1, y1
margin + barWidth, barSpacing + (barSpacing * i) // x2, y2
);
// remove stroke, set circle fill
noStroke()
// Circle plotting subloop
for (let j = 0; j < circles; j++) {
fill(50,30,00,40)
ellipse(margin + int(random(circSpacing * j, circSpacing * (j+1))), //x
barSpacing * (i+1), // y
// radius
map((i * 50) + (j * 20), // input
0, // inmin
(50 * bars + 20 * circles), // inmax
circleMin, //outmin
circleMax // outmax
))
}
}
}