-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathslit_scan.pde
More file actions
40 lines (35 loc) · 977 Bytes
/
slit_scan.pde
File metadata and controls
40 lines (35 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Simple slit-scanning program.
// Works with Processing 4.0.1.
// Golan Levin, 2022
import processing.video.*;
Capture cam;
int dstX = 0;
void setup() {
cam = new Capture(this, 640, 480, 30);
cam.start();
size(640, 960);
}
void draw() {
// Set some parameters for capture and display.
int srcX = (mousePressed) ? mouseX : cam.width/2;
int srcY = 0;
int srcW = 2; // how wide is the stripe?
int srcH = cam.height;
int dstY = cam.height;
int dstW = srcW;
int dstH = srcH;
// Draw the camera feed, and the source stripe indicator
image(cam, 0, 0, cam.width, cam.height);
stroke(255, 80);
strokeWeight(5);
line(srcX, srcY, srcX, srcY+srcH);
// If there's fresh camera data,
// copy the stripe of pixels to the screen,
// and advance the drawing destination.
if (cam.available()) {
cam.read();
cam.loadPixels();
copy(cam, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH);
dstX = (dstX+srcW)%width;
}
}