43
edits
No edit summary |
|||
Line 205: | Line 205: | ||
} | } | ||
} | } | ||
</source> | |||
== Homework 5 == | |||
<source lang = "java"> | |||
import processing.video.*; | |||
Capture cam; | |||
PImage[] buffer; | |||
int frames = 60; | |||
int write = 0; | |||
int read =1; | |||
void setup(){ | |||
size(640, 360); | |||
cam = new Capture(this, width, height); | |||
cam.start(); | |||
buffer = new PImage[frames]; | |||
} | |||
void draw() { | |||
if(cam.available()) { | |||
cam.read(); | |||
buffer[write] = cam.get(); | |||
if(buffer[read] != null){ | |||
image(buffer[read], 0, 0); | |||
} | |||
write++; | |||
read++; | |||
if(read >= random(frames)){ | |||
read = 0; | |||
} | |||
if(write >= random(frames)){ | |||
write = 0; | |||
} | |||
} | |||
} | |||
</source> | </source> |
edits