xxxxxxxxxx
233
let cap;
let button;
let snapshots = [];
let total = 25;
let counter = 0;
let r = 0;
let g = 0;
let b = 0;
let h, m;
let mon, date, yr;
let sceneNum = 0;
function preload() {
Font = loadFont("Assets/LibreCaslonText-Bold.ttf");
img = loadImage("Assets/Photobooth (2).gif");
sampleImg = loadImage("Assets/DigitalPhotobooth (2).jpg");
Scene0img = loadImage("Assets/photobooth.png");
}
function setup() {
createCanvas(800, 600);
background(50);
cap = createCapture(VIDEO);
cap.size(400, 300);
cap.hide();
pixelDensity(1);
textFont(Font);
let greenbutton = color(110, 231, 110);
let redbutton = color(232, 84, 84);
let purplebutton = color(180, 0, 180);
let yellowbutton = color(254, 241, 157);
//Snap button
snapButton = createButton("Snap");
snapButton.mousePressed(takesnap);
snapButton.style("background-color", purplebutton);
snapButton.position(50, 50);
snapButton.hide();
//yes button
yesButton = createButton("Yes");
yesButton.position(240, 300);
yesButton.style("background-color", greenbutton);
yesButton.size(70, 50);
yesButton.style("font-size", "16px");
yesButton.mousePressed(changeScene);
yesButton.hide();
//no button
noButton = createButton("No");
noButton.position(70, 300);
noButton.style("background-color", redbutton);
noButton.size(70, 50);
noButton.style("font-size", "16px");
noButton.mousePressed(exitScene);
noButton.hide();
//go button
goButton = createButton("Yes");
goButton.position(360, 350);
goButton.style("background-color", greenbutton);
goButton.style("font-size", "16px");
goButton.mousePressed(changeScene);
goButton.size(70, 50);
goButton.hide();
//home button
homeButton = createButton("Home");
homeButton.style("background-color", yellowbutton);
homeButton.mousePressed(changeScene);
homeButton.position(100, 50);
homeButton.hide();
}
function takesnap() {
saveCanvas(canvas, "DigitalPhotobooth", "jpg");
}
let go = false;
function ready() {
go = true;
}
function draw() {
switch (sceneNum) {
// first page
case 0:
image(Scene0img, 0, 0, 800, 600);
fill(255);
textSize(20);
textFont(Font);
text("Ready to Enter the Digital PhotoBooth?", 200, 100);
goButton.show();
break;
// camera consent
case 1:
goButton.hide();
image(Scene0img, 0, 0, 800, 600);
image(sampleImg, 400, 70, 400, 300);
push();
fill(155, 0, 156, 80);
noStroke();
rect(25, 70, 350, 500);
fill(200);
textSize(16);
text("Sample Image", 440, 410, 200);
pop();
push();
textSize(14);
fill(255);
text(
"This camera application wants to access your camera.",
60,
100,
270
);
text(
"By allowing access, the app is allowed to capture and record photos through your front camera. There is a sample image on the left.",
60,
150,
280
);
text("Do you want to allow camera access?", 60, 240, 300);
pop();
yesButton.show();
noButton.show();
push();
fill(255);
textSize(15);
text("READ AND KNOW YOUR RIGHTS", 60, 400, 400);
textSize(12);
text(
"This application will not collect any of your images or metadata after your close the app. Meta data is any data related to you - location, time accessed, device info, etc.",
60,
430,
300
);
text(
"You can revoke your consent any time from the camera page later",
60,
510,
300
);
pop();
break;
//camerapage
case 2:
yesButton.hide();
noButton.hide();
snapButton.show();
homeButton.show();
ready();
if (go) {
snapshots[counter] = cap.get();
counter++;
if (counter == total) {
counter = 0;
}
}
let w = 200;
let h = 160;
let x = 0;
let y = 0;
for (i = 0; i < snapshots.length; i++) {
r = random(0, 255);
g = random(0, 255);
b = random(0, 255);
tint(20 + i * 20, 20 + i * 10, 20 + i * 20);
let index = (i + frameCount) % snapshots.length;
image(snapshots[index], x, y, w, h);
x = x + w;
if (x > width) {
x = 0;
y = y + h;
}
}
datePhoto();
break;
//see you soon page
case 3:
snapButton.hide();
homeButton.hide();
yesButton.hide();
image(Scene0img, 0, 0, 800, 600);
push();
fill(155, 0, 156, 80);
noStroke();
rect(25, 70, 350, 300);
pop();
push();
fill(255);
textSize(16);
text("We respect your right and privacy!", 60, 100, 300);
text("Hope you had fun! See you next time..", 60, 180, 300);
text("Press button below to return", 60, 260, 300);
pop();
noButton.show();
break;
}
}
function changeScene() {
sceneNum = sceneNum + 1;
if (sceneNum > 3) {
sceneNum = 2;
}
}
function exitScene() {
noButton.hide();
yesButton.hide();
sceneNum = 0;
homeButton.hide();
}
function datePhoto() {
h = hour();
m = minute();
mon = month();
date = day();
yr = year();
push();
textFont(Font);
fill(0);
textSize(16);
text(
"Created: " + mon + "/" + date + "/" + yr + " at " + h + ":" + m,
500,
500
);
pop();
}