xxxxxxxxxx
26
let x = 0;
let xSpeed = 3; // speed of ball
let color;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(250);
x+= xSpeed;
//reverse
if (x >= width || x <= 0) {
xSpeed *= -1;
}
color = map(x, 0, width, 255, 0);
noStroke()
fill(color);
ellipse(x, height / 2, 100, 100);
}