xxxxxxxxxx
31
//Now the color of the sprinkles are random along with their placement on the Y axis
function setup() {
createCanvas(400, 200);
background("LemonChiffon");
//The loop code
//Top border
for (var x = 0; x < width; x += 30) {
noStroke();
fill("HotPink");
ellipse(x, 10, 45);
}
//Bottom border
for (x = 0; x < width; x += 30) {
ellipse(x, 190, 45);
}
//Random sprinkles
for (x = 5; x < width; x += 40) {
var y = random(height / 2 + 40, height / 2 - 40);
//Random sprinkles color. Yes I did just copy and paste the code from the example since I conveniently liked the color pallette lol
var r = random(0, 255);
var g = random(0, 100);
var b = random(100, 255);
fill(r, g, b);
rect(x, y + 10, 30, 10, 5);
}
}