//Doug Potts
//ARTD 252
//Lab MW 2:00pm


//Adapted from code by Neema Sadeghi 
// and then from SherrieCode



 //  "_.New_.Additions_"   \\
//     by  Doug  Potts      \\




// Click and hold your mouse on the image at will.



float angle; 
int posX,posY;
int value = 0;
float scaleON = int(random(0,400));


void setup(){ 


  size(1050,500); 
  smooth(); 

  angle = 0; 
  posX=250;                   
  posY=250; 

  frameRate(15); 
  
  // Frame rate adjusts the smoothness of the movement. 
  // with the setting @ 15, the element seemingly coils
  // only to be better used once the color flashes.

} 

void draw(){ 


  background(0);
  fill(value,29,80);
  ellipse(0,0,width,height);


  fill(100, 125, 0, 3);
  stroke(0,225);
  ellipseMode(CORNERS+90);
  ellipse(0,0,width+250,height+50);
  ellipseMode(-CENTER);
  // As shown above, this sets the entire background
  // omitting the all objects in motion

  fill(0,10);
  stroke(225,90);
  ellipse(random(0,1200),random(0,600),225,8);

  for(int i=0; i<50; i++){                 
    // (i) determines the number of rectangles rotating.

    rotaRect(15*i,0*i,angle*i*.03);  
    // Once I played around with all of these values
    // I realized that they help angle the object in the frame.
    // I also realized that I can adjust the speed desparity between the sides of
    // the image. 
    
    angle+=-.05; 
    // This adjusts the speed of rotation.
  } 
} 

void rotaRect(int posX,int posY,float scaleON){ 
    // This rotaRet command rotates the image you see in its entirety
    // omitting the three background ellipses.
  
  fill(0,12);
  stroke(0);
  //stroke(25,190);
  ellipse(random(0,1200),random(0,600),45,10);
    // This sets a random amount of rotating ellipses.

  pushMatrix(); 
  
  stroke(225,400);
  translate(posX+135,posY+275);         
    // By adding an integer to posX and posY I shift the rotating 
    // element in the respective directions

  rotate(radians(scaleON));
    // Sets rotation and the scaleON command denotes the angle starting point.

  stroke(0,225);
  colorMode(RGB); 
  fill(value,29,80); 

  if(mousePressed == posY>400){
    scale(1);
  } 
  
  
      // The following set of ellipses create the sense of movement
      // in the background. 
else {
    fill(100, 125, 0, 3);
    stroke(220,225);
    ellipseMode(CORNERS+90);
    ellipse(0,0,width+250,height+50);
    fill(0);
    ellipseMode(-CENTER);
    // This creates the rotating tunnel of ellipses.
    
    
    scale (1);
    // mousePressed funtion enlarges the image
    // by the scale listed 
}


   fill(0);
   stroke(225,225,225,225);
   ellipse(-25,-25,60,60);
   // This ellipse is the wormlike object you see. 


stroke(280,280,280,250);  
fill(0);
ellipse(-10,-100,10,100); 
  posX+=+1.5; 
  posY+=-5;  
  // This is the set of ellipses potruding from the wormlike object.

  
  popMatrix(); 
}