23. September 2013
A quick and simple way to get an oscilating value
void setup () {
size(600,400);
background(0);
stroke(255);
}
float theta = 0.0;
float itr = (sin(theta) + 1) * width/2;
void draw () {
theta += 0.01;
itr = (sin(theta) + 1) / 2; // oscilate between 0 and 1
// You can easiy invert it: (1-itr)
background(0); // "reset" canvas
line(itr*width, height / 2, width * (1-itr), height / 2);
line(width / 2, itr*height, width / 2, height * (1-itr));
}