blob: 05b8335447a5c011a99b3b73f7d5b76e7e5d7a01 (
plain) (
blame)
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
102
103
104
105
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pico Cam</title>
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon">
<link rel="icon" href="./favicon.ico" type="image/x-icon">
<meta name="theme-color" content="#EEE1C6">
<meta name="description" content="For those times when you need a Gameboy camera but only have a phone.">
<style>
body {
background-color: beige;
margin: 0;
padding-bottom: 60px; /* Space for footer */
}
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: #f5f5f5;
color: black;
text-align: center;
height: 60px; /* Fixed height */
display: flex;
justify-content: center;
align-items: center;
}
button {
font-size: 16px;
padding: 12px 24px;
border: none;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover, button:focus {
outline: none;
}
.capture-frame.active {
background-color: teal;
color: #FFFFFF;
}
.capture-frame#captureVideo.active {
background-color: #FF0000;
}
.media-container {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
video, canvas {
max-width: 50%;
height: auto; /* Maintain aspect ratio */
flex: 1 1 auto; /* Allows the elements to change size as needed */
}
/* Check if the viewport is taller than it is wide */
@media (orientation: portrait) {
.media-container {
flex-direction: column;
}
video, canvas {
max-width: 100%; /* Use the full width of the container */
width: 100%; /* Make sure they don't exceed the container */
}
}
</style>
</head>
<body>
<div class="footer">
<button id="toggleCamera">Turn Camera On</button>
<button id="captureFrame" class="capture-frame" disabled>Capture Frame</button>
<button id="captureVideo" class="capture-frame" disabled>Capture Video</button>
</div>
<div class="media-container">
<video id="webcam" autoplay playsinline style="display:none;"></video>
<canvas id="ditheredOutput"></canvas>
</div>
<script src="./pico-cam.js"></script>
<script>
// Check if Service Workers are supported
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('./service-worker.js').then(function(registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}, function(err) {
// Registration failed
console.log('ServiceWorker registration failed: ', err);
});
});
}
</script>
</body>
</html>
|