// 10 Lines // Paul Bartlett // 18 Sept 2007 float[][] lineData; float[] goal; float[] velocity; float velScale = 0.0007; int pad = 22; void setup(){ size(640,480); frameRate(50); stroke(255); strokeWeight(3); smooth(); // Setup line position & velocity arrays lineData = new float[4][10]; goal = new float[10]; velocity = new float[10]; for(int L=0; L<10; L++){ lineData[0][L]=0; lineData[1][L]=height/11+L*height/11; lineData[2][L]=0; lineData[3][L]=height/11+L*height/11; velocity[L] = 0; } } void draw(){ background(0); // Set the goal points for each line as the mouse passes for(int m=0; m<10; m++){ if(mouseY < height/11+m*height/11+pad && mouseY > height/11+m*height/11-pad){ goal[m]=mouseX; } } // Animate the lines for(int r=0; r<10; r++){ velocity[r] = velScale*(goal[r] - lineData[2][r])*abs(goal[r] - lineData[2][r]); lineData[2][r]=lineData[2][r]+velocity[r]; line(lineData[0][r],lineData[1][r],lineData[2][r],lineData[3][r]); } }