void setup() { size (200,200); stroke(255); background(0); // black frameRate(60); } int step = 5; float y = step; float x = step*2; int yDir = 1; int xDir = 1; int lineColor=0; float rr=0; float rb=0; void draw() { // //if (y >= (height-step) || y <= 0 ) { yDir *= -1; } //if (x >= (width-step) || x <= 0 ) { xDir *= -1; } if (y > (height-step) || y<=0) { yDir*= -1; xDir*=-1;} //if (x > (width-step)) { x=step; } y += (yDir * step); x += (xDir * step); stroke(rr,20,lineColor); if (lineColor < 255) { lineColor++; } else { if (lineColor == 255) { rr=random(255); rb=random(255); lineColor=0; //background(0); } lineColor--; } if (y == step && x == step) { background(0); } line(0+2, x, y, height-2); }