xxxxxxxxxx
37
/*
Objective:
- Learn Loops.
*/
function setup() {
createCanvas(400, 400);
}
function draw() {
// We are using the function noLoop to stop the animation
// It helps visualizing the outcome
noLoop();
background(255);
// code to create 5 bubbles without a for loop
circle(random(width), random(height), 50);
circle(random(width), random(height), 50);
circle(random(width), random(height), 50);
circle(random(width), random(height), 50);
circle(random(width), random(height), 50);
// generating the 5 bubbles with a for loop
for(let i = 0; i < 5; i++){
// We are making this bubbles pink
fill(250,0,150);
circle(random(width), random(height), 50);
}
}
/*
Challenges
- Comment out the noLoop() function. What happens?
- Use the loop to create 100 bubbles
- Create other shape, maybe a triangle or rectangle
*/