import UDP.*; //import the library to talk to the iColor Tile import processing.video.*; //import the video lib //intialize objects UDPSend udp; Pixelizer [] nakedImages; PFont useFont; Capture video; //initialize variables int currImg = 0; int totalImages = 3; float threshold = 60; //light sensitivity threshold boolean displayPixel = true; //when true, display the actual pixel, when false display the color in binary void setup() { size(240, 240); noStroke(); colorMode(RGB); nakedImages = new Pixelizer[3]; nakedImages[0] = new Pixelizer("albasmall.jpg"); nakedImages[1] = new Pixelizer("bikinismall.jpg"); nakedImages[2] = new Pixelizer("mankinismall.jpg"); setFont("Geneva-64.vlw", 64); video = new Capture(this, 10, 10, 30); //initiate the video, resolution and frame rate //create the UDP object to talk to the iColor Tile12 udp = new UDPSend(this,"10.0.9.93",6038,"/Users/coreymenscher/Desktop/projects/ITP/classwork/pComp/final/colorkinetics_lib/header","/Users/coreymenscher/Desktop/projects/ITP/classwork/pComp/final/colorkinetics_lib/lookup",200,0); } void captureEvent(Capture video) { video.read(); } class Pixelizer { PImage theImg; int currPixel = 0; //current pixel counter boolean showingPixelColor = true; //set to true when LEDs are showing the currPixel value to reset the transitional counter int currPixelBin = 0; Pixelizer(String filename) { theImg = loadImage(filename); loadPixels(); println("displaying image " + filename); } //display the actual pixel color void showPixel() { //mode 0 = pixel color, mode 1 = binary display background(0); int c = theImg.pixels[currPixel]; fill(c); rect(0,0,width,height); delay(500); //slow down or you'll give someone a seizure currPixel = currPixel+10; if(currPixel >= theImg.pixels.length) { currPixel = 0; currImg++; } } //display the color's binary value void showPixelBinary() { background(255); textSize(200); textAlign(CENTER, CENTER); color c = theImg.pixels[currPixel]; String theBinaryColor = binary(c); if(showingPixelColor) { fill(0); text(theBinaryColor.charAt(currPixelBin), width/2, height-50); delay(300); } else { fill(255); rect(0,0,width,height); } showingPixelColor = !showingPixelColor; //flip the bit delay(100); currPixelBin++; if(currPixelBin >= theBinaryColor.length()-1) { currPixelBin = 0; currPixel = currPixel+10; } } void ambientLightTest() { boolean isDark = false; float currBright = 0; int darkPixels = 0; for(int row=0; row= 80) { println("OH NOES IT'S DARK!"); displayPixel = false; } else { displayPixel = true; } } //where the magic happens void run() { ambientLightTest(); if(displayPixel) { showPixel(); } else { showPixelBinary(); } if(currPixel > theImg.pixels.length) { //reset the pixel array and move to the next image currPixel = 0; currImg++; if(currImg > totalImages-1) currImg = 0; //cycle through the images defined in nakedImages array } } } void draw() { nakedImages[currImg].run(); if(currImg > totalImages-1) currImg = 0; //println("udp.send() disabled!!!!"); udp.send(); } //my generic font configuration function void setFont(String _fontFile, int _fontSize) { useFont = loadFont(_fontFile); textFont(useFont, _fontSize); }