// Dartmouth CS 2, Winter 2009, Chris Bailey-Kellogg // Notes 21 | Sketch 3 // Inspired by Processing exhibition Shadow Monsters import JMyron.*; JMyron video; // Video capture // maximum spacing between hairs; maximum length of hairs float hairStep=2, hairLength=30; void setup() { size(640,480); video = new JMyron(); video.start(width,height); video.minDensity(1000); // decent-sized globs video.trackColor(0,0,0,200); // fairly dark globs stroke(221,30,232); // magenta hair smooth(); } void draw() { video.update(); // Show the camera image loadPixels(); video.imageCopy(pixels); updatePixels(); // Follow outlines int[][][] edgePointSets = video.globEdgePoints(30); // an array (over globs) of arrays (over edge points) of 2 elements (0=x, 1=y) for (int eps=0; eps0) { // Take equal-sized steps from x1 to x2 float dx=(x2-x1)/l, dy=(y2-y1)/l; float x=x1, y=y1; boolean done=false; while (!done) { // Choose random step and length up to maximum values float hs=random(0.1,hairStep), hl=random(1,hairLength); // Draw line perpendicular to (x1,y1)-(x2,y2) direction line(x,y,x+hl*dy,y-hl*dx); // Take a step x+=hs*dx; y+=hs*dy; // Test depends on whether moving left or right if (x1=x2; else done = x<=x2; } } }