/* * Draw some lines... * */ // the initial spacing between lines, in pixels float spacing = 1f; // line width in pixels (from middle of line) float lineWidth = 1.5; // the multiplier for the spacing of successive lines float spaceMult = 1.001f; float startTime = 0f; void setup() { size(768, 512); background(0); strokeWeight(lineWidth); smooth(); startTime = millis(); } void draw() { background(0); //spaceMult = sin( (millis() - startTime)*0.0001f % PI)+1.0001f; spaceMult = (millis() - startTime)*0.0002f % 1f + 1.00001f; int iters = 0; int ctr=0; // counter var float space = spacing; //first draw white bg below fill(255); noStroke(); rect(0, 0, width, height*0.5); // draw black lines from center to top ctr = int(height*0.5-space); strokeWeight(lineWidth); stroke(0); while (ctr > 0 && iters < height) { iters++; line(0, ctr, width, ctr); ctr -= int(2*space); space *= spaceMult; } // draw white lines from center to bottom stroke(255); space = spacing; ctr = int(height*0.5-space); iters = 0; while (ctr < height && iters < height) { iters++; line(0, ctr, width, ctr); ctr += int(2*space); space *= spaceMult; } stroke(255); space = spacing; ctr = int(width*0.5-space); iters = 0; while (ctr < width && iters < width) { iters++; line(ctr, height*0.5, ctr, height); ctr += int(2*space); space *= spaceMult; } stroke(0); space = spacing; ctr = int(width*0.5-space); iters = 0; while (ctr > 0 && iters < width) { iters++; line(ctr, 0, ctr, height*0.5); ctr -= int(2*space); space *= spaceMult; } }