xxxxxxxxxx
108
let sceneNum = 0;
let button;
let capture;
function setup() {
createCanvas(400, 400);
//button
button = createButton("BE BOLD!");
button.size(300,300);
button.position(40,20);
button.style("font-family", "Bodoni");
button.style("font-size", "48px");
button.hide();
consent = createButton ("Let's go!");
consent.size (100,100);
consent.position (10,10);
consent.style ("font-family", "Bodoni");
consent.hide ();
deny = createButton ("I do not feel comfortable");
deny.size (100,100);
deny.position (300,300);
deny.style ("font-family", "Bodoni");
deny.hide ();
}
function draw() {
background(220);
if (sceneNum == 0) {
button.show();
} else {
button.hide();
}
if (sceneNum == 1) {
consent.show();
deny.show ();
} else {
consent.hide();
deny.hide ();
}
switch (sceneNum) {
case 0:
background (252, 132, 3);
console.log('scene 0')
break;
case 1:
background (181, 252, 3);
textSize(18);
text('Are you ok with having your face on camera?', 10, 200);
console.log('scene 1')
break;
case 2:
loadCamera ();
image(capture, 0, 0, width, width * capture.height / capture.width);
filter(INVERT);
console.log('scene 2')
break;
}
}
function back() {
sceneNum-=1;
}
function loadCamera (){
if (sceneNum == 2) {
createCanvas(400, 400);
capture = createCapture(VIDEO);
}
}
function mousePressed () {
sceneNum++;
}