<Back

//Aaron Koblin
//Design for Interactive Media 157A
//11/22/04
 

//Memecry is an application which re-creates images from corporate logos. //Designed for use with a webcam, the application draws images of the viewer //out of logos. The internet version of the application uses stock images //to demonstrate the technology.

int stagex = 400; //stage width int stagey = 400; //steage height int numads = 199; //# of sprites per stroke int state = 1; //initial bg int opac; //int fadelay; BImage fade; BImage bg1, bg2, bg3, bg4; BImage bgbig, bgbars, black1, white1, red1, green1, blue1, yellow1, purple1, turquois1; BImage white2, red2, green2, blue2, yellow2, turquois2, purple2; BImage red3, blue3, blue4,skin1,skin2; int[] bgpixels, stage; Ad[] myAd; void setup(){ framerate(30); // fadedelay = 0; background(255); size(stagex, stagey); fade = loadImage("fade.jpg"); tint(255,255,255,255); image(fade, 0, 0, stagex, stagey); imageMode(CENTER_DIAMETER); bgbig = loadImage("bgbig.jpg"); bgbars = loadImage("bgbars.jpg"); red1 = loadImage("red1.gif"); red2 = loadImage("red2.gif"); red3 = loadImage("red3.gif"); green1 = loadImage("green1.gif"); green2 = loadImage("green2.gif"); blue1 = loadImage("blue1.gif"); blue2 = loadImage("blue2.gif"); blue3 = loadImage("blue3.gif"); blue4 = loadImage("blue4.gif"); yellow1 = loadImage("yellow1.gif"); yellow2 = loadImage("yellow2.gif"); purple1 = loadImage("purple1.gif"); purple2 = loadImage("purple2.gif"); turquois1 = loadImage("turquois1.gif"); turquois2 = loadImage("turquois2.gif"); white1 = loadImage("white1.gif"); black1 = loadImage("black.gif"); skin1 = loadImage("skin1.gif"); skin2 = loadImage("skin2.gif"); //beginVideo(1280, 800, 4); bgpixels = new int[width*height]; stage = new int[width*height]; myAd = new Ad[numads]; for(int i=0; i<numads; i++) { int xpos = int(random(width)); // x-position int ypos = int(random(height)); // x-position myAd[i] = new Ad(xpos, ypos); } bg1 = loadImage("bg.jpg"); bg2 = loadImage("bg2.jpg"); bg3 = loadImage("bg3.jpg"); bg4 = loadImage("bg4.jpg"); initbg(); } void loop(){ opac = 100; //opac = int(random(100)); /* tint(255,255,255,1); if(fadedelay > 50){ image(fade, 0, 0, stagex, stagey); //causes fade effect fadedelay = 0; }else fadedelay++; */ for(int i=0; i<numads; i++) { myAd[i].x = int(random(width)); myAd[i].y = int(random(height)); myAd[i].setcolor(); myAd[i].display(); } } void initbg(){ BImage thepicture = bg1; if(state == 1){ thepicture = bg1; } if(state == 2){ thepicture = bg2; } if(state == 3){ thepicture = bg3; } if(state == 4){ thepicture = bg4; } for(int i=0; i<width*height; i++) { bgpixels[i] = thepicture.pixels[i]; } } void videoEvent() { initbg(); } void mousePressed() { state++; if(state > 4){ state = 1; } initbg(); } void keyPressed(){ if (key == 'b'){ BImage thepicture = bgbars; for(int i=0; i<width*height; i++) { stage[i] = thepicture.pixels[i]; } } if (key == 'c'){ BImage thepicture = video; for(int i=0; i<width*height; i++) { stage[i] = thepicture.pixels[i]; } } } class Ad { int x; int y; int size = int(random(20)); color tintcl; String cl; BImage ad; Ad(int xpos, int ypos) { x = xpos; y = ypos; } void setcolor() { int avgcl; tintcl = (bgpixels[y*width+x]) + color(0, 0, 0,opac); avgcl = int(((red(tintcl) + green(tintcl) + blue(tintcl))/3))+15; if(avgcl > 28){ if(red(tintcl) > avgcl){ if(blue(tintcl) > avgcl){ ad = purplepic(); tint(red(tintcl)+blue(tintcl),opac); }else {ad = yellowpic(); tint(tintcl); if(green(tintcl) > avgcl){ if(blue(tintcl) > (avgcl/2)){ ad = skin1; tint(tintcl); }else{ if(blue(tintcl) > (avgcl/5)){ ad = skin2; tint(tintcl); } } }else{ ad = redpic(); tint(tintcl); } } }else{ if(green(tintcl) > avgcl){ if(blue(tintcl) > avgcl){ ad = turquoispic(); tint(tintcl); }else {ad = greenpic(); tint(tintcl); } }else{ if(blue(tintcl)>avgcl){ ad = bluepic(); tint(blue(tintcl),opac); }else{ ad = white1; tint(avgcl,opac);} } } if(avgcl > 235){ ad = white1; tint(tintcl); } } else{ tint(avgcl*4, opac); ad = black1; } } void display() { image(ad, x, y, size, size); } } BImage redpic(){ int x = int(random(3)); BImage thepic = red3; if(x == 0){ thepic = red1;} if(x == 1){ thepic = red2;} if(x == 2){ thepic = red3;} return(thepic); } BImage yellowpic(){ int x = int(random(2)); BImage thepic = red3; if(x == 0){ thepic = yellow1;} if(x == 1){ thepic = yellow2;} return(thepic); }BImage bluepic(){ int x = int(random(4)); BImage thepic = blue1; if(x == 0){ thepic = blue1;} if(x == 1){ thepic = blue2;} if(x == 2){ thepic = blue3;} if(x == 3){ thepic = blue4;} return(thepic); }BImage greenpic(){ int x = int(random(2)); BImage thepic=green1; if(x == 0){ thepic = green1;} if(x == 1){ thepic = green2;} return(thepic); } BImage turquoispic(){ int x = int(random(2)); BImage thepic=turquois1; if(x == 0){ thepic = turquois1;} if(x == 1){ thepic = turquois2;} return(thepic); } BImage purplepic(){ int x = int(random(2)); BImage thepic=purple1; if(x == 0){ thepic = purple1;} if(x == 1){ thepic = purple2;} return(thepic); } BImage skinpic(){ int x = int(random(2)); BImage thepic=skin1; if(x == 0){ thepic = skin1;} if(x == 1){ thepic = skin2;} return(thepic); } static public void main(String args[]) { try { Frame frame = new Frame(); // !!! // change this to your sketch name... Class c = Class.forName("memecry2"); BApplet applet = (BApplet) c.newInstance(); applet.init(); applet.start(); // get default screendevice and configuration GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice (); GraphicsConfiguration gc = gd.getDefaultConfiguration(); frame.setUndecorated(true); frame.setBackground(Color.black); frame.setLayout(new GridBagLayout()); frame.add(applet); frame.pack(); // test if fullscreen mode is available (jvm 1.4+) and activate it if (gd.isFullScreenSupported()) { gd.setFullScreenWindow(frame); } // test if display mode is available (jvm 1.4+) and set it to the // size of the applet if (gd.isDisplayChangeSupported()) { gd.setDisplayMode(new DisplayMode(applet.g.width, applet.g.height, 32, 0)); } frame.setLocation(0, 0); frame.show(); applet.requestFocus(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } catch (Exception e) { e.printStackTrace(); System.exit(1); } }
Built with Processing