import java.util.ArrayList;

import processing.core.*;
import processing.video.*;

public class HUEtube230 extends PApplet{
Movie video;
int width = 320;
int height = 262;
int arraySize = 22000;
int[] changeArray = new int[arraySize];
int[] xArray = new int[arraySize];
int[] yArray = new int[arraySize];
int counter = 0;

public void setup() {
size(width, height);
video = new Movie(this, "HUEtube230.mov");
video.play();
}

public void draw(){
if (video.available()) {
video.read();
background(0,0,0);
loadPixels();

for(int r = 0; r<height; r++){
for(int c = 0; c<width; c++){
int loc = r*width + c;
int p = video.pixels[loc];
float hue = hue(p);

if(hue == 230){
if (counter < changeArray.length){
changeArray[counter] = loc;
xArray[counter] = c;
yArray[counter] = r;
counter++;
} else{
counter = 0;
}
}
}
}

for (int i = 0; i<changeArray.length; i++){
pixels[changeArray[i]] = color(250, 33, 100);
}
updatePixels();
for (int i = 0; i<changeArray.length; i++){
if(i > 0){
stroke(250, 33, 100, 33);
line(xArray[i-1], yArray[i-1], xArray[i], yArray[i]);
}
}
//image(video,0,0);
}
}

public static void main(String args[]) {
PApplet.main(new String[] { "--present", "HUEtube230" });
}
}