xxxxxxxxxx
45
/*
----- Coding Tutorial by Patt Vira -----
Name: Color Changing Ball
Video Tutorial: https://youtu.be/n3s-yOCH638?si=EiVfJRws_p8rmBf4
Connect with Patt: @pattvira
https://www.pattvira.com/
----------------------------------------
*/
let x = 0;
let y = 200;
function setup() {
createCanvas(600, 400);
}
function draw() {
background(100);
// Drawing separation lines
for (let i=0; i<width; i+=100){
stroke(0);
line(i, 0, i, height);
}
// If Statements
if (x > 0 && x <= 100) {
fill(250, 250, 110);
} else if (x > 100 && x <= 200) {
fill(156, 223, 124);
} else if (x > 200 && x <= 300) {
fill(74, 189, 140);
} else if (x > 300 && x <= 400) {
fill(0, 150, 142);
} else if (x > 400 && x <= 500) {
fill(16, 110, 124);
} else {
fill(42, 72, 88);
}
ellipse(x, y, 50, 50);
x += 3; // Same as writing x = x + 3;
}