xxxxxxxxxx
139
let currentflush
let song;
function preload(){
currentflush = mainpage;
song = loadSound('assets/salamisound-3780183-toilets-pressure-flushing.mp3');
}
function setup(){
createCanvas(windowWidth,windowHeight);
angleMode(DEGREES);
rectMode(CENTER);
}
function keyPressed() {
if (key == '1') {
currentflush = mainpage;
;(song.stop());
} else if (key == '2') {
currentflush = flush1;
;(song.play());
} else if (key == '3') {
currentflush = flush2;
;(song.play());
// }else if (key =='4') {
// currentFlush = reset
} else if (key == 'f') {
let fs = full1screen();
fullscreen(!fs);
}
}
function draw() {
currentflush();
}
function toiletflush1() {
if (song.isPlaying()) {
// .isPlaying() returns a boolean
song.stop();
} else {
song.play();
}
}
// function toiletflush2() {
// if (song.isPlaying()) {
// // .isPlaying() returns a boolean
// song.stop();
// } else {
// song.play();
// }
// }
function mainpage(){
background(0);
noFill();
translate(width/2,height/2)
for (var i = 0; i<200; i++){
push();
rotate(sin(frameCount+i)*200);
var r = map(sin(frameCount), -1,1,-50,255);
var g = map(sin(frameCount/2), -1,1,-50,255);
var b = map(sin(frameCount/4), -1,1,-50,255);
stroke(r,g,b);
rect(0,0,600 - i*3,600 - i*3, 200-i);
pop();
}
}
function flush1(){
background(0);
noFill();
translate(width/2,height/2)
for (var i = 0; i<200; i++){
push();
rotate(sin(frameCount+i)*900);
var r = map(sin(frameCount), 100,1,-50,255);
var g = map(sin(frameCount/2), -1,1,-50,255);
var b = map(sin(frameCount/4), -1,1,-50,255);
stroke(r,g,b);
rect(0,0,600 - i*6,600 - i*6, 200-i);
pop();
}
}
function flush2(){
background(0);
noFill();
translate(width/2,height/2)
for (var i = 0; i<200; i++){
push();
rotate(sin(frameCount+i)*1000*10);
var r = map(sin(frameCount), 100,1,-50,255);
var g = map(sin(frameCount/2), 100,1,-50,255);
var b = map(sin(frameCount/4), 100,200,-50,255);
stroke(r,g,b);
rect(0,0,600 - i*10,600 - i*10, 200-i);
pop();
}
}