Code

//Leonardo Covarrubias
//Exercise014
//
//creates lines between two random points, vibrates each end point differently based on its distance from the mouse
//  changes line thickness based on the distance between the mouse and both end points.
//
//based from code by Ersatz, Falschung found at http://courses.cfa.cmu.edu/~golan/courses/dmc/iig_04f/detalle.php?p_id=30&e_id=10

float [] ay;
float [] ax;
float [] by;
float [] bx;

void setup(){
  size(400,400);
  framerate(12);
  background(0);
  stroke(255);
  smooth();
  strokeCap(ROUND);
  ax = new float[1000];
  ay = new float[1000];
  for (int i=0; i<1000; i++){
    ax[i] = 0 + random(400);
    ay[i] = 0 + random(400);
  }
  bx = new float[1000];
  by = new float[1000];
  for (int i=0; i<1000; i++){
    bx[i] = 0 + random(400);
    by[i] = 0 + random(400);
  }
}

void draw(){
  
  background(0);
  
  for (int i=0; i<1000; i++){
    float randDistA = (dist(ax[i], ay[i], mouseX, mouseY))/50.0;
    float randDistB = (dist(bx[i], by[i], mouseX, mouseY))/50.0;
    float randDist = (randDistA+randDistB)/2;
    strokeWeight(int(randDist/5));
    line(ax[i],ay[i] + random(-randDistA, randDistA), bx[i], by[i] + random(-randDistB, randDistB));
    
  }
  

}

014 -- 1000 Lines: Iteration & Interaction

Statement:Develop a composition in which one thousand (straight) lines respond to the position and/or movements of the cursor.

Restrictions:
The composition should be 400x400 pixels.
The only allowable colors are black and white (no grays).

hide statement