let colors = ["#fa4848", "#ffeb3b", "#4df78b", "#489af7", "#fa50d5"];
for (let i = 0; i < seg; i++) {
for (let j = 0; j < seg; j++) {
forms.push(new Form(x, y, w));
translate(width / 2, height / 2);
translate(-width / 2, -height / 2);
for (let i = 0; i < forms.length; i++) {
function easeOutQuart(t) {
return 1 - (--t) * t * t * t
this.w = this.w0 * int(random(2) + 1);
this.col = color(random(colors));
this.tog = int(random(2));
this.cor = this.tog * this.w * 0.5;
this.t = -int(random(100) * random());
this.tSpan = int(random(20, 100));
this.rnd = int(random(4));
this.w2 = this.w0 * int(random(2) + 1);
this.dir = int(random(4));
this.col2 = color(random(colors));
rect(this.x, this.y, this.w, this.w, this.cor);
if (this.t < this.tSpan) {
let nor = easeOutQuart(norm(this.t, 0, this.tSpan - 1));
this.cor = lerp(0, this.w, nor);
this.cor = lerp(this.w, 0, nor);
if (this.dir == 0) this.x = lerp(this.px, this.px + this.w, nor);
if (this.dir == 1) this.x = lerp(this.px, this.px - this.w, nor);
if (this.dir == 2) this.y = lerp(this.py, this.py + this.w, nor);
if (this.dir == 3) this.y = lerp(this.py, this.py - this.w, nor);
this.w = lerp(this.w1, this.w2, nor);
if ((this.w1 < this.w2) && this.tog == 1) {
this.col = lerpColor(this.col1, this.col2, nor);
if (this.tog == 0) this.tog = 1;
if (this.x < 0) this.dir = 0;
if (this.x > width) this.dir = 1;
if (this.y < 0) this.dir = 2;
if (this.y > height) this.dir = 3;