//import processing.opengl.*; float x; float y; boolean toggleLoop = true; void setup(){ // Generic setup statements go here: //size (1280, 900, OPENGL); size (600, 400); background (0); smooth (); frameRate (15); x = width/2; y = height/2; } void draw() { //background (0); //Comment out background w/in draw for cummulative effect. fill(0, 5); rect(0, 0, width, height); for (int i=0; i= width*.8) { //Constrain motion. x = x - 1; } if (x <= width*.2) { x = x + 1; } if (y >= height*.8) { y = y - 1; } if (y <= height*.2) { y = y + 1; } } } // Mouse toggle code by amnon.owed // http://forum.processing.org/topic/mouse-toggle-loop // Place boolean toggleLoop = true; above setup. void mousePressed() { if (mouseButton == LEFT) { if (toggleLoop) { noLoop(); toggleLoop = false; } else { loop(); toggleLoop = true; } } }