// cirkel v.001 elout de kok 2004 // http://www.xs4all.nl/~elout/ // processing.org - v.067 BImage pfoto,backg; int fx=1,maxfx=2; String fxname=""; //for the precalculated circle buffer int maxd=2048; float [] cosd = new float[maxd]; float [] sind = new float[maxd]; int ybuffer[]; int photowidth=374; int photoheight=500; int nocircs=200; mycirk bob[] = new mycirk[nocircs]; int midx,midy; // used for fps int new_sec,old_sec,my_fps,temp_fps; void setup() { size(748,500); pfoto = loadImage("toxi2_16aug03.jpg"); //photobuffer=new int [width*height]; image(pfoto, 0, 0, photowidth, photoheight); image(pfoto, photowidth, 0, photowidth, photoheight); //copy the 2 photo`s into memory backg = copy(); //make a precalculated ybuffer storing y*width ybuffer=new int [height]; for (int i=0;imaxfx){fx=0;} //fx=(int) random(maxfx+1); //background(128); } //--------------------- class mycirk { int stepper; int pos; int xpos, ypos; int sxpos, sypos; int r,g,b; boolean drawstate; int sizer; mycirk() { pos=0; sizer=(int)random(140)+1; stepper=(int)random(80)+1; sxpos=(int)random(width); sypos=(int)random(height); r=(int)random(20)+1; g=r;//(int)random(10)+1; b=r;//(int)random(10)+1; if((int)random(2)==0){ drawstate=false;} else { drawstate=true;} } //update a circle void calc00() { xpos=sxpos + ((int) (cosd[pos]*sizer)); ypos=sypos + ((int) (sind[pos]*sizer)); if (xpos>-1 && ypos>-1 && xpos> 16) & 0xff); //g=255-((backg.pixels[ybuffer[ypos]+xpos] >> 8) & 0xff); // b=255-(backg.pixels[ybuffer[ypos]+xpos] & 0xff); minpoint( pixels,ybuffer[ypos]+xpos, (270-r)/40,(270-g)/40,(270-b)/40); } else { //r=((backg.pixels[ybuffer[ypos]+xpos] >> 16) & 0xff); //g=((backg.pixels[ybuffer[ypos]+xpos] >> 8) & 0xff); //b=(backg.pixels[ybuffer[ypos]+xpos] & 0xff); addpoint( pixels,ybuffer[ypos]+xpos, r/40,g/40,b/40); } } pos=pos+stepper; if (pos>=maxd) //full circle drawn? { sizer=(int)random(60)+1; stepper=(int)random(180)+4; sxpos=(int)random(width); sypos=(int)random(height); r=((backg.pixels[ybuffer[sypos]+sxpos] >> 16) & 0xff); g=((backg.pixels[ybuffer[sypos]+sxpos] >> 8) & 0xff); b=(backg.pixels[ybuffer[sypos]+sxpos] & 0xff); //if(sxpos<0){sxpos=width+sxpos;} //if(sypos<0){sypos=height+sypos;} //if(sxpos>width){sxpos=sxpos-width;} //if(sypos>height){sypos=sypos-height;} pos=0; } } //update a circle void calc01() { xpos=sxpos + ((int) (cosd[pos]*sizer)); ypos=sypos + ((int) (sind[pos]*sizer)); if (xpos>-1 && ypos>-1 && xpos> 16) & 0xff); g=255-((backg.pixels[ybuffer[ypos]+xpos] >> 8) & 0xff); b=255-(backg.pixels[ybuffer[ypos]+xpos] & 0xff); minpoint( pixels,ybuffer[ypos]+xpos, r/40,g/40,b/40); } else { r=((backg.pixels[ybuffer[ypos]+xpos] >> 16) & 0xff); g=((backg.pixels[ybuffer[ypos]+xpos] >> 8) & 0xff); b=(backg.pixels[ybuffer[ypos]+xpos] & 0xff); addpoint( pixels,ybuffer[ypos]+xpos, r/40,g/40,b/40); } } pos=pos+stepper; if (pos>=maxd) //full circle drawn? { sizer=(int)random(240)+1; stepper=(int)random(80)+1; r=(int)random(6)+1; g=r; b=r; sxpos=(int)random(width); sypos=(int)random(height); //if(sxpos<0){sxpos=width+sxpos;} //if(sypos<0){sypos=height+sypos;} //if(sxpos>width){sxpos=sxpos-width;} //if(sypos>height){sypos=sypos-height;} pos=0; } } //update a circle void calc02() { xpos=sxpos + ((int) ((float)cosd[pos]*sizer)); ypos=sypos + ((int) ((float)sind[pos]*sizer)); if (xpos>-1 && ypos>-1 && xpos=maxd) //full circle drawn? { sizer++;//=(int)random(140)+1; if(sizer>150){sizer=4;} //stepper=(int)random(80)+1; r=(int)random(12)+1; g=r; b=r; sxpos=(int)random(width); sypos=(int)random(height); if(sxpos<0){sxpos=width+sxpos;} if(sypos<0){sypos=height+sypos;} if(sxpos>width){sxpos=sxpos-width;} if(sypos>height){sypos=sypos-height;} pos=0; } } //update a circle void calc03() { xpos=sxpos + ((int) ((float)cosd[pos]*sizer)); ypos=sypos + ((int) ((float)sind[pos]*sizer)); if (xpos>-1 && ypos>-1 && xpos=maxd) //full circle drawn? { sizer--;//=(int)random(140)+1; if(sizer<4) { sizer=200; sxpos=(int)random(width); sypos=(int)random(height); } stepper=(int)random(80)+1; r=(int)random(10)+1; g=r; b=r; // sxpos=sxpos++;//((int)random(12)-6); // sypos=sypos++; //sypos=sypos+((int)random(12)-6); if(sxpos<0){sxpos=width+sxpos;} if(sypos<0){sypos=height+sypos;} if(sxpos>width){sxpos=sxpos-width;} if(sypos>height){sypos=sypos-height;} pos=0; } } } void addpoint(int output[],int posi, int r, int g, int b) { r=r+((output[posi] >> 16) & 0xff); g=g+((output[posi] >> 8) & 0xff); b=b+(output[posi] & 0xff); if (r>255){r=255;} if (g>255){g=255;} if (b>255){b=255;} output[posi] = ( (0xff<<24) | (r<<16) | (g<<8) | b); } void minpoint(int output[],int posi, int r, int g, int b) { r=((output[posi] >> 16) & 0xff)-r; g=((output[posi] >> 8) & 0xff)-g; b=(output[posi] & 0xff)-b; if (r<0){r=0;} if (g<0){g=0;} if (b<0){b=0;} if (r>255){r=255;} if (g>255){g=255;} if (b>255){b=255;} output[posi] = ( (0xff<<24) | (r<<16) | (g<<8) | b); } void copyar2(int input[], int output[], int inputstart, int outputstart, int sizer) // source, destination { System.arraycopy(input, inputstart, output, outputstart, sizer); }