/**
FeedbackQuads
Dave Bollinger Jun 2007
http://www.davebollinger.com
Press spacebar to generate new pattern.
*/
import processing.opengl.*;
import javax.media.opengl.*;
PImage fbimg;
// configuration:
int nquads;
float offset;
float quadsize;
float lrotz, lrotdz;
float grotz, grotdz;
void setup() {
size(256,256,OPENGL);
frameRate(10);
textureMode(NORMALIZED);
strokeWeight(4f);
config();
}
void config() {
nquads = (int)(random(12))+2;
offset = random(10,100);
quadsize = random(40,120);
lrotdz = random(0,0.1f);
grotdz = random(0,0.1f);
// after a reconfiguration blank the texture image
fbimg = null;
fbimg = createImage(width,height,ARGB);
}
void draw() {
background(0);
camera();
// draw the feedback background
fill(255,245);
noStroke();
beginShape(QUADS);
texture(fbimg);
vertex(0,0, 0,0);
vertex(width,0, 1,0);
vertex(width,height, 1,1);
vertex(0,height, 0,1);
endShape();
// keep the colors, just clear depth buffer
// so that feedback quad doesn't interfere with source quads
((PGraphicsOpenGL)g).gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
// draw the new source material quads with recursive texture
fill(255);
stroke(255);
translate(width/2, height/2, 100);
float templrotz = lrotz;
for (int i=0; i