This repository has been archived by the owner on Aug 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnvironment.pde
101 lines (88 loc) · 2.07 KB
/
Environment.pde
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Environment
* @author Jonathan Simon Prates ([email protected])
*/
import fullscreen.*;
import JMyron.*;
public class Environment
{
private boolean fullscreen = true;
private int screenWidth = 1440;
private int screenHeight = 900;
private int framerate = 30;
private PImage backgroundImage;
private JMyron capture;
private boolean userFocus = false;
private PApplet pApplet = null;
public void setUserFocus(boolean value)
{
this.userFocus = value;
}
public boolean getUserFocus()
{
return this.userFocus;
}
private void setupFullScreen()
{
if (this.fullscreen)
{
FullScreen fs = new FullScreen(this.pApplet);
fs.setResolution(this.screenWidth, this.screenHeight);
fs.enter();
}
}
private void setupCapture()
{
capture = new JMyron();
capture.start(640, 480);
capture.settings();
capture.findGlobs(0);
}
public void update()
{
this.capture.update();
this.capture.imageCopy(backgroundImage.pixels);
this.backgroundImage.updatePixels();
image(this.backgroundImage, 0, 0, this.screenWidth, this.screenHeight);
}
private void setup()
{
noCursor();
size(this.screenWidth, this.screenHeight);
frameRate(this.framerate);
this.backgroundImage = createImage(640, 480, RGB);
this.setupFullScreen();
this.setupCapture();
}
public void stop()
{
this.capture.stop();
this.capture = null;
this.backgroundImage = null;
}
private void init()
{
this.setup();
this.update();
}
public Environment(PApplet app)
{
this.pApplet = app;
this.init();
}
public Environment(PApplet app, boolean useFullscreen)
{
this.pApplet = app;
this.fullscreen = useFullscreen;
this.init();
}
public Environment(PApplet app, int width, int height, int frameRate, boolean useFullscreen)
{
this.pApplet = app;
this.screenWidth = width;
this.screenHeight = height;
this.framerate = frameRate;
this.fullscreen = useFullscreen;
this.init();
}
}