float x = 100.0; // X-coordinate float y = 100.0; // Y-coordinate float angle = 0.0; // Direction of motion float speed = 0.5; // Speed of motion void setup() { size(400, 400); x = width/2; y=height/2; background(0); stroke(0, 0, 205, 100); //randomSeed(121); // Force the same random values } void draw() { // draw path stroke(0,255,0); line(x,y,x+cos(angle) * speed, y+sin(angle) * speed); // set color back stroke(0, 0, 205, 130); angle += random(-0.3, 0.3); x += cos(angle) * speed; // Update x-coordinate y += sin(angle) * speed; // Update y-coordinate // warp around if (x>width) x = 0; if (x<0) x=width; if (y>height) y = 0; if (y<0) y=height; translate(x, y); rotate(angle); line(0, -10, 0, 10); } void keyPressed() { if (key == 's') save("Mod32_06.jpg"); else { // start again background(0); x = width/2; y=height/2; } }