var dis; var spacer; var segLength; x, y, x2, y2; //var bg; function setup() { colorMode(HSB,height,height,height); bg = loadImage("Noth_America_West_Coast_1600x900.jpg"); createCanvas(1600, 900); strokeWeight(5); x = width/2; y = width/2; x2 = x; y2 = y; spacer = 20; } function draw() { background(bg); for (var y2 = 0; y2 < height; y2 += spacer) { for (var x2 = 0; x2 < width; x2 += spacer) { dx = x2 - mouseX ; dy = y2 - mouseY ; angle1 = -TWO_PI - atan2(dx,dy); dis = dist(x2,y2,mouseX,mouseY); segment(x2, y2, angle1, dis); } } function segment( x, y, a, dis) { push(); translate(x, y); rotate(a); stroke(2*pow((dis),0.5),(height),height,height); //stroke(0.005*pow(dis,1.7),(height),height,height); segLength=200/((0.1*dis)+10); strokeWeight(3); line(0, 0, segLength, 0); pop(); } }