// Colours, locations, and backgrounds change when mouse is pressed. Demonstrates: mouseX, mouseY, mousePressed and Map
// Author: David Klein
// Class: PUDT 1203 Creative Computing

PImage img1;
PImage img2;
PImage img3;


void setup () {
  size (800, 800);
  background(0);
  noStroke();
  
  img1 = loadImage ("legs.jpg");
  img2 = loadImage ("orange.png");
  img3 = loadImage ("legs2.png");
}

void draw() {
  background(0);

//changes the opacity of the circle as it gets closer to the center...for some reason it only works with 
//y coordinate and not the x
  if(mouseY < 400){
    fill(255, 255, 255, map(mouseY, 0, 400, 20, 255));
  } else if (mouseY > 400){
    fill(255, 255, 255, map(mouseY, 400, 800, 255, 20));
  } else if (mouseX < 400){
  fill(255, 255, 255, map(mouseX, 0, 400, 20, 255));
  } else if(mouseX > 400){
  fill(255, 255, 255, map(mouseX, 400, 800, 255, 20));
  }
  
  // ellipse that changes shades of white when the mouse is not pressed 
  ellipse(mouseX, mouseY, 200, 200);
  
  //Party Time 
  if (mousePressed == true) {
  
    //changes the background colour 
    background(random(40,255), random (40,255), random(40, 255));
    
    //randomly changes circles to float around MY image 
    fill(random(20,255),random(20,255), random(20,255)); 
    ellipse(pmouseX + random(-200, 200), pmouseY + random(-200, 200), 30, 30);
    
    //Loads Images when button is pressed. WHY DO THEY NOT CHANGE LOCATIONS??
    image(img1, mouseX-100, mouseY-100, 200, 100);
    image(img2, random(mouseX+100, mouseX-100), random(mouseY+100, mouseY-100), mouseX * 2, mouseY *2);   
    image(img3, random(mouseX+100, mouseX-100), random(mouseY+100, mouseY-100), mouseX * 2, mouseY *2);
  }
  }

 


