Advertisement
xeromino

cam

Jan 4th, 2015
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. import processing.video.*;
  2.  
  3. Capture cam;
  4.  
  5. void setup() {
  6.   size(480,480);
  7.   initVideo();
  8. }
  9.  
  10. void draw() {
  11.   PImage img = captureImage();
  12.   for (int i=0; i<2000; i++) {
  13.     float x = random(width);
  14.     float y = random(height);
  15.     color col = img.get(int(x), int(y));
  16.     float sz = random(5, 15);
  17.     colorMode(HSB,360,100,100);
  18.     float h = hue(col);
  19.     float b = brightness(col);
  20.     fill(h,0,b,150);
  21.     noStroke();
  22.     ellipse(width-x, y, sz, sz);
  23.   }
  24.   //saveFrame("image-###.gif");
  25. }
  26.  
  27. void initVideo() {
  28.   cam = new Capture(this, 640, 480, 30);
  29.   cam.start();
  30. }
  31.  
  32. PImage captureImage() {
  33.   if (cam.available()) {
  34.     cam.read();
  35.   }
  36.   return cam;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement