import processing.video.*; import processing.opengl.*; /* * * draw circles inside one another, offset * * by pixelpusher * http://pixelist.info * pixelpusher@pixelist.com * Apr 27 2008 * keys: u,i,o (rotation - dec,initialize,increase) * z - start save, x - finish save * and more... q,w,e and a,s,d - see below * */ int numCircles = 10; int ctr = 0; // counter var float rotIncVal = 1f/(numCircles*300f); float rotInc = rotIncVal; int MAX_DIAMETER; // pixels int MIN_DIAMETER; // pixels static int FRAMERATE = 30; float rotation = 0; int transY = 15; float d; boolean saving = false; MovieMaker mm; float f1,f2,f3; void setup() { size(512, 512, JAVA2D); background (1f,1f, 0.9f); smooth(); colorMode(HSB, 1.0); ellipseMode(CENTER); rectMode(CORNER); frameRate(FRAMERATE); rotInc = rotIncVal; // this is fun to play with d = width * 1f; } void draw() { noStroke(); fill(1f,1f, 0.8f, 0.3f); rect(0,0, width, height); translate(width/2, height/2 - transY); rotate(rotation); drawCircle(numCircles); if (saving) mm.addFrame(); // Add window's pixels to movie } void drawCircle(int index) { f1=1f; f2=1f; f3=1f; rotation += rotInc; rotate(rotation); translate(0, transY); f1 = 0.35*pow(float(index)/float(numCircles), 2) + 0.5; f3 = 1f - f1; fill(f1, 1f, 0.8f, 1f/numCircles); // this creates some cool results - you'll need to change the ellipse line below if // you ucomment it, though. //scale(0.85); ellipse(0, 0, d*index/numCircles, d*index/numCircles); // x,y, width, height if (index > 0) drawCircle(index-1); } void keyPressed() { if (key == 'x') { saving = false; mm.finish(); // Finish the movie if space bar is pressed! } else if (key == 'i') { rotation = 0; } else if (key == 'o') { rotation *= 1.5; } else if (key == 'u') { rotation /= 1.5; } else if (key == 'q') { rotInc -= rotIncVal; } else if (key == 'w') { rotInc *= -1f; } else if (key == 'e') { rotInc += rotIncVal; } else if (key == 'a') { rotInc /= 2f; } else if (key == 's') { rotInc *= -1f; } else if (key == 'd') { rotInc *= 2f; } else if (key == '1') { numCircles /= 1.5; } else if (key == '2') { numCircles *= 1.5; } else if (key == 'z') { mm = new MovieMaker(this, width, height, "offsetcircles" + System.currentTimeMillis() + ".mov", 30, MovieMaker.JPEG, MovieMaker.BEST); saving = true; } }