IdeaMonk

thoughts, ideas, code and other things...

Tuesday, November 18, 2008

Some work in Process (progress ?!)

Some work I've been recently doing in Processing 1.0. I can't show applets for these, each of them too more than 20 minutes to render! Will talk more about how I did the second one and 4th one in detail later. All this began in C++ and allegro one day... I haven't yet got the effects I wished to program :| but, processing is taking these experiments into a whole new direction!











An example for what I call circulation-fx -
Put this image into data folder int the processing project you created
This is the code that breaks it into beautiful circles -

/* Circulation-fx */
/* crappy-test version */

PGraphics buffer,checkbak;
PFont font;
PImage girl;
color blend1, blend2,src,original,test;
/* ******************* configuration variables */
int tolerance = 15, bmax = 100, bsize;
// adjust tolerance and bmax(max size for circles)

int sX, sY;
boolean possible = true;
float stime;
char c;
String s;

void setup(){
noLoop();

background (255,255,255);

/* *************** change the image here ********************** */
girl = loadImage ("surfing.jpg");
size(girl.width,girl.height);
buffer = createGraphics (girl.width,girl.height,P3D);
buffer.beginDraw();
buffer.noStroke();
buffer.background(255);
buffer.textFont(font);
buffer.endDraw();

stime=millis();
loop();
}

void draw(){
buffer.beginDraw();

possible = true;
bsize=2;

sX=int(random(screen.width));
sY=int(random(screen.height));
test = girl.get(sX,sY);

original=blend2=blend1 = girl.get (sX,sY);

while (possible && bsize<= tolerance && abs(blue(blend1)-blue(blend2)) <= tolerance && abs(green(blend1)-green(blend2)) <= tolerance){ bsize+=1; blend1=blend2; } else { possible=false; } if (bsize>bmax)
possible=false;
}

// crappy string hack
c=(char)(random(25)); c=char(c+'a'+1); s=""; s=s+c;
buffer.stroke((int)red(original),(int)green(original),(int)blue(original),
255- ((float)bsize/float(bmax))*200
);

buffer.noFill();
buffer.ellipse( sX,sY,bsize,bsize);

image(buffer,0,0);

if (millis()-stime >= 20000){
stime=millis();
saveFrame("out/frame-#######.png");
}

buffer.endDraw();
}

void mousePressed(){
noLoop();
}

void mouseReleased(){
loop();
}
Don't forget to have an 'out' folder in the project folder and the image in the 'data' folder.
have a look here too...

Labels: , ,

1 Comments:

At November 19, 2008 at 12:34 AM , Anonymous Tomek said...

great work.. but looks like unfinished one, try making this work faster and try posting a better looking code once you're dome with it... best of luck!

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home