-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasicCam.js
49 lines (39 loc) · 1.03 KB
/
basicCam.js
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
let capture;
let button;
let button1;
let on = false;
let c;
function setup() {
c = createCanvas(300, 200); // putting createCanvas inside a variable will enable us to save the canvas as an image in takePic()
c.parent('p5pos');
capture = createCapture(VIDEO);
capture.elt.setAttribute('playsinline', ''); // add this for iphone compatibility
capture.hide();
// button = createButton('Start / Stop');
// button.parent('p5pos');
// button.mousePressed(startStop);
button1 = createButton('Save Pic');
button1.parent('p5pos');
button1.mousePressed(takePic);
}
function draw() {
background(255);
if(capture){
image(capture, 0, 0, width, height);
}
filter(INVERT);
}
function takePic() {
saveCanvas(c, 'myCanvas', 'jpg');
}
// function startStop(){
// on = !on;
// console.log(on);
// if (on == true){
// capture = createCapture(VIDEO);
// capture.elt.setAttribute('playsinline', ''); // add this for iphone compatibility
// capture.hide();
// } else {
// capture.remove();
// }
// }