xxxxxxxxxx
57
let boxx;
let boxy;
let boxw = 40;
let boxh = 40;
let boxr;
let xJump = 1.1875;
let yJump = 3.14;
let R = 255;
let G = 255;
let B = 255;
let R2 = R - 40;
let G2 = G - 40;
let B2 = B - 40;
function setup() {
createCanvas(400, 400);
background(random(R), random(G), random(B));
boxx = width / 2;
boxy = height / 2;
boxr = random(9);
}
function draw() {
R = map(boxx, 0, width, 0, 360);
G = map(boxy, 0, width, 0, 100);
boxw = map(mouseX, 0, width, 0, 100);
boxh = map(mouseY, 0, width, 0, 100);
colorMode(HSB);
rectMode(CENTER);
fill(R, G, B);
rect(boxx, boxy, boxw, boxh, boxr);
boxx = boxx + xJump;
boxy = boxy + yJump;
if (boxx >= width - boxw / 2 || boxx <= boxw / 2) {
xJump = xJump * -1;
}
if (boxy >= height - boxh / 2 || boxy <= boxh / 2) {
yJump = yJump * -1;
}
}
function mouseClicked(){
background(random(R), random(G), random(B));
}