-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessing_fadecandy_video.pde
More file actions
83 lines (69 loc) · 2.1 KB
/
Processing_fadecandy_video.pde
File metadata and controls
83 lines (69 loc) · 2.1 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import processing.video.*;
Movie movie;
OPC opc;
final String fcServerHost = "127.0.0.1";
final int fcServerPort = 7890;
String filename = "flag_400_300.mp4";
// String filename = "launch1.mp4";
// String filename = "skate01.mp4";
int exitTimer = 0;
// We can use this to mess with the aspect ratio of the video as the grid is currently 1:1
int verticalBorder = 100; // Bars at the sides of the display
int horizontalBorder = 0; // Bars at the top and bottom of display
final int boxesAcross = 2;
final int boxesDown = 2;
final int ledsAcross = 8;
final int ledsDown = 8;
// initialized in setup()
float spacing;
int x0;
int y0;
void setup()
{
apply_cmdline_args();
size(720, 405);
movie = new Movie(this, filename);
movie.loop();
opc = new OPC(this, fcServerHost, fcServerPort); // Connect to an instance of fcserver
spacing = (float)min(height / (boxesDown * ledsDown + 1), width / (boxesAcross * ledsAcross + 1));
x0 = (int)(width - spacing * (boxesAcross * ledsAcross - 1)) / 2;
y0 = (int)(height - spacing * (boxesDown * ledsDown - 1)) / 2;
final int boxCentre = (int)((ledsAcross - 1) / 2.0 * spacing); // probably using the centre in the ledGrid8x8 method
int ledCount = 0;
for (int y = 0; y < boxesDown; y++) {
for (int x = 0; x < boxesAcross; x++) {
opc.ledGrid8x8(ledCount, x0 + spacing * x * ledsAcross + boxCentre, y0 + spacing * y * ledsDown + boxCentre, spacing, 0, false, false);
ledCount += ledsAcross * ledsDown;
}
}
}
void draw()
{
image(movie, verticalBorder, horizontalBorder, width-(2*verticalBorder), height-(2*horizontalBorder));
if (exitTimer > 0 && millis() / 1000 > exitTimer) {
exit();
}
}
void movieEvent(Movie m)
{
m.read();
}
void apply_cmdline_args()
{
if (args == null) {
return;
}
for (String exp: args) {
String[] comp = exp.split("=");
switch (comp[0]) {
case "file":
filename = comp[1];
println("use filename " + filename);
break;
case "exit":
exitTimer = parseInt(comp[1], 10);
println("exit after " + exitTimer + "s");
break;
}
}
}