float y1; //variable to hold the lineStart float y2; //variable to hold the lineEnd int x1; //variable to hold the x-positions int x2; int col; //variable for alpha strength float lineHeight; //Sets maximum value float distance; float closeEnough = 50; //Sets variable for when lines begin to grow void setup(){ size(720,240); background(0); stroke(255,50); x1=(width/2); x2=(width/2); } void draw(){ background(0); setLineHeight(); drawLine(); } void setLineHeight(){ distance=abs(mouseX-x1); if (distance <= closeEnough){ if(distance <= 0){ lineHeight=(height/2)-70; //if 0, set MAXIMUM line Height }else{ lineHeight = ((height/2)-70)+distance; //setting LINE HEIGHT based on DISTANCE } }else{ lineHeight=(height/2)-30; //if mouse too far away, set MINIMUM line Height } } void drawLine(){ for(int i = 0; i < (width/10); i++){ //decreasing will drop opacity of whole line if (lineHeight >= (height/2)){ lineHeight = (height/2); //Make sure lines don't draw past center } line(x1,y1,x2,y2); y1=lineHeight; //Sets linestart to INCREASING value as loop goes y2=(height)-y1; //Sets lineEnd to a DECREASING value as loop goes col = i+(round(width/lineHeight)); //TRANSPARENCY drops as you go up in loop lineHeight++; stroke(255, col); } }