This example is for Processing 3+. If you have a previous version, use the examples included with your software. If you see any errors or have suggestions, please let us know.

Linear Motion.

Changing a variable to create a moving line. When the line moves off the edge of the window, the variable is set to 0, which places the line back at the bottom of the screen.

float a;

void setup() {
  size(640, 360);
  a = height/2;

void draw() {
  line(0, a, width, a);  
  a = a - 0.5;
  if (a < 0) { 
    a = height;