Abbreviated version
When having the problem with the face not sticking I wasn’t sure how long Mark would take to get back to me, I remembered Mark saying that last year Jason posted his problem up on the processing forum and got answers really quickly. I thought what the hell and gave it a go and it definitely got me results, although not as fast as Mark. The guy on the forum did come up with one more solution though that was incredibly helpful, a way to abbreviate my code. As it stood before i was declaring each picture being imported into the processing sketch on a single line. I had over 300 images that i wasn’t looking forward to all that typing. This is what my coding looks like now.
PImage bg;
PImage[] featLEye = new PImage[89];
PImage[] featREye = new PImage[89];
PImage[] featMouth = new PImage[91];
PImage[] featNose = new PImage[82];
int leye, reye, mouth, nose;
void setup(){
bg = loadImage("mattface4.png");
size(1024,972);
for (int i = 0; i < featLEye.length; i++) featLEye[i] = loadImage("le"+i+".png");
for (int i = 0; i < featREye.length; i++) featREye[i] = loadImage("re"+i+".png");
for (int i = 0; i < featMouth.length; i++) featMouth[i] = loadImage("mouth"+i+".png" );
for (int i = 0; i < featNose.length; i++) featNose[i] = loadImage("nose"+i+".png"); }
void draw(){
background(bg);
image(featMouth[mouth],0,0, 1024,972);
image(featNose[nose],0,0, 1024,972);
image(featLEye[leye],0,0, 1024,972);
image(featREye[reye],0,0, 1024,972); }
void keyPressed() {
if (key == 'n' || key == 'N') nose=int(random(82));
else if (key == 'l' || key == 'L') leye=int(random(89));
else if (key == 'r' || key == 'R') reye=int(random(89));
else if (key == 'm' || key == 'M') mouth=int(random(91));
else if (key == 's' || key == 'S') saveFrame("face-####.tif");
}
What he did was create a floating int variable that meant that processing was able to look for any files with the same name and import all variations of it at once.
June 10th, 2008 - Posted in Double Project | | 0 Comments
Leave a reply
You must be logged in to post a comment.
