Monday, February 3, 2025

Save this to a text doc then save it to .html then open it up and type something

 <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Text to Abstract Art</title>
    <style>
        body {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            background: #111;
            color: white;
            font-family: sans-serif;
        }
        #canvas {
            width: 80vw;
            height: 50vh;
            background: black;
            overflow: hidden;
            position: relative;
        }
        .shape {
            position: absolute;
            border-radius: 50%;
            opacity: 0.8;
            transition: transform 1s ease-in-out, opacity 1s ease-in-out;
        }
        input {
            margin-top: 20px;
            padding: 10px;
            font-size: 18px;
            width: 60%;
            text-align: center;
        }
    </style>
</head>
<body>

    <div id="canvas"></div>
    <input type="text" id="textInput" placeholder="Type something, anything, please!">

    <script>
        const canvas = document.getElementById("canvas");
        const input = document.getElementById("textInput");

        function generateArt(text) {
            canvas.innerHTML = "";
            let uniqueChars = new Set(text).size;
            let textLength = text.length;

            for (let i = 0; i < Math.min(textLength, 50); i++) {
                let shape = document.createElement("div");
                shape.classList.add("shape");

                // Randomized shape properties based on text input? v I dunno a million
                let size = (textLength % 50) + (Math.random() * 50);
                let x = Math.random() * (canvas.clientWidth - size);
                let y = Math.random() * (canvas.clientHeight - size);
                let color = `hsl(${(uniqueChars * 36 + i * 10) % 360}, 80%, 60%)`;

                shape.style.width = shape.style.height = `${size}px`;
                shape.style.left = `${x}px`;
                shape.style.top = `${y}px`;
                shape.style.background = color;

                // Random animation effect lets gooo just cirlces so far
                shape.style.transform = `scale(${1 + Math.random()}) rotate(${Math.random() * 360}deg)`;
                
                canvas.appendChild(shape);
            }
        }

        input.addEventListener("input", () => generateArt(input.value));
    </script>

</body>
</html>

No comments:

Post a Comment

Current obsession

 Singularly combining photography, traditional cyanotype printing processes, 3d printing, and digital maniuplation - to create singlular obj...