import processing.core.*; import java.applet.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.util.zip.*; import java.util.regex.*; public class Reach2 extends PApplet { /** * Reach 2. * Based on code from Keith Peters (www.bit-101.com) * * The arm follows the position of the mouse by * calculating the angles with atan2(). */ int numSegments = 10; float[] x = new float[numSegments]; float[] y = new float[numSegments]; float[] angle = new float[numSegments]; float segLength = 20; float targetX, targetY; public void setup() { size(200, 200); smooth(); strokeWeight(20.0f); stroke(0, 100); x[x.length-1] = 0; // Set base x-coordinate y[x.length-1] = height; // Set base y-coordinate } public void draw() { background(226); reachSegment(0, mouseX, mouseY); for(int i=1; i=1; i--) { positionSegment(i, i-1); } for(int i=0; i