//size of each rect int cellsize = 20; //number of columns and rows in our system int COLS, ROWS; int trackColor; int sz; void setup() { size(800, 600); //set up columns and rows COLS = width/cellsize; ROWS = height/cellsize; colorMode(RGB,255,255,255,100); rectMode(CENTER_DIAMETER); background(255,0,0); //start our video stream beginVideo(COLS,ROWS,15); trackColor = color(206,90,107); } void loop() { background(255,0,0); beginShape(LINE_STRIP); //begin loop for columns for ( int i = 0; i < COLS;i++) { //begin loop for rows for ( int j = 0; j < ROWS;j++) { int loc = i + j*video.width; color currentColor = video.pixels[loc]; float R = red(currentColor); float G = green(currentColor); float B = blue(currentColor); float R1 = red(trackColor); float G1 = green(trackColor); float B1 = blue(trackColor); // noStroke(); //make a new color with alpha value color c = color(R,G,B,100); //our drawing code, we are using translate b/c we will rotate push(); int x = i*cellsize + cellsize/2; x = (800-x); int y = j*cellsize + cellsize/2; fill(255); // translate(x,y); //each rectangle colored white with a size determined by redness // float sz = ((red(c)/255.0f)*cellsize)-1; float diff = sqrt(sq(R - R1) + sq(G - G1) + sq(B - B1)); // println(sz); if (diff >= 36){ sz = 0 ; } else { sz = 20; vertex(x, y); } rect(x, y, sz, sz); pop(); } } endShape(); }