4mo

Bouncy ⌐🄰-🄿

This piece is generated by the following code:

let centerX, centerY;
let rectWidth = 185;
let rectHeight = 225;
let speedX, speedY;
let bottomRectX = 178;
let bottomRectY = 265;

function setup() {
createCanvas(420, 420);
rectMode(CENTER);
noStroke();

centerX = width / 2;
centerY = height / 2;

speedX = random(-2, 2);
speedY = random(-2, 2);
}

function draw() {
background('#eeefee');

centerX += speedX;
centerY += speedY;

if (centerX - rectWidth / 2 < 0 || centerX + rectWidth / 2 > width) {
speedX *= -1;
}

if (centerY - rectHeight / 2 < 0 || centerY + rectHeight / 2 > height) {
speedY *= -1;
}

if (frameCount % 13 < 5) {
fill('#010001');
} else {
fill('#eeefee');
}

rect(centerX, centerY, rectWidth, rectHeight);
let smallRectWidth = 70;
let smallRectHeight = 90;

fill('#fec925');
rect(centerX - 42, centerY - 52, smallRectWidth, smallRectHeight);

fill('#eef3fb');
rect(centerX + 42, centerY - 52, smallRectWidth, smallRectHeight);

fill('#e01935');
rect(centerX + 42, centerY + 52, smallRectWidth, smallRectHeight);

fill('#5648ec');
rect(centerX - 42, centerY + 52, smallRectWidth, smallRectHeight);

bottomRectX += speedX;
bottomRectY += speedY;

if (bottomRectX - 25 < 0 || bottomRectX + 25 > width) {
speedX *= -1;
}

if (bottomRectY - 8 < 0 || bottomRectY + 8 > height) {
speedY *= -1;
}

fill('#01499d');
rect(bottomRectX, bottomRectY, 50, 16);
}