xxxxxxxxxx
22
let x = 0;
let xspeed = 10;
let color1 = 255;
let cspeed = 6.375;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
x += xspeed;
color1 += cspeed;
color1 = constrain(color1, 0, 255);
if (x > width || x < 0) {
cspeed *= -1;
xspeed *= -1;
}
fill(color1);
ellipse(x, height / 2, 20, 20);
}