// Bouncy pixel_flow (2005. 2. 25.) // by SeungJoon Choi // erucipe@hanmail.net // inspired by itunes visualizer // shining code hint from http://www.harukit.com/ // http://processing.org BGraphics buffer; float[] theta_field; void setup() { size(320, 240); theta_field = new float[width * height]; buffer = new BGraphics(width, height); buffer.format = RGB; ellipseMode(CENTER_RADIUS); buffer.background(0); buffer.ellipseMode(CENTER_RADIUS); buffer.noFill(); prepareShine(); setThetaField(); } void mousePressed() { setThetaField(); } void setThetaField() { noiseDetail(2+(int)random(6), random(1)); for(int y = 0; y < height; y++) { for(int x = 0; x < width; x++) { int i = y * width + x; theta_field[i] = noise(x*0.02, y*0.02); } } } int turn = 60; int iter = 0; void loop() { if(iter > turn) { turn = (int)random(60); iter = 0; prepareShine(); } iter++; /* buffer.strokeWeight(5); buffer.stroke(255, 255, 0, 32); buffer.ellipse(mouseX, mouseY, 20, 20); */ transfer(g); shiningBlur(g); System.arraycopy(g.pixels, 0, buffer.pixels, 0, buffer.pixels.length); /* fill(0, 0, 255, 64); rect(0, 0, width, height); */ } int Red(int c) { return (c & 0xff0000) >> 16; } int Green(int c) { return (c & 0x00ff00) >> 8; } int Blue(int c) { return c & 0x0000ff; } float r = 5; float angle = 0; void transfer(BGraphics target) { int index; int sumr, sumg, sumb; float ox, oy, dx, dy, theta; ox = width * 0.5; oy = height * 0.5; int x, y; angle += 0.005*PI; //angle = 0.4*PI; //angle += 0.01*cos(millis()*0.001)*PI; r = 1+19*(cos(millis()*0.0002)); for(int j=0;j width-1) x = width-1; if(y < 0) y = 0; if(y > height-1) y = height-1; index = y*width+x; target.pixels[i*width+j]=buffer.pixels[index]; } } } void shiningBlur(BGraphics target) { //float divider = 4.99 + random(0.5); //float divider = 5; float divider = 5 + (1-random(2))*0.2; int index,left,right,top,bottom; int sumr, sumg, sumb; for(int j=0;j0) left=-1; else left=width-1; if(j==(width-1)) right=-width+1; else right=1; if(i>0) top=-width; else top=(height-1)*width; if(i==(height-1)) bottom=-(height-1)*width; else bottom=width; // Calculate the sum of n neighbors sumr=Red(target.pixels[left+index]); // left middle sumg=Green(target.pixels[left+index]); sumb=Blue(target.pixels[left+index]); sumr+=Red(target.pixels[right+index]); // right middle sumg+=Green(target.pixels[right+index]); sumb+=Blue(target.pixels[right+index]); sumr+=Red(target.pixels[index]); // middle middle sumg+=Green(target.pixels[index]); sumb+=Blue(target.pixels[index]); sumr+=Red(target.pixels[index+top]); // middle top sumg+=Green(target.pixels[index+top]); sumb+=Blue(target.pixels[index+top]); sumr+=Red(target.pixels[index+bottom]); // middle bottom sumg+=Green(target.pixels[index+bottom]); sumb+=Blue(target.pixels[index+bottom]); sumr=(int)((float)sumr/divider); sumg=(int)((float)sumg/divider); sumb=(int)((float)sumb/divider); dis =dist(mouseX, mouseY,j,i)/2; sumr += cc[0]/dis-gain; sumg += cc[1]/dis-gain; sumb += cc[2]/dis-gain; target.pixels[index] = color(sumr, sumg, sumb); } } } float rr,gg,bb,dis; int gain = 3; float[] cc = new float[3]; void prepareShine() { for(int i=0;i<3;i++){ cc[i]=random(40)+random(40)+random(40)+random(40)+random(40); } }