xxxxxxxxxx
33
let directionX = -1;
let directionY = -1;
let directionC = -1;
let color = 0;
let x = 60;
let y = 200;
let s = 3;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
noStroke();
fill(color);
circle(x,y,30);
if (x < 0 || x > width){
directionX = - directionX;
}
if (y < 0 || y > height){
directionY = - directionY;
}
x = x + directionX * s;
y = y + directionY * s;
//extra 1
if (color == 0 || color == 255){
directionC = - directionC;
}
color = color + directionC * s;
}