Spaces:
Running
Running
Download index.html from moshmage/anycoder-d0215471: direct link, hf CLI and curl.
- Browser
- Download file 20.9 kB
-
https://huggingface.co/spaces/moshmage/anycoder-d0215471/resolve/main/index.html
- Command line
-
hf download hf://spaces/moshmage/anycoder-d0215471/index.html
-
curl -L -o index.html https://huggingface.co/spaces/moshmage/anycoder-d0215471/resolve/main/index.html
20.9 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Lumina Flow - Visualizer</title> | |
| <!-- Remix Icon Library for modern UI icons --> | |
| <link href="https://cdn.jsdelivr.net/npm/remixicon@3.5.0/fonts/remixicon.css" rel="stylesheet"> | |
| <style> | |
| :root { | |
| --bg-color: #050505; | |
| --panel-bg: rgba(20, 20, 20, 0.6); | |
| --panel-border: rgba(255, 255, 255, 0.1); | |
| --accent: #00f2ff; | |
| --text-main: #ffffff; | |
| --text-muted: #888888; | |
| --font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; | |
| --transition-speed: 0.3s; | |
| } | |
| * { | |
| box-sizing: border-box; | |
| margin: 0; | |
| padding: 0; | |
| user-select: none; /* Prevent selection for UI feel */ | |
| } | |
| body { | |
| background-color: var(--bg-color); | |
| color: var(--text-main); | |
| font-family: var(--font-family); | |
| overflow: hidden; /* Hide scrollbars */ | |
| height: 100vh; | |
| width: 100vw; | |
| } | |
| /* --- Canvas Layer --- */ | |
| #flowCanvas { | |
| position: fixed; | |
| top: 0; | |
| left: 0; | |
| width: 100%; | |
| height: 100%; | |
| z-index: 1; | |
| /* Enhance contrast for the 'video' feel */ | |
| filter: contrast(1.2) brightness(1.1); | |
| } | |
| /* --- UI Overlay --- */ | |
| .ui-layer { | |
| position: fixed; | |
| z-index: 10; | |
| pointer-events: none; /* Let clicks pass through to canvas where possible */ | |
| width: 100%; | |
| height: 100%; | |
| display: flex; | |
| flex-direction: column; | |
| justify-content: space-between; | |
| padding: 2rem; | |
| } | |
| /* Header */ | |
| header { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| pointer-events: auto; | |
| animation: fadeInDown 1s ease-out; | |
| } | |
| .brand { | |
| display: flex; | |
| align-items: center; | |
| gap: 10px; | |
| } | |
| .brand h1 { | |
| font-size: 1.5rem; | |
| font-weight: 700; | |
| letter-spacing: 1px; | |
| text-transform: uppercase; | |
| background: linear-gradient(90deg, #fff, var(--text-muted)); | |
| -webkit-background-clip: text; | |
| -webkit-text-fill-color: transparent; | |
| } | |
| .anycoder-link { | |
| font-size: 0.8rem; | |
| color: var(--text-muted); | |
| text-decoration: none; | |
| opacity: 0.7; | |
| transition: opacity var(--transition-speed); | |
| display: flex; | |
| align-items: center; | |
| gap: 5px; | |
| } | |
| .anycoder-link:hover { | |
| opacity: 1; | |
| color: var(--accent); | |
| } | |
| /* Controls Panel */ | |
| .controls-container { | |
| pointer-events: auto; | |
| background: var(--panel-bg); | |
| backdrop-filter: blur(12px); | |
| -webkit-backdrop-filter: blur(12px); | |
| border: 1px solid var(--panel-border); | |
| border-radius: 16px; | |
| padding: 1.5rem; | |
| width: 100%; | |
| max-width: 400px; | |
| box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); | |
| align-self: flex-end; /* Bottom right on desktop */ | |
| margin-bottom: 1rem; | |
| animation: fadeInUp 1s ease-out; | |
| } | |
| .control-group { | |
| margin-bottom: 1.2rem; | |
| } | |
| .control-group:last-child { | |
| margin-bottom: 0; | |
| } | |
| .label-row { | |
| display: flex; | |
| justify-content: space-between; | |
| margin-bottom: 0.5rem; | |
| font-size: 0.85rem; | |
| color: var(--text-muted); | |
| font-weight: 500; | |
| } | |
| .value-display { | |
| color: var(--accent); | |
| font-family: monospace; | |
| } | |
| /* Sliders */ | |
| input[type="range"] { | |
| -webkit-appearance: none; | |
| width: 100%; | |
| height: 6px; | |
| background: rgba(255, 255, 255, 0.1); | |
| border-radius: 3px; | |
| outline: none; | |
| cursor: pointer; | |
| } | |
| input[type="range"]::-webkit-slider-thumb { | |
| -webkit-appearance: none; | |
| width: 18px; | |
| height: 18px; | |
| background: var(--accent); | |
| border-radius: 50%; | |
| box-shadow: 0 0 10px var(--accent); | |
| transition: transform 0.2s; | |
| } | |
| input[type="range"]::-webkit-slider-thumb:hover { | |
| transform: scale(1.2); | |
| } | |
| /* Color Palette Selector */ | |
| .palette-selector { | |
| display: flex; | |
| gap: 10px; | |
| } | |
| .palette-btn { | |
| width: 30px; | |
| height: 30px; | |
| border-radius: 50%; | |
| border: 2px solid rgba(255, 255, 255, 0.2); | |
| cursor: pointer; | |
| transition: transform 0.2s, border-color 0.2s; | |
| } | |
| .palette-btn.active { | |
| transform: scale(1.15); | |
| border-color: #fff; | |
| box-shadow: 0 0 10px rgba(255, 255, 255, 0.5); | |
| } | |
| /* Action Buttons */ | |
| .action-buttons { | |
| display: flex; | |
| gap: 10px; | |
| margin-top: 1rem; | |
| } | |
| .btn { | |
| flex: 1; | |
| padding: 10px; | |
| border: none; | |
| border-radius: 8px; | |
| background: rgba(255, 255, 255, 0.1); | |
| color: #fff; | |
| font-weight: 600; | |
| cursor: pointer; | |
| transition: all 0.2s; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| gap: 8px; | |
| } | |
| .btn:hover { | |
| background: rgba(255, 255, 255, 0.2); | |
| } | |
| .btn-primary { | |
| background: var(--accent); | |
| color: #000; | |
| } | |
| .btn-primary:hover { | |
| background: #4df2ff; | |
| box-shadow: 0 0 15px rgba(0, 242, 255, 0.4); | |
| } | |
| /* Responsive */ | |
| @media (max-width: 768px) { | |
| .ui-layer { | |
| padding: 1rem; | |
| } | |
| .controls-container { | |
| max-width: 100%; | |
| margin-bottom: 0; | |
| } | |
| header { | |
| padding: 0; | |
| } | |
| } | |
| /* Animations */ | |
| @keyframes fadeInDown { | |
| from { opacity: 0; transform: translateY(-20px); } | |
| to { opacity: 1; transform: translateY(0); } | |
| } | |
| @keyframes fadeInUp { | |
| from { opacity: 0; transform: translateY(20px); } | |
| to { opacity: 1; transform: translateY(0); } | |
| } | |
| /* Loading Overlay */ | |
| #loader { | |
| position: fixed; | |
| top: 0; left: 0; width: 100%; height: 100%; | |
| background: #000; | |
| z-index: 100; | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| transition: opacity 0.5s; | |
| } | |
| .spinner { | |
| width: 40px; | |
| height: 40px; | |
| border: 4px solid rgba(255,255,255,0.1); | |
| border-left-color: var(--accent); | |
| border-radius: 50%; | |
| animation: spin 1s linear infinite; | |
| } | |
| @keyframes spin { 100% { transform: rotate(360deg); } } | |
| </style> | |
| </head> | |
| <body> | |
| <!-- Loading Screen --> | |
| <div id="loader"> | |
| <div class="spinner"></div> | |
| </div> | |
| <!-- Canvas --> | |
| <canvas id="flowCanvas"></canvas> | |
| <!-- UI Overlay --> | |
| <div class="ui-layer"> | |
| <header> | |
| <div class="brand"> | |
| <i class="ri-flashlight-fill" style="color: var(--accent); font-size: 1.5rem;"></i> | |
| <h1>Lumina Flow</h1> | |
| </div> | |
| <!-- Requirement: "Built with anycoder" --> | |
| <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link"> | |
| Built with anycoder <i class="ri-arrow-right-up-line"></i> | |
| </a> | |
| </header> | |
| <aside class="controls-container"> | |
| <!-- Particle Count --> | |
| <div class="control-group"> | |
| <div class="label-row"> | |
| <span>Swarm Density</span> | |
| <span class="value-display" id="countVal">2000</span> | |
| </div> | |
| <input type="range" id="particleCount" min="500" max="5000" step="100" value="2000"> | |
| </div> | |
| <!-- Speed --> | |
| <div class="control-group"> | |
| <div class="label-row"> | |
| <span>Flow Velocity</span> | |
| <span class="value-display" id="speedVal">1.5</span> | |
| </div> | |
| <input type="range" id="speed" min="0.1" max="5.0" step="0.1" value="1.5"> | |
| </div> | |
| <!-- Trail Length --> | |
| <div class="control-group"> | |
| <div class="label-row"> | |
| <span>Trace Persistence</span> | |
| <span class="value-display" id="trailVal">Long</span> | |
| </div> | |
| <input type="range" id="trail" min="0.02" max="0.3" step="0.01" value="0.08"> | |
| </div> | |
| <!-- Color Palette --> | |
| <div class="control-group"> | |
| <div class="label-row"> | |
| <span>Spectrum Theme</span> | |
| </div> | |
| <div class="palette-selector" id="paletteContainer"> | |
| <!-- Buttons injected via JS --> | |
| </div> | |
| </div> | |
| <!-- Actions --> | |
| <div class="action-buttons"> | |
| <button class="btn" id="pauseBtn"> | |
| <i class="ri-pause-circle-line"></i> Pause | |
| </button> | |
| <button class="btn btn-primary" id="snapshotBtn"> | |
| <i class="ri-camera-lens-line"></i> Capture | |
| </button> | |
| </div> | |
| </aside> | |
| </div> | |
| <script> | |
| /** | |
| * LUMINA FLOW SIMULATION | |
| * A high-performance canvas particle system using a flow field algorithm. | |
| */ | |
| const canvas = document.getElementById('flowCanvas'); | |
| const ctx = canvas.getContext('2d', { alpha: false }); // Optimize for no transparency on base | |
| // UI Elements | |
| const loader = document.getElementById('loader'); | |
| const particleCountInput = document.getElementById('particleCount'); | |
| const speedInput = document.getElementById('speed'); | |
| const trailInput = document.getElementById('trail'); | |
| const countVal = document.getElementById('countVal'); | |
| const speedVal = document.getElementById('speedVal'); | |
| const trailVal = document.getElementById('trailVal'); | |
| const pauseBtn = document.getElementById('pauseBtn'); | |
| const snapshotBtn = document.getElementById('snapshotBtn'); | |
| const paletteContainer = document.getElementById('paletteContainer'); | |
| // State | |
| let width, height; | |
| let particles = []; | |
| let animationId; | |
| let isPaused = false; | |
| let frame = 0; | |
| // Configuration | |
| const config = { | |
| particleCount: parseInt(particleCountInput.value), | |
| speed: parseFloat(speedInput.value), | |
| trailFade: parseFloat(trailInput.value), // Lower = longer trails | |
| baseRadius: 1.5, | |
| gridSize: 20, // Size of flow field vectors | |
| zoom: 0.005, | |
| timeSpeed: 0.001 | |
| }; | |
| // Color Palettes | |
| const palettes = [ | |
| { name: 'Neon', colors: ['#00f2ff', '#00ff9d', '#ffffff', '#0033ff'] }, | |
| { name: 'Sunset', colors: ['#ff0055', '#ff9900', '#ffcc00', '#ff00aa'] }, | |
| { name: 'Matrix', colors: ['#003300', '#00ff00', '#ccffcc', '#005500'] }, | |
| { name: 'Aurora', colors: ['#e0f7fa', '#80deea', '#26c6da', '#00bcd4'] }, | |
| { name: 'Inferno', colors: ['#2d0000', '#550000', '#ff0000', '#ffcc00'] } | |
| ]; | |
| let currentPalette = palettes[0]; | |
| // --- Particle Class --- | |
| class Particle { | |
| constructor() { | |
| this.reset(true); | |
| } | |
| reset(randomizePos = false) { | |
| this.x = randomizePos ? Math.random() * width : Math.random() * width; | |
| this.y = randomizePos ? Math.random() * height : Math.random() * height; | |
| this.vx = 0; | |
| this.vy = 0; | |
| this.life = Math.random() * 100 + 50; | |
| this.color = this.pickColor(); | |
| } | |
| pickColor() { | |
| return currentPalette.colors[Math.floor(Math.random() * currentPalette.colors.length)]; | |
| } | |
| update() { | |
| // Calculate grid position | |
| const x = this.x * config.zoom; | |
| const y = this.y * config.zoom; | |
| const z = frame * config.timeSpeed; | |
| // Simplex-like noise calculation using trigonometry (lightweight alternative to Perlin) | |
| // Layered waves create smooth, organic flow | |
| const angle = (Math.cos(x) + Math.sin(y) + Math.sin(z)) * Math.PI * 2; | |
| // Physics | |
| this.vx += Math.cos(angle) * 0.1; | |
| this.vy += Math.sin(angle) * 0.1; | |
| // Speed limit | |
| const speed = Math.sqrt(this.vx * this.vx + this.vy * this.vy); | |
| if (speed > config.speed) { | |
| this.vx = (this.vx / speed) * config.speed; | |
| this.vy = (this.vy / speed) * config.speed; | |
| } | |
| this.x += this.vx; | |
| this.y += this.vy; | |
| // Mouse Interaction (Repulsion) | |
| // Simple distance check against center (simulating a focus point or mouse) | |
| const dx = this.x - (width / 2); | |
| const dy = this.y - (height / 2); | |
| const dist = Math.sqrt(dx * dx + dy * dy); | |
| const forceRadius = 200; | |
| if (dist < forceRadius) { | |
| const force = (forceRadius - dist) / forceRadius; | |
| this.vx += (dx / dist) * force * 2; | |
| this.vy += (dy / dist) * force * 2; | |
| } | |
| // Wrap around screen | |
| if (this.x > width) this.x = 0; | |
| if (this.x < 0) this.x = width; | |
| if (this.y > height) this.y = 0; | |
| if (this.y < 0) this.y = height; | |
| // Occasional color shift for dynamic feel | |
| if (Math.random() < 0.005) { | |
| this.color = this.pickColor(); | |
| } | |
| } | |
| draw() { | |
| // Draw a small line segment for the "tail" effect | |
| // This is faster and looks better than just a dot with heavy blur | |
| const tailLength = Math.min(Math.sqrt(this.vx**2 + this.vy**2) * 3, 15); | |
| ctx.strokeStyle = this.color; | |
| ctx.lineWidth = config.baseRadius; | |
| ctx.lineCap = 'round'; | |
| // Use lighter composite for neon glow effect | |
| ctx.globalCompositeOperation = 'lighter'; | |
| ctx.beginPath(); | |
| ctx.moveTo(this.x, this.y); | |
| ctx.lineTo(this.x - this.vx * 3, this.y - this.vy * 3); | |
| ctx.stroke(); | |
| } | |
| } | |
| // --- Initialization & Helpers --- | |
| function init() { | |
| resize(); | |
| createParticles(); | |
| setupUI(); | |
| // Hide loader | |
| setTimeout(() => { | |
| loader.style.opacity = '0'; | |
| setTimeout(() => loader.style.display = 'none', 500); | |
| }, 500); | |
| animate(); | |
| } | |
| function resize() { | |
| width = window.innerWidth; | |
| height = window.innerHeight; | |
| canvas.width = width; | |
| canvas.height = height; | |
| } | |
| function createParticles() { | |
| particles = []; | |
| for (let i = 0; i < config.particleCount; i++) { | |
| particles.push(new Particle()); | |
| } | |
| } | |
| // --- Core Animation Loop --- | |
| function animate() { | |
| if (!isPaused) { | |
| // 1. Create the "Blurry Trace" effect | |
| // Instead of clearRect, we draw a semi-transparent rectangle | |
| // This makes previous frames slowly fade out | |
| ctx.globalCompositeOperation = 'source-over'; | |
| ctx.fillStyle = `rgba(5, 5, 5, ${config.trailFade})`; | |
| ctx.fillRect(0, 0, width, height); | |
| // 2. Update and Draw Particles | |
| for (let i = 0; i < particles.length; i++) { | |
| particles[i].update(); | |
| particles[i].draw(); | |
| } | |
| frame++; | |
| } | |
| animationId = requestAnimationFrame(animate); | |
| } | |
| // --- UI Logic --- | |
| function setupUI() { | |
| // Generate Palette Buttons | |
| palettes.forEach((p, index) => { | |
| const btn = document.createElement('div'); | |
| btn.className = `palette-btn ${index === 0 ? 'active' : ''}`; | |
| btn.style.background = `linear-gradient(135deg, ${p.colors[0]}, ${p.colors[1]})`; | |
| btn.title = p.name; | |
| btn.onclick = () => { | |
| document.querySelectorAll('.palette-btn').forEach(b => b.classList.remove('active')); | |
| btn.classList.add('active'); | |
| currentPalette = p; | |
| // Refresh particle colors immediately | |
| particles.forEach(p => p.color = p.pickColor()); | |
| }; | |
| paletteContainer.appendChild(btn); | |
| }); | |
| // Sliders | |
| particleCountInput.addEventListener('input', (e) => { | |
| const newVal = parseInt(e.target.value); | |
| countVal.innerText = newVal; | |
| // Adjust array size dynamically | |
| if (newVal > particles.length) { | |
| for (let i = particles.length; i < newVal; i++) { | |
| particles.push(new Particle()); | |
| } | |
| } else { | |
| particles.splice(newVal); | |
| } | |
| config.particleCount = newVal; | |
| }); | |
| speedInput.addEventListener('input', (e) => { | |
| config.speed = parseFloat(e.target.value); | |
| speedVal.innerText = config.speed.toFixed(1); | |
| }); | |
| trailInput.addEventListener('input', (e) => { | |
| // Invert logic for UI display: Lower value = Longer trace | |
| // Input is opacity (0.02 to 0.3) | |
| // Let's make the slider feel intuitive: Left (Low opacity) = Long Trace | |
| config.trailFade = parseFloat(e.target.value); | |
| let label = "Normal"; | |
| if (config.trailFade < 0.04) label = "Infinite"; | |
| else if (config.trailFade < 0.1) label = "Long"; | |
| else if (config.trailFade > 0.2) label = "Short"; | |
| trailVal.innerText = label; | |
| }); | |
| // Buttons | |
| pauseBtn.addEventListener('click', () => { | |
| isPaused = !isPaused; | |
| pauseBtn.innerHTML = isPaused | |
| ? '<i class="ri-play-circle-line"></i> Resume' | |
| : '<i class="ri-pause-circle-line"></i> Pause'; | |
| }); | |
| snapshotBtn.addEventListener('click', () => { | |
| // Pause momentarily to ensure clean capture | |
| const wasPaused = isPaused; | |
| isPaused = true; | |
| pauseBtn.innerHTML = '<i class="ri-camera-lens-line"></i> Capturing...'; | |
| setTimeout(() => { | |
| const link = document.createElement('a'); | |
| link.download = `lumina-flow-${Date.now()}.png`; | |
| link.href = canvas.toDataURL(); | |
| link.click(); | |
| // Restore state | |
| isPaused = wasPaused; | |
| pauseBtn.innerHTML = wasPaused | |
| ? '<i class="ri-play-circle-line"></i> Resume' | |
| : '<i class="ri-pause-circle-line"></i> Pause'; | |
| }, 100); | |
| }); | |
| // Window | |
| window.addEventListener('resize', resize); | |
| } | |
| // Start | |
| init(); | |
| </script> | |
| </body> | |
| </html> |