<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.roberttwomey.com/index.php?action=history&amp;feed=atom&amp;title=Dance_in_the_Dark.pde</id>
		<title>Dance in the Dark.pde - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.roberttwomey.com/index.php?action=history&amp;feed=atom&amp;title=Dance_in_the_Dark.pde"/>
		<link rel="alternate" type="text/html" href="http://wiki.roberttwomey.com/index.php?title=Dance_in_the_Dark.pde&amp;action=history"/>
		<updated>2026-10-01T08:44:00Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.27.1</generator>

	<entry>
		<id>http://wiki.roberttwomey.com/index.php?title=Dance_in_the_Dark.pde&amp;diff=4040&amp;oldid=prev</id>
		<title>Elenyui: New page: //Dance in the Dark  import processing.video.*; Capture video; PGraphics buffer; PImage img;  int brightestX = 0; // X-coordinate of the brightest video pixel int brightestY = 0; // Y-coor...</title>
		<link rel="alternate" type="text/html" href="http://wiki.roberttwomey.com/index.php?title=Dance_in_the_Dark.pde&amp;diff=4040&amp;oldid=prev"/>
				<updated>2010-06-05T23:13:44Z</updated>
		
		<summary type="html">&lt;p&gt;New page: //Dance in the Dark  import processing.video.*; Capture video; PGraphics buffer; PImage img;  int brightestX = 0; // X-coordinate of the brightest video pixel int brightestY = 0; // Y-coor...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;//Dance in the Dark&lt;br /&gt;
&lt;br /&gt;
import processing.video.*;&lt;br /&gt;
Capture video;&lt;br /&gt;
PGraphics buffer;&lt;br /&gt;
PImage img;&lt;br /&gt;
&lt;br /&gt;
int brightestX = 0; // X-coordinate of the brightest video pixel&lt;br /&gt;
int brightestY = 0; // Y-coordinate of the brightest video pixel&lt;br /&gt;
int lastX, lastY;&lt;br /&gt;
&lt;br /&gt;
int currentFrame = 0; &lt;br /&gt;
PImage[] frames = new PImage[12]; &lt;br /&gt;
int lastTime = 0; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup() &lt;br /&gt;
{ &lt;br /&gt;
size(700, 500, P3D); &lt;br /&gt;
video = new Capture(this, width, height, 30);&lt;br /&gt;
noStroke(); &lt;br /&gt;
smooth(); &lt;br /&gt;
buffer = createGraphics(700, 500, P3D);&lt;br /&gt;
&lt;br /&gt;
background(102); &lt;br /&gt;
&lt;br /&gt;
for (int i = 0; i &amp;lt; frames.length; i++) { &lt;br /&gt;
frames[i] = get(); // Create a blank frame &lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void draw() &lt;br /&gt;
{ &lt;br /&gt;
background(0);&lt;br /&gt;
&lt;br /&gt;
int currentTime = millis(); &lt;br /&gt;
if (currentTime &amp;gt; lastTime+30) { &lt;br /&gt;
&lt;br /&gt;
lastTime = currentTime; //Setting the refresh rate of the recording&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//replaces mousepressing line drawing&lt;br /&gt;
if (video.available()) {&lt;br /&gt;
int threshold = 1; &lt;br /&gt;
video.read();&lt;br /&gt;
image(video, 0, 0, width, height); // Draw the webcam video onto the screen&lt;br /&gt;
&lt;br /&gt;
img=buffer.get();&lt;br /&gt;
image(buffer, 0, 0, 700, 500); // RDT: draw the offscreen buffer on top of the webcam video&lt;br /&gt;
nextFrame(); &lt;br /&gt;
&lt;br /&gt;
//filter(BLUR, 2);&lt;br /&gt;
float brightestValue = 0; // Brightness of the brightest video pixel&lt;br /&gt;
// Search for the brightest pixel: For each row of pixels in the video image and&lt;br /&gt;
// for each pixel in the yth row, compute each pixel&amp;#039;s index in the video&lt;br /&gt;
video.loadPixels();&lt;br /&gt;
int index = 0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
lastX = brightestX;&lt;br /&gt;
lastY = brightestY;&lt;br /&gt;
&lt;br /&gt;
for (int y = 0; y &amp;lt; video.height; y++) {&lt;br /&gt;
for (int x = 0; x &amp;lt; video.width; x++) {&lt;br /&gt;
// Get the color stored in the pixel&lt;br /&gt;
int pixelValue = video.pixels[index];&lt;br /&gt;
// Determine the brightness of the pixel&lt;br /&gt;
float pixelBrightness = brightness(pixelValue);&lt;br /&gt;
// If that value is brighter than any previous, then store the&lt;br /&gt;
// brightness of that pixel, as well as its (x,y) location&lt;br /&gt;
if (pixelBrightness &amp;gt; brightestValue) {&lt;br /&gt;
brightestValue = pixelBrightness;&lt;br /&gt;
brightestY = y;&lt;br /&gt;
brightestX = x;&lt;br /&gt;
}&lt;br /&gt;
index++;&lt;br /&gt;
}&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//fill(255, 100, 50, 70);&lt;br /&gt;
if (brightestValue &amp;gt; threshold) { // If the test location is brighter than&lt;br /&gt;
noStroke();&lt;br /&gt;
//fill (255);&lt;br /&gt;
// the threshold set the fill to black&lt;br /&gt;
&lt;br /&gt;
variableEllipse(lastX, lastY, brightestX, brightestY); &lt;br /&gt;
nextFrame();&lt;br /&gt;
} &lt;br /&gt;
else { // Otherwise,&lt;br /&gt;
noStroke();&lt;br /&gt;
//fill(255,0); // set the fill to random&lt;br /&gt;
variableEllipse(lastX, lastY, brightestX, brightestY); &lt;br /&gt;
nextFrame();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
void nextFrame() &lt;br /&gt;
{ &lt;br /&gt;
frames[currentFrame] = buffer.get(); // Get the display window &lt;br /&gt;
currentFrame++; // Increment to next frame &lt;br /&gt;
if (currentFrame &amp;gt;= frames.length) { &lt;br /&gt;
currentFrame = 0; &lt;br /&gt;
} &lt;br /&gt;
image(frames[currentFrame], 0, 0); &lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void variableEllipse(int x, int y, int px, int py) &lt;br /&gt;
{&lt;br /&gt;
float speed = abs(x-px) + abs(y-py);&lt;br /&gt;
&lt;br /&gt;
stroke(speed);&lt;br /&gt;
&lt;br /&gt;
// RDT: draw to the offscreen buffer&lt;br /&gt;
buffer.beginDraw();&lt;br /&gt;
buffer.noStroke();&lt;br /&gt;
buffer.fill(random(0,255), random(0,255), random(0,255), 160);&lt;br /&gt;
buffer.ellipse(px, py, speed/4, speed/4);&lt;br /&gt;
buffer.endDraw();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if mouseClicked(){&lt;br /&gt;
setup();&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Elenyui</name></author>	</entry>

	</feed>