int i; int direction; void setup(){ size(300,300); direction=1; } void loop(){ background(i,0,0); stroke(0,i,0); strokeWeight(i/5); line(0,i,300,i); i+=direction; if(i>300){ direction=-1; } if(i<0){ direction=1; } }