class Point2f { float x,y; Point2f(float x, float y) { this.x=x; this.y=y; } } class Line { Vector points = new Vector(); void add(Point2f p) { points.add(p); } Point2f get(int i) { return (Point2f)points.elementAt(i); } int size() { return points.size(); } } Vector lines = new Vector(); int gw = 15; void setup() { size(400,400); smooth(); // verticals for (int i = 0; i <= gw; i++) { Line line = new Line(); for (int j = 0; j <= gw; j++) { line.add(new Point2f(i*width/gw,j*height/gw)); } lines.add(line); } // horizontals for (int i = 0; i <= gw; i++) { Line line = new Line(); for (int j = 0; j <= gw; j++) { line.add(new Point2f(j*width/gw,i*height/gw)); } lines.add(line); } } void draw() { background(255); noFill(); stroke(0); strokeWeight(2); for (int i = 0; i < lines.size(); i++) { Line line = (Line)lines.elementAt(i); beginShape(LINE_STRIP); for (int j = 0; j < line.size(); j++) { Point2f point = line.get(j); float d2 = sq(point.x - mouseX) + sq(point.y - mouseY); if (d2 > 0.0) { float d = sqrt(d2); curveVertex(point.x + ((point.x - mouseX)/d*15.0),point.y + ((point.y - mouseY)/d*15.0)); } else { curveVertex(point.x,point.y); } if (j == 0 || j == line.size()-1) { curveVertex(point.x,point.y); } } endShape(); } }