xxxxxxxxxx
21
let x = 25;
let xspeed = 5;
let color;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
color = map (x, 25, 375, 255, 0);
fill (color);
ellipse(x, height/2, 50, 50);
x += xspeed;
if (x <= 25 || x >= 375) {
xspeed = - xspeed;
}
}