This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

import processing.video.*; PImage bird; PImage cloud; PImage crabby; PImage dragon; PImage flyingturtle; PImage ghost; PImage happymushroom; PImage mysterymushroom; PImage pinkmonster; PImage redbug; PImage root; PImage turtle; PImage mouse; Capture video; float x = 0.0; float y = 0.0; float a = 0.0; float b = 0.0; float c = 0.0; float d = 0.0; float e = 0.0; float f = 0.0; float g = 0.0; float h = 0.0; float i = 0.0; float j = 0.0; float k = 0.0; float l = 0.0; float m = 0.0; float n = 0.0; float o = 0.0; float p = 0.0; float q = 0.0; float r = 0.0; float s = 0.0; float t = 0.0; float u = 0.0; float easing = 0.041; // numbers 0.0 to 10 void setup() { size(640, 480); // Change size to 320 x 240 if too slow at 640 x 480 // Uses the default video input, see the reference if this causes an error video = new Capture(this, width, height, 30); noStroke(); smooth(); bird = loadImage("bird_bomb.gif"); cloud = loadImage("cloud_waitforme.gif"); crabby = loadImage("crabby.gif"); dragon = loadImage("dragon_buzz.gif"); flyingturtle = loadImage("flying_turtle.gif"); ghost = loadImage("ghost.gif"); happymushroom = loadImage("happy_mushroom_guy.gif"); mysterymushroom = loadImage("mystery_mushroom.gif"); pinkmonster = loadImage("pink_monster.gif"); redbug = loadImage("redbug.gif"); root = loadImage("root.gif"); turtle = loadImage("turtle.gif"); mouse = loadImage("mouse.gif"); } void draw() { if (video.available()) { video.read(); image(video, 0, 0, width, height); // 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 = 0; // 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; // whats the difference between brightestValue and pixelBrightness? brightestY = y; brightestX = x; } index++; } } // Draw a large, yellow circle at the brightest pixel float targetX = brightestX; x += (targetX - x) * easing; float targetY = brightestY; y += (targetY - y) * easing; float targetA = x; a += (targetA - a) * easing; float targetB = y; b += (targetB - b) * easing; float targetC = a; c += (targetC - c) * easing; float targetD = b; d += (targetD - d) * easing; float targetE = c; e += (targetE - e) * easing; float targetF = d; f += (targetF - f) * easing; float targetG = e; g += (targetG - g) * easing; float targetH = f; h +=(targetH - h) * easing; float targetI = g; i +=(targetI - i) * easing; float targetJ = h; j +=(targetJ - j) * easing; float targetK = i; k +=(targetK - k) * easing; float targetL = h; l +=(targetL - l) * easing; float targetM = k; m +=(targetM - m) * easing; float targetN = l; n +=(targetN - n) * easing; float targetO = m; o +=(targetO - o) * easing; float targetP = n; p +=(targetP - p) * easing; // float target // fill(255, 204, 0, 128); image(mouse, brightestX, brightestY); // this ellipse needs a pacman mouth image(pinkmonster, x/2, y); image(cloud, a/3, b/2); image(ghost, c*1.5, d/2); image(crabby, e, f*1.75); image(bird, g, h/5); image(dragon, i, j*1.3); image(flyingturtle, k*1.5, l/8); image(happymushroom, m*1.25, n); image(mysterymushroom, o*2, p/5); } }

Source code: fan_club_4_barcade

Built with Processing