xxxxxxxxxx
211
var gracias;
var clave;
var staticsound;
var veinte;
var artist;
let selfie;
let silho;
let minisilho;
let shadow1;
let shadow2;
let shadow3;
let squarel;
let meesh;
let donot;
let osc;
var cuca;
var rainman;
function preload()
{
gracias=loadSound('gracias.mp3');
veinte=loadSound('veinte.mp3');
artist=loadSound('artist.mp3');
staticsound=loadSound('staticsound.mp3');
clave=loadSound('clave.mp3');
silho=loadImage('silho.png');
selfie=loadImage('oldselfie.png');
mini=loadImage('minisilho.png');
donot=loadSound('donotlisten.mp3');
}
function setup(){
createCanvas(700,1020);
noCursor();
noStroke();
loadPixels();
meesh=createGraphics(574,765);
meesh.tint(255,15);
meesh.image(selfie,0,0,574,765);
rainman=createGraphics(120,150);
rainman.tint(255,25);
rainman.image(silho,0,0,120,150);
cuca=createGraphics(30,40);
cuca.tint(255,75);
cuca.image(mini,0,0,30,40);
// squarel=square(200,200,0,0);
// squarel.tint(255,125);
//squarel.square
osc = new p5.Oscillator();
osc.setType('sine');
osc.start();
//reverb=new p5.Reverb();
// veinte.disconnect();
//reverb.process(veinte,3,3);
//SOUND LOOPS
gracias.play();
gracias.loop();
clave.play();
clave.loop();
staticsound.play();
staticsound.loop();
artist.play();
artist.loop();
//SHADOWS
shadow1=new Shadow(100,100);
shadow2=new Shadow(383,400);
shadow3=new Shadow(width-100,700);
}
function draw() {
var mambo=(map(mouseY,0,height,0,155))
if(mouseIsPressed){
background(random(100,225),random(100,225),random(100,225));}
else{
background(mambo,mambo,mambo);}
// fill(mambo+5,mambo+5,mambo+10);
rectMode(CENTER);
if((mouseX>257)&&(mouseX<507)&&(mouseY>178)&&(mouseY<722)){
// donot.play();
fill(random(100,225),random(100,225),random(100,225));
}
else{
fill(random(100,225));}
rect(width/2, 200, 250,44);
rect(width/2, 325, 250,44);
rect(width/2, 450, 250,44);
rect(width/2, 575, 250,44);
rect(width/2, 700, 250,44);
imageMode(CENTER);
image(meesh,width/2,height/2,574,765);
if(shadow1.x>width){shadow1.x=0;}
if(shadow1.y>height){shadow1.y=0;}
if(shadow2.x>width){shadow2.x=0;}
if(shadow2.y>height){shadow2.y=0;}
if(shadow3.x>width){shadow3.x=0;}
if(shadow3.y>height){shadow3.y=0;}
shadow1.show(100,80);
shadow1.fly();
shadow2.show(450,14);
shadow2.fly();
shadow3.show(600,0);
shadow3.fly();
//SOUND
if(mouseIsPressed){
osc.freq(map(mouseY,height-mouseY,0,random(300,900),random(1000,1800)));}
else{osc.freq(map(mouseY,height-mouseY,0,random(50-150),random(200,300)));}
if(mouseIsPressed){
osc.amp(map(mouseY,0,height,0,0.5));}
else{if(mouseY<500){osc.amp(0);}
else{osc.amp(map(mouseY,500,height,0,0.2));}
}
//GRACIAS
if(mouseY<height/4){
gracias.setVolume(map(mouseY,height/4,0,0,0.1));}
else {gracias.setVolume(0);}
//IAMANARTIST
if(mouseY>700){
artist.setVolume(map(mouseY,700,height,0,1));
fill(0);
rect(width/2,height/2,width,height); //black screen word opp
fill(random(0,100),random(0,100),random(0,100));
textAlign(CENTER);
if(mouseIsPressed){
textSize(60);
text('NETWORK OF LIMIT-',width/2,height/4);
text('LESS INTERRELATIONS',width/2,height/2-100)
}
else{
textSize(60);
text(' WORK ',width/2,height/4);
text('LESS IN RELATIONS',width/2,height/2-100)}
}
else {artist.setVolume(0);}
//STATICSOUND
if(mouseY>(height*0.7)){
staticsound.setVolume(0.5);}
else{staticsound.setVolume(0)}
//CLAVE
clave.setVolume(map(mouseY,0,height,0,0.3));
if(mouseIsPressed){
clave.rate(map(mouseY,0,height,0.1,5));}
else {clave.rate(map(mouseX,width,0,3,0.2));}
//RECURSION TREE
var len=0
translate(mouseX,mouseY+100);
branch(map(height-mouseY,0,height,10,300));
}
//BRANCHES
function branch(len){
noStroke();
line(0,0,0,-(len));
translate(0,-len+90);//+90 instead of 100 helps my feet form dangling at Y=0
if(len>6){
push();
rotate(map(mouseY,0,height,-2,2,0.01));//added a negative
branch(len*0.67);
pop();
push();
rotate(-(map(mouseY,0,height,-2,2,0.1)));
branch(len*0.67);
if(mouseY>700){
var mambo=(map(mouseX,0,width,0,255))
var mambu=(map(mouseY,800,height,0,255))
if(mouseIsPressed){
fill(random(100,225),random(100,225),random(100,225));}
else{fill(random(50,200));}
square(0,-(len+20),random(100,200));}
else{
image(cuca,0,-len,60,80);}
pop();
}}
//DO NOT LISTEN
function mousePressed(){
donot.play();
donot.loop();
donot.amp(0.5);}
//NERUDA
function mouseReleased(){
veinte.play();
veinte.amp(0.5);
donot.amp(0);
donot.stop(); //stop function is too iffy
}
//SHADOOWS
class Shadow{
constructor(x,y,h,w){
this.x=x;
this.y=y;
this.h=h;
this.w=w;
this.fly=function(){
this.x = (this.x);
this.y = (this.y)+2;}
if(this.y>height){this.y=0;}
this.show=function(){
imageMode(CENTER);
image(rainman,this.x,this.y,120,150);
}
}}