xxxxxxxxxx
32
let x = 0;
let y = 0;
let w = 40;
let h = 40;
let xjump = 2;
let yjump = 3;
function setup() {
createCanvas(400,400);
background(100);
}
function draw() {
colorMode(HSB);
fill(
map(x,0,width,0,360),
map(mouseX,0,width,0,100),
map(y,0,height,0,100)
);
rect(x,y,w,h);
x = x + xjump;
y = y + yjump;
if(x >= width || x <= 0){
xjump = xjump * -1;
}
if(y >= height || y <= 0){
yjump = yjump * -1;
}
}