import processing.video.*; Capture cam; color selected = color(0,255,0); // selected color void setup() { size(640,480); smooth(); cam = new Capture(this,640,480); cam.start(); } void draw() { if (cam.available()) { cam.read(); cam.loadPixels(); // pick a different selected color, if you want if(mousePressed) selected = cam.pixels[mouseX+mouseY*cam.width]; // search for the pixel closer to the selected color int sx = 0, sy = 0; // selected position float minDist = 1000; // put a huge number so we do not have to care for(int y = 0; y < cam.height; y ++) { for(int x = 0; x < cam.width; x ++) { color c = cam.pixels[x+y*cam.width]; float d = dist(red(c),green(c),blue(c), red(selected),green(selected),blue(selected)); if(d < minDist) { minDist = d; sx = x; sy = y; } } } // draw the image and the color image(cam,0,0); noFill(); stroke(200,255,200); strokeWeight(5); ellipse(sx,sy,50,50); } } // START NO NOTES // code used to capture screenshots void keyReleased() { if(key == '`' && !online) save("sketch.png"); }