let jokeSetup, punchline;
let punchlineFrames = 600;
let currentJokeIndex = 0;
let epicenterX, epicenterY
function shuffleArray(array) {
let shuffled = array.slice();
for (let i = shuffled.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
headphones = loadImage('https://deckard.openprocessing.org/user276376/visual2480615/h46e124172bacdcfe78513ce8d9229f7d/headphone-emoji-2048x2048-2ayz493s.png')
let url = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vS8WhlDcV30CXVlTcLr2N3RXeQlSwlwhYBV4TCp-_ar4f-z9QDfatPKU38HlqmCYDrOuP3htjMiVO31/pub?gid=0&single=true&output=csv';
loadTable(url, 'csv', 'header', table => {
for (let row of table.rows) {
punchline: row.get('Punchline')
backgroundSound = loadSound('atmosphere.mp3');
criticalMass= random(50, 200)
headphones.resize(0, height / 2)
disableCanvasInteractions();
createCanvas(windowHeight, windowHeight);
speech = new p5.Speech();
textAlign(CENTER, CENTER);
console.log = function() {};
shuffledJokes = shuffleArray(jokes);
jokeSetup = shuffledJokes[currentJokeIndex].setup;
punchline = shuffledJokes[currentJokeIndex].punchline;
for (let i = 0; i < criticalMass; i++) {
colorChoice = random(255)
brushes.push(new Brush(width / 2 +
map(noise(i), 0, 1, 0, width / 2),
map(noise(i), 0, 1, 0, height / 2), i));
function disableCanvasInteractions() {
let canvas = document.querySelector('canvas');
canvas.addEventListener('contextmenu', e => e.preventDefault());
canvas.addEventListener('mousedown', e => e.preventDefault());
canvas.addEventListener('touchstart', e => e.preventDefault());
document.addEventListener('keydown', e => e.preventDefault());
if (frameCount % 120 === 0) {
background(map(frameCount, 0, 30000, 0, 255), 150, 255, random(0, random([1, random(20)])))
if (frameCount % 8000 === 0) {
background(random(255), random(255), random(255), random(150, 200))
for (let i = 0; i < brushes.length; i++) {
square(0, height - height / 10, height / 10)
square(width - width / 10, height - height / 10, height / 10)
square(0, 0, height / 10)
square(width - width / 10, 0, height / 10)
if (jokes.length === 0) {
text("Loading jokes...", width / 2, height / 2);
if (frameCounter > setupFrames) {
} else if (state === 1) {
if (frameCounter > punchlineFrames) {
} else if (state === 2) {
if (currentJokeIndex >= shuffledJokes.length) {
shuffledJokes = shuffleArray(jokes);
jokeSetup = shuffledJokes[currentJokeIndex].setup;
punchline = shuffledJokes[currentJokeIndex].punchline;
for (let i = 0; i < pens.length; i++) {
if (frameCount % 100 < 80) {
image(headphones, headphones.width, height - headphones.height)
image(headphones, width - headphones.width, height - headphones.height)
image(headphones, headphones.width, headphones.height)
image(headphones, width - headphones.width, headphones.height)
constructor(x, y, index) {
this.pos = createVector(x, y);
this.sat = random(127, 255)
this.bright = random(127, 255)
this.size = random(0.25, 10)
let lineSize = map(noise(adv), 0, 1, 10, (this.inc * this.size) + (frameCount / (this.index * this.inc + frameCount / (adv - frameCount / 1000000))) + this.inc * (1 + criticalMass - this.index) / 5)
let hueDiff = 255 - this.hue
if (this.pos.x > width + lineSize || this.pos.x < -lineSize || this.pos.y > height + lineSize || this.pos.y < -lineSize) {
if (frameCount % 100 === 0) {
pens.push(new Pen (random(width), random(height)))
this.pos.x = random(width)
this.pos.y = random(height)
stroke(this.hue + map(sin(frameCount / (50 * this.pos.x)), -1, 1, hueDiff / 1.5, hueDiff), this.sat, this.bright, 0.5 * this.index + this.inc * (this.index / 20) - adv / 2)
stroke(this.hue - map(cos(frameCount / (50 * this.pos.y)), -1, 1, hueDiff / 1.5, hueDiff), this.sat, this.bright, 0.5 * this.index + this.inc * (this.index / 20) - adv / 2)
this.pos.x += sin(this.pos.y / (this.inc + this.index * 100)) / 10 + cos((this.pos.y / (500 - this.inc)) * (this.inc + (frameCount / 100))) + random(this.inc / (1 + this.index)) * 10 + (1 + this.index) / 100
this.pos.y += cos(this.pos.x / (this.inc + this.index * 100)) / 10 + cos((this.pos.x / (500 - this.inc)) * (this.inc + (frameCount / 100))) + random(this.inc / (1 + this.index)) * 10 + (1 + this.index) / 100
this.inc += (1 + this.index) / (10 * frameCount)
line(this.pos.x, this.pos.y, this.prevX, this.prevY)
line(width - this.pos.x, height - this.pos.y, width - this.prevX, height - this.prevY)
line(width - this.pos.x, this.pos.y, width - this.prevX, this.prevY)
line(this.pos.x, height - this.pos.y, this.prevX, height - this.prevY)
this.ink = random([0, 255])
for (let i = 0; i < 3; i++) {
this.x += map(sin(this.y / random(9, 11)), -1, 1, -1, noise(cos(this.y / (1 + frameCount / 10))) * (1 + noise(frameCount / 5)))
this.y += map(cos(this.x / random(18,21)), -1, 1, -1, noise(sin(this.x / (1 + frameCount / 20))) * (1 + noise(frameCount / 2)))
if (this.x > width || this.x < 0 || this.y > height || this.y < 0) {
strokeWeight(map(noise(frameCount / 100), 0, 1, 1, 10))
line(this.x, this.y, this.prevX, this.prevY)
line(width - this.x, height - this.y, width - this.prevX, height - this.prevY)
line(width - this.x, this.y, width - this.prevX, this.prevY)
line(this.x, height - this.y, this.prevX, height - this.prevY)