Untitled

 avatar
unknown
plain_text
2 years ago
4.0 kB
2
Indexable
<!DOCTYPE html>
<html>
<head>
    <style>
        .container {
            position: relative;
            height: 400px;
            overflow: hidden;
        }

        .line {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 2;
        }

        .wave {
            animation: waveAnimation 4s linear infinite;
        }

        @keyframes waveAnimation {
            0% {
                d: path("M0 200 Q 100 100 200 200 Q 300 300 400 200 Q 500 100 600 200 Q 700 300 800 200 Q 900 100 1000 200");
            }
            50% {
                d: path("M0 100 Q 100 200 200 100 Q 300 0 400 100 Q 500 200 600 100 Q 700 0 800 100 Q 900 200 1000 100");
            }
            100% {
                d: path("M0 200 Q 100 100 200 200 Q 300 300 400 200 Q 500 100 600 200 Q 700 300 800 200 Q 900 100 1000 200");
            }
        }

        .box-container {
            position: relative;
            margin-top: 60px;
        }

        .box {
            width: 50px;
            height: 50px;
            margin: 5px;
            display: inline-block;
            background-color: blue;
            position: relative;
        }

        .line {
            position: absolute;
            width: 100%;
            height: 2px;
            background-color: black;
            bottom: -6px;
            left: 0;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="box-container" id="container"></div>
        <svg class="line" viewBox="0 0 1000 200">
            <path class="wave" d="M0 200 Q 100 100 200 200 Q 300 300 400 200 Q 500 100 600 200 Q 700 300 800 200 Q 900 100 1000 200"></path>
        </svg>
    </div>

    <script>
        // Create the grid
        var container = document.getElementById('container');
        for (var i = 0; i < 5; i++) {
            for (var j = 0; j < 10; j++) {
                var box = document.createElement('div');
                box.className = 'box';
                var line = document.createElement('div');
                line.className = 'line';
                box.appendChild(line);
                container.appendChild(box);
            }
            container.appendChild(document.createElement('br'));
        }

        // Function to generate a random color
        function getRandomColor() {
            var letters = '0123456789ABCDEF';
            var color = '#';
            for (var i = 0; i < 6; i++) {
                color += letters[Math.floor(Math.random() * 16)];
            }
            return color;
        }

        // Function to update box colors
        function updateColors() {
            var boxes = document.getElementsByClassName('box');
            for (var i = 0; i < boxes.length; i++) {
                var box = boxes[i];
                box.style.backgroundColor = getRandomColor();
            }
        }

        // Function to update wave path data
        function updateWave() {
            var wave = document.querySelector('.wave');
            var pathData = generateRandomPathData();
            wave.setAttribute('d', pathData);
        }

        // Function to generate random path data for the wave
        function generateRandomPathData() {
            var pathData = 'M0 200';
            var amplitude = 100; // Adjust the wave amplitude
            var frequency = 0.01; // Adjust the wave frequency
            var phase = Math.random() * 1000; // Random phase shift

            for (var x = 0; x <= 1000; x += 20) {
                var y = Math.sin(x * frequency + phase) * amplitude + 200;
                pathData += ' L' + x + ' ' + y;
            }

            return pathData;
        }

        // Interval to update colors every 1 second
        setInterval(updateColors, 1000);

        // Interval to update wave path every 2 seconds
        setInterval(updateWave, 2000);
    </script>
</body>
</html>
Editor is loading...