Sunday, 17 August 2014

Final 2: Fireworks worm

This is my final for processing. I experimented with the mousex and mousey functions to make the ellipse follow my mouse around. I have included the easing function so there is some delay after the mouse moves. I have included multiple ellipses to follow my mouse all with an increased amount of ease to create a trail behind the first ellipse. I have experimented with randomising colours and opacities. Unfortunately I had aimed to include the mousePressed function to create a new ellipse to join the trail every time I pressed the mouse. I spent many hours trying to achieve this but was never successful. I was also unsuccessful in creating a for loop for the ellipses so i had to type the code out manually. I like this composition because it is satisfying to watch the ellipse morph into one another when the mouse is kept still after movement. 

Dropbox link: https://www.dropbox.com/s/xvl3zij6pvc51tu/This_is_da_final.pde












Code:




float x;
float y;
float easing = 0.4;

float x2;
float y2;
float easing2 = 0.2;

float x3;
float y3;
float easing3 = 0.16;

float x4;
float y4;
float easing4 = 0.12;

float x5;
float y5;
float easing5 = 0.08;

float x6;
float y6;
float easing6 = 0.06;

float x7;
float y7;
float easing7 = 0.05;

float x8;
float y8;
float easing8 = 0.45;

float x9;
float y9;
float easing9 = 0.40;

float x10;
float y10;
float easing10 = 0.35;

float x11;
float y11;
float easing11 = 0.30;

float x12;
float y12;
float easing12 = 0.25;


void setup() {
  size(840, 860); 
  noStroke();  
   noCursor();

}

void draw() { 
  background(0);
 float r = random(255);
  fill(12*r,7+r,22-r);
 x += (mouseX - x)*easing;
  y += (mouseY - y)*easing;

x2 += (mouseX - x2)*easing2;
  y2 += (mouseY - y2)*easing2; 
  
  x3 += (mouseX - x3)*easing3;
  y3 += (mouseY - y3)*easing3;
  
  x4 += (mouseX - x4)*easing4;
  y4 += (mouseY - y4)*easing4;
  
  x5 += (mouseX - x5)*easing5;
  y5 += (mouseY - y5)*easing5;
  
  x6 += (mouseX - x6)*easing6;
  y6 += (mouseY - y6)*easing6;
  
  x7 += (mouseX - x7)*easing7;
  y7 += (mouseY - y7)*easing7;
  
   x8 += (mouseX - x8)*easing8;
  y8 += (mouseY - y8)*easing8;
  
   x9 += (mouseX - x9)*easing9;
  y9 += (mouseY - y9)*easing9;
  
   x10 += (mouseX - x10)*easing10;
  y10 += (mouseY - y10)*easing10;
  
   x11 += (mouseX - x11)*easing11;
  y11 += (mouseY - y11)*easing11;
  
    x12 += (mouseX - x12)*easing12;
  y12 += (mouseY - y12)*easing12;
  
  
  
  
  float targetX = mouseX;
  
  
  float dx = targetX - x;
  if(abs(dx) > 0) {
    x += dx * easing;
    
    
  }
  
  float targetY = mouseY;
  float dy = targetY - y;
  if(abs(dy) > 0) {
    y += dy * easing;
   
   
  }
  

  ellipse(x, y, 30, 30);
  ellipse(x2, y2, 30, 30);
  ellipse(x3, y3, 30, 30);
  ellipse(x4, y4, 30, 30);
  ellipse(x5, y5, 30, 30);
  ellipse(x6, y6, 30, 30);
  ellipse(x7, y7, 30, 30);
  ellipse(x8, y8, 30, 30);
  ellipse(x9, y9, 30, 30);
  ellipse(x10, y10, 30, 30);
  ellipse(x11, y11, 30, 30);
  ellipse(x12, y12, 30, 30);
}



No comments:

Post a Comment