xxxxxxxxxx
43
let rectx = 0;
let recty = 0;
let speedx = 2;
let speedy = 7;
function setup() {
createCanvas(600, 600);
background(255,255,225);
}
function draw() {
//background(255,255,225);
colorMode(HSB);
stroke(20);
strokeWeight(5);
rectx = rectx + speedx;
recty = recty + speedy;
rect(rectx,recty,30,30);
fill(
map(mouseX,0,width,0,360),
map(mouseY,0,height,0,100),
map(rectx,0,width,0,100),
map(recty,0,height,0,100));
if(rectx>=width || rectx<=0){
speedx = speedx*-1;
}
if(recty>=height || recty<=0){
speedy = speedy*-1;
}
}
function mousePressed(){
clear();
}