about summary refs log blame commit diff stats
path: root/js/pico-cam/index.html
blob: 05b8335447a5c011a99b3b73f7d5b76e7e5d7a01 (plain) (tree)
1
2
3
4
5
6
7
8
9
10




                                                                          
                           

                                                                       

                                                                                                             


































                                                        
                           

         



                                            







                                    
                            
                                                     
                                                                              








                                                             

                                                                            


             

       


                                                                                       
                                                                                       




                                                                              
                                         



                                                        
                                                                                                     








                                                                                                          
       
      
<!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>