let cols, rows, particle, particleNumber, bGcolor, shadowColor, elemColor, lightMode, nukeAcc;
let maxR = 200; let minR = 50;
let maxG = 100; let minG = 20;
let maxB = 100; let minB = 20;
myFont = loadFont('PlayfairBold.otf');
bGcolor = color(238, 240, 219);
shadowColor = color(41, 45, 59, 5);
elemColor = color(41, 45, 59);
createCanvas(innerWidth, innerHeight);
cols = int( width / gridSize );
rows = int( height / gridSize );
particleNumber = (cols + rows) /2;
for(let p = 0; p < particleNumber; p++) {
particle = new Particle();
particles.push(particle);
translate(gridSize/2, gridSize/2);
for (let v = 0; v < cols; v++) {
for (let r = 0; r < rows; r++) {
let offset = createVector((gridSize * v), (gridSize * r));
let head = p5.Vector.fromAngle(360 * noise(noiseValue * 0.01));
noiseValue = noiseValue + noiseLevel;
for(let m = 0; m < modes.length; m++) {
for(let r = 0; r < rains.length; r++) {
for(let ri = 0; ri < ripples.length; ri++) {
ripples[ri].remove(ripples);
for(let l = 0; l < letters.length; l++) {
letters[l].remove(letters);
for(let p = 0; p < particles.length; p++) {
particles[p].follow(flowField);
particles[p].joint(particles);
if (keyCode === 32 || keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40) {
} else if (keyCode === 16 || keyCode === 13 || keyCode === 20 || keyCode === 8 || keyCode === 9) {
} else if (keyCode === 17 || keyCode === 18 || keyCode === 91 || keyCode === 93 ) {
let nuke = createVector( random(width), random(height) );
let ripple = new Ripple(nuke);
let letter = new Letter(key);
this.size = random(20, 200);
this.speed = random(5, 10);
this.pos = createVector (random(width - this.size), random(height/2));
this.r = floor(map(noise(this.size *0.5), 0, 1, maxR, minR));
this.g = floor(map(noise(this.speed *0.5), 0, 1, maxG, minG));
this.b = floor(map(noise(this.pos.x *0.5), 0, 1, maxB, minB));
if(this.key == 'q' || this.key == 'w' || this.key == 'a') {
this.speed = random(20, 40);
fill(this.r, this.g, this.b);
text(this.key, this.pos.x, this.pos.y);
this.pos.y = this.pos.y + this.speed;
let removeYpos = height + this.size;
if(this.pos.y > removeYpos) {
for (let l = 0; l < arrayName.length; l++) {
if ( this.pos.y == arrayName[l].y ) {
arrayName.splice( index, 1 );
if(arrayName.length > 30) {
arrayName.splice( 0, 1 );
this.speed = random(1.5, 2.5);
circle( width/2, height/2, this.r);
bGcolor = color(31, 35, 49);
shadowColor = color(238, 240, 219, 5);
elemColor = color(238, 240, 219);
maxR = maxR + 20; maxG = maxG + 20; maxB = maxB + 20;
bGcolor = color(238, 240, 219);
shadowColor = color(41, 45, 59, 5);
elemColor = color(41, 45, 59);
maxR = maxR - 20; maxG = maxG - 20; maxB = maxB - 20;
this.pos = createVector(random(width), random(height));
this.vel = createVector(0, 0);
this.acc = createVector(0, 0);
this.random = random(-10, 40);
circle( this.pos.x, this.pos.y, 2 );
this.vel.limit(this.maxspeed);
let x = int(this.pos.x / gridSize);
let y = int(this.pos.y / gridSize);
for( let v = 0; v < cols; v++) {
for( let r = 0; r < rows; r++) {
if (this.pos.x < 0 || this.pos.x > width) {
this.vel.x = this.vel.x * -1;
if (this.pos.y < 0 || this.pos.y > height) {
this.vel.y = this.vel.y * -1;
if ( this.vel.x == 0 && this.vel.y == 0 ) {
let bounce = createVector(-0.1, -0.1);
particles.forEach(first =>{
let dis = dist( this.pos.x, this.pos.y, first.pos.x, first.pos.y );
particles.forEach(second =>{
let dis2 = dist( this.pos.x, this.pos.y, second.pos.x, second.pos.y );
if (dis2 < triSize /3 ) {
let r = floor(map(noise(first.pos.x *0.125), 0, 1, maxR, minR));
let g = floor(map(noise(first.pos.y *0.125), 0, 1, maxG, minG));
let b = floor(map(noise(second.pos.x *0.125), 0, 1, maxB, minB));
let x2 = first.pos.x + (this.random * noise(first.pos.x *0.25));
let y2 = first.pos.y + (this.random * noise(first.pos.y *0.25));
let x3 = second.pos.x + (this.random * noise(second.pos.x *0.25));
let y3 = second.pos.y + (this.random * noise(second.pos.y *0.25));
triangle(x1, y1, x2, y2, x3, y3);
strokeWeight(this.random);
point(this.pos.x, this.pos.y);
this.speed = random( height/6 , height/10 );
this.num = floor(random(4, 20));
this.pos = createVector( random( (width - (this.w * this.num * 2)) ), 0);
for(let r = 0; r < this.num; r++) {
let offset = this.w * 2 * r;
rect((this.pos.x + offset), this.pos.y, this.w, this.h);
this.pos.y = this.pos.y + this.speed;
this.h = this.h + this.speed;
if(this.pos.y > height) {
for (let r = 0; r < 4; r++) {
let offset = this.w * 4 * r;
circle(this.pos.x, this.pos.y, this.size + offset);
this.size = this.size * 2;
if(this.size > width * 2) {