Rectangle m_rect; //rectangle library for hot spot detection import processing.video.*; import fullscreen.*; //for rome feeder import net.obxlabs.romefeeder.*; //romefeeder import com.sun.syndication.feed.synd.*; //ROME String getText; String showText; Feeder feeder; // the feeder int feedRate = 500; // rate for displaying posts (in miliseconds) int feedLast = 0; // time of the last displayed post SyndEntry entry; // feed entry FullScreen fs; //full screen library Capture video; //capture for motion tracking // GLOBAL CONSTANTS int NUM_MONSTERS = 4; // number of monster instances int NUM_TYPESHAPES = 55; // size of the characterset int AVG_FLOCKSIZE = 164; float AVG_TYPESIZE = 6.0; float AVG_SPEED = 3.0; int RESET_TIMER = 15000; // reset a flock automatically after a specified time boolean insideSquare = false; //detection hot spot float pSec; float cSet; int isec; int isec2; int dsec; Monster[] m = new Monster[NUM_MONSTERS]; PShape[] typeShape = new PShape[NUM_TYPESHAPES]; char[] charSet = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '.', ',', '!', '?', ' ', ':','@','#','*','<','>','=','^','-','_',';','~','(',')'}; // Character to integer mapping, I should have used ASCII encoding for this… //'0', '1', '2', '3', '4', '5', '6', '7', '8', '9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40' int idleTime, pIdleTime, actMonster; float DX=0; //darkest point of X float DY=0; //darkest point of Y void setup() { println(Capture.list()); //code for feeder feeder = new Feeder(); feeder.verbose = true; feeder.sort(Feeder.PUBLISHED_DATE); feeder.load("http://search.twitter.com/search.atom?q=hello"); feeder.setUpdateInterval(10000); feeder.startUpdate(); frameRate(30); size(1024, 768); // screen size smooth(); noStroke(); for (int i=0; i= feedRate)) { //get the next entry entry = feeder.next(); getText = entry.getTitle(); getText = getText.toLowerCase(); //update the feed timer feedLast = millis(); if(getText.length()<35) { showText = getText; println(showText + " : " + showText.length()); } } background(255); for (int i=0; i RESET_TIMER) { resetIdleTimer(); m[actMonster].resetFlock(); // reset active monster } //darkest point tracking if (video.available()) { video.read(); //image(video, 0, 0, 120, 90); // Draw the webcam video onto the screen int brightestX = 0; // X-coordinate of the brightest video pixel int brightestY = 0; // Y-coordinate of the brightest video pixel float brightestValue = 255; // Brightness of the brightest video pixel // Search for the brightest pixel: For each row of pixels in the video image and // for each pixel in the yth row, compute each pixel's index in the video video.loadPixels(); int index = 0; for (int y = 0; y < video.height; y++) { for (int x = 0; x < video.width; x++) { // Get the color stored in the pixel int pixelValue = video.pixels[index]; // Determine the brightness of the pixel float pixelBrightness = brightness(pixelValue); // If that value is brighter than any previous, then store the // brightness of that pixel, as well as its (x,y) location if (pixelBrightness < brightestValue) { brightestValue = pixelBrightness; brightestY = y; brightestX = x; } index++; } } float SA=0.94; DX=DX*SA+(1-SA)*brightestX; DY=DY*SA+(1-SA)*brightestY; // Draw a large, yellow circle at the brightest pixel //for debuging fill(255, 204, 0, 128); //rect(350,50,200,200); stroke(200); //display hot spot zone line(412,150,422,150); line(412,150,412,160); line(602,150,612,150); line(612,150,612,160); line(412,490,412,500); line(412,500,422,500); line(612,490,612,500); line(602,500,612,500); noStroke(); //just to show dark spot //ellipse(DX, DY, 20, 20); //hot spot if((DX>412) && (DX<612) && (DY>150) && (DY<500)){ //println("inside"); insideSquare = true; isec = second(); dsec = isec-isec2; } else{ if(insideSquare){ //release text only if dark point stays in square more than 2 second. if (dsec >2 ) { dotRelease(); } insideSquare = false; //isec2 = second(); } else isec2 = second(); } } } //mousereleased //disply text void dotRelease() { resetIdleTimer(); // determine which monster to reset float[] monsterDist = new float[m.length]; // create an array for storing the distances from the monsters to the mouse for (int i=0; i