Advertisement
Guest User

Processing frame blending code for light painting

a guest
Apr 26th, 2016
79
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Really simple blending of webcam frames for light painting/POV leds etc.
  2. //For processing 3.0 +, may require edits for older versions.
  3. //Should show 'trails' from light sources for several frames
  4. //And pictures from light painting gear or POV leds
  5. //By devicer.net
  6. //do whatever you like with this code, it's only a basic start :)
  7.  
  8. import processing.video.*;
  9.  
  10. Capture video;
  11. int fadeValue = 5; //lower = longer tail, 0 to disable...
  12.  
  13. void setup() {
  14.   size(640, 480);
  15.   // Uses the default video input, see the reference if this causes an error
  16.   video = new Capture(this, width, height);
  17.   video.start();  
  18.   noStroke();
  19.   smooth();
  20.   blendMode(LIGHTEST);
  21.   background(0);
  22. }
  23.  
  24. void draw() {
  25.   if (video.available()) {
  26.     video.read();
  27.       blendMode(LIGHTEST);//can also use ADD for additive and possibly SCREEN too, see blendMode() reference.
  28.     image(video, 0, 0, width, height); // Draw webcam frame (with lightest blending)
  29.     blendMode(BLEND);  //crude but it works...!
  30.     fill(0,fadeValue);
  31.     rect(0, 0, width, height);
  32.   }
  33. }
Advertisement
RAW Paste Data Copied
Advertisement