//See Mickey! //Author: Alex Rector //October 27, 2009 //This program uncovers Mickey Mouse when you drag the cursor //over the picture. (If you want to see the whole picture press "s") PImage mouse; PImage grey; void setup () { size(312,400); background (0); noStroke(); colorMode (HSB,360,100,100); smooth(); mouse = loadImage("mouse.jpg"); //load mickey mouse background grey = loadImage("grey.jpg");//load grey cover up image(grey,0,0); mouse.loadPixels(); } void draw(){ } void mousePressed() { //loads the pixels from the display mouse.loadPixels(); } void mouseDragged(){ int h, s, b, j, i, currentIndex = mouseX-1 + (mouseY-1)*mouse.width; color currentPixelColor; //mouse.loadPixels(); //sums the nine pixels h,s,b centered at the mouse for (h=0, s=0,b=0,j = 0; j<3; j++) { for (i = 0; i<3; i++) { h += hue(mouse.pixels[currentIndex+i]); s += saturation(mouse.pixels[currentIndex+i]); b += brightness(mouse.pixels[currentIndex+i]); } currentIndex += mouse.width; } //sets fill to be the average of the 10 pixels fill(color(h/10, s/10, constrain(b/10+20,0,100), 50)); //draws a circle wth the averaged fill at the location ellipse(mouseX, mouseY, 30,30); } //shows the picture void keyPressed() { if (key=='s') { image(mouse,0,0); } } // covers back up the picture void keyReleased() { image(grey,0,0); }