Spaces:
Running
Running
Download index.html from WhyMe1234/anycoder-5cdab494: direct link, hf CLI and curl.
- Browser
- Download file 17.6 kB
-
https://huggingface.co/spaces/WhyMe1234/anycoder-5cdab494/resolve/main/index.html
- Command line
-
hf download hf://spaces/WhyMe1234/anycoder-5cdab494/index.html
-
curl -L -o index.html https://huggingface.co/spaces/WhyMe1234/anycoder-5cdab494/resolve/main/index.html
17.6 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Rotated Grid Visualization</title> | |
| <style> | |
| * { | |
| margin: 0; | |
| padding: 0; | |
| box-sizing: border-box; | |
| } | |
| :root { | |
| --primary-color: #6366f1; | |
| --secondary-color: #8b5cf6; | |
| --background: #0f172a; | |
| --surface: #1e293b; | |
| --text: #e2e8f0; | |
| --text-muted: #94a3b8; | |
| --accent: #f59e0b; | |
| } | |
| body { | |
| font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; | |
| background: linear-gradient(135deg, var(--background) 0%, #1a1f36 100%); | |
| color: var(--text); | |
| min-height: 100vh; | |
| display: flex; | |
| flex-direction: column; | |
| } | |
| .header { | |
| padding: 1.5rem 2rem; | |
| background: rgba(30, 41, 59, 0.8); | |
| backdrop-filter: blur(10px); | |
| border-bottom: 1px solid rgba(148, 163, 184, 0.1); | |
| } | |
| .header-content { | |
| max-width: 1400px; | |
| margin: 0 auto; | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| flex-wrap: wrap; | |
| gap: 1rem; | |
| } | |
| .title { | |
| font-size: 1.5rem; | |
| font-weight: 700; | |
| background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); | |
| -webkit-background-clip: text; | |
| -webkit-text-fill-color: transparent; | |
| background-clip: text; | |
| } | |
| .built-with { | |
| font-size: 0.875rem; | |
| color: var(--text-muted); | |
| text-decoration: none; | |
| transition: color 0.3s ease; | |
| display: inline-flex; | |
| align-items: center; | |
| gap: 0.5rem; | |
| } | |
| .built-with:hover { | |
| color: var(--primary-color); | |
| } | |
| .main-container { | |
| flex: 1; | |
| display: flex; | |
| flex-direction: column; | |
| padding: 2rem; | |
| max-width: 1400px; | |
| margin: 0 auto; | |
| width: 100%; | |
| } | |
| .controls-panel { | |
| background: var(--surface); | |
| border-radius: 1rem; | |
| padding: 1.5rem; | |
| margin-bottom: 2rem; | |
| border: 1px solid rgba(148, 163, 184, 0.1); | |
| backdrop-filter: blur(10px); | |
| } | |
| .controls-grid { | |
| display: grid; | |
| grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); | |
| gap: 1.5rem; | |
| } | |
| .control-group { | |
| display: flex; | |
| flex-direction: column; | |
| gap: 0.75rem; | |
| } | |
| .control-label { | |
| font-size: 0.875rem; | |
| font-weight: 600; | |
| color: var(--text-muted); | |
| display: flex; | |
| align-items: center; | |
| gap: 0.5rem; | |
| } | |
| .control-input { | |
| display: flex; | |
| align-items: center; | |
| gap: 1rem; | |
| } | |
| .slider { | |
| flex: 1; | |
| -webkit-appearance: none; | |
| height: 6px; | |
| border-radius: 3px; | |
| background: rgba(148, 163, 184, 0.2); | |
| outline: none; | |
| transition: background 0.3s; | |
| } | |
| .slider::-webkit-slider-thumb { | |
| -webkit-appearance: none; | |
| appearance: none; | |
| width: 20px; | |
| height: 20px; | |
| border-radius: 50%; | |
| background: var(--primary-color); | |
| cursor: pointer; | |
| transition: transform 0.2s, background 0.3s; | |
| } | |
| .slider::-webkit-slider-thumb:hover { | |
| transform: scale(1.2); | |
| background: var(--secondary-color); | |
| } | |
| .slider-value { | |
| min-width: 3rem; | |
| text-align: center; | |
| font-weight: 600; | |
| color: var(--primary-color); | |
| } | |
| .canvas-container { | |
| background: var(--surface); | |
| border-radius: 1rem; | |
| padding: 1.5rem; | |
| border: 1px solid rgba(148, 163, 184, 0.1); | |
| backdrop-filter: blur(10px); | |
| flex: 1; | |
| display: flex; | |
| flex-direction: column; | |
| } | |
| .canvas-header { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| margin-bottom: 1rem; | |
| } | |
| .canvas-title { | |
| font-size: 1.125rem; | |
| font-weight: 600; | |
| color: var(--text); | |
| } | |
| .canvas-info { | |
| font-size: 0.875rem; | |
| color: var(--text-muted); | |
| } | |
| #gridCanvas { | |
| width: 100%; | |
| height: 500px; | |
| border-radius: 0.5rem; | |
| background: #0f172a; | |
| box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); | |
| } | |
| .code-snippet { | |
| background: rgba(15, 23, 42, 0.5); | |
| border: 1px solid rgba(148, 163, 184, 0.1); | |
| border-radius: 0.5rem; | |
| padding: 1rem; | |
| margin-top: 1.5rem; | |
| font-family: 'Fira Code', 'Courier New', monospace; | |
| font-size: 0.875rem; | |
| line-height: 1.6; | |
| color: #e2e8f0; | |
| overflow-x: auto; | |
| } | |
| .code-keyword { | |
| color: #f59e0b; | |
| } | |
| .code-function { | |
| color: #60a5fa; | |
| } | |
| .code-comment { | |
| color: #64748b; | |
| } | |
| .code-string { | |
| color: #a78bfa; | |
| } | |
| .code-number { | |
| color: #34d399; | |
| } | |
| @media (max-width: 768px) { | |
| .header-content { | |
| flex-direction: column; | |
| text-align: center; | |
| } | |
| .controls-grid { | |
| grid-template-columns: 1fr; | |
| } | |
| .main-container { | |
| padding: 1rem; | |
| } | |
| #gridCanvas { | |
| height: 350px; | |
| } | |
| } | |
| @media (prefers-color-scheme: light) { | |
| :root { | |
| --background: #f8fafc; | |
| --surface: #f1f5f9; | |
| --text: #1e293b; | |
| --text-muted: #64748b; | |
| } | |
| body { | |
| background: linear-gradient(135deg, var(--background) 0%, #e0f2fe 100%); | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <header class="header"> | |
| <div class="header-content"> | |
| <h1 class="title">Rotated Grid Visualization</h1> | |
| <a href="https://huggingface.co/spaces/akhaliq/anycoder" class="built-with" target="_blank" rel="noopener noreferrer"> | |
| Built with anycoder | |
| </a> | |
| </div> | |
| </header> | |
| <main class="main-container"> | |
| <div class="controls-panel"> | |
| <div class="controls-grid"> | |
| <div class="control-group"> | |
| <label class="control-label"> | |
| <span>Rotation Angle</span> | |
| </label> | |
| <div class="control-input"> | |
| <input type="range" id="angleSlider" class="slider" min="0" max="360" value="45"> | |
| <span class="slider-value" id="angleValue">45°</span> | |
| </div> | |
| </div> | |
| <div class="control-group"> | |
| <label class="control-label"> | |
| <span>Line Spacing</span> | |
| </label> | |
| <div class="control-input"> | |
| <input type="range" id="spacingSlider" class="slider" min="10" max="50" value="20"> | |
| <span class="slider-value" id="spacingValue">20px</span> | |
| </div> | |
| </div> | |
| <div class="control-group"> | |
| <label class="control-label"> | |
| <span>Grid Density</span> | |
| </label> | |
| <div class="control-input"> | |
| <input type="range" id="densitySlider" class="slider" min="5" max="20" value="10"> | |
| <span class="slider-value" id="densityValue">10 lines</span> | |
| </div> | |
| </div> | |
| <div class="control-group"> | |
| <label class="control-label"> | |
| <span>Line Color</span> | |
| </label> | |
| <div class="control-input"> | |
| <input type="color" id="colorPicker" value="#6366f1" style="width: 40px; height: 40px; border: none; border-radius: 0.5rem; cursor: pointer;"> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="canvas-container"> | |
| <div class="canvas-header"> | |
| <h2 class="canvas-title">Grid Visualization</h2> | |
| <div class="canvas-info" id="canvasInfo">Angle: 45° | Spacing: 20px</div> | |
| </div> | |
| <canvas id="gridCanvas"></canvas> | |
| </div> | |
| <div class="code-snippet"> | |
| <pre><code><span class="code-comment">// Rotate a point around a center point</span> | |
| <span class="code-keyword">void</span> <span class="code-function">RotatePoint</span>(<span class="code-keyword">double</span> x1, <span class="code-keyword">double</span> y1, <span class="code-keyword">double</span> x2, <span class="code-keyword">double</span> y2, <span class="code-keyword">double</span> angleDegrees, <span class="code-keyword">double</span> &finalX, <span class="code-keyword">double</span> &finalY) { | |
| <span class="code-comment">// Calculate the difference between the points</span> | |
| <span class="code-keyword">double</span> angle = angleDegrees * (M_PI / 180.0); | |
| <span class="code-keyword">double</span> tempX = x1 - x2; | |
| <span class="code-keyword">double</span> tempY = y1 - y2; | |
| <span class="code-comment">// Apply rotation formula</span> | |
| <span class="code-keyword">double</span> rotatedX = (tempX * cos(angle)) - (tempY * sin(angle)); | |
| <span class="code-keyword">double</span> rotatedY = (tempX * sin(angle)) + (tempY * cos(angle)); | |
| <span class="code-comment">// Store the result</span> | |
| finalX = rotatedX; | |
| finalY = rotatedY; | |
| } | |
| <span class="code-comment">// Draw multiple parallel lines with rotation</span> | |
| <span class="code-keyword">void</span> <span class="code-function">drawRotatedGrid1</span>(<span class="code-keyword">double</span> cX) { | |
| <span class="code-comment">// Loop to draw multiple parallel lines</span> | |
| <span class="code-keyword">for</span> (<span class="code-keyword">int</span> off = -max(SCREENWIDTH, SCREENHEIGHT); off < max(SCREENWIDTH, SCREENHEIGHT); off += 10) { | |
| <span class="code-comment">// Define UN-ROTATED endpoints</span> | |
| <span class="code-keyword">double</span> p1_unrotates_x = 0; | |
| <span class="code-keyword">double</span> p1_unrotates_y = cY + off; | |
| <span class="code-keyword">double</span> p2_unrotates_x = SCREENWIDTH; | |
| <span class="code-keyword">double</span> p2_unrotates_y = cY + off; | |
| <span class="code-comment">// Rotate points</span> | |
| RotatePoint(p1_unrotates_x, p1_unrotates_y, cX, cY, 5, p1_rotated_x, p1_rotated_y); | |
| RotatePoint(p2_unrotates_x, p2_unrotates_y, cX, cY, 5, p2_rotated_x, p2_rotated_y); | |
| <span class="code-comment">// Draw the modified line segment</span> | |
| SDL_RenderDrawLine(renderer, p1_rotated_x, p1_rotated_y, p2_rotated_x, p2_rotated_y); | |
| } | |
| }</code></pre> | |
| </div> | |
| </main> | |
| <script> | |
| class RotatedGrid { | |
| constructor(canvasId) { | |
| this.canvas = document.getElementById(canvasId); | |
| this.ctx = this.canvas.getContext('2d'); | |
| this.angle = 45; | |
| this.spacing = 20; | |
| this.density = 10; | |
| this.color = '#6366f1'; | |
| this.centerX = 0; | |
| this.centerY = 0; | |
| this.setupCanvas(); | |
| this.setupEventListeners(); | |
| this.draw(); | |
| } | |
| setupCanvas() { | |
| const resizeCanvas = () => { | |
| const rect = this.canvas.getBoundingClientRect(); | |
| this.canvas.width = rect.width; | |
| this.canvas.height = rect.height; | |
| this.centerX = this.canvas.width / 2; | |
| this.centerY = this.canvas.height / 2; | |
| this.draw(); | |
| }; | |
| resizeCanvas(); | |
| window.addEventListener('resize', resizeCanvas); | |
| } | |
| setupEventListeners() { | |
| const angleSlider = document.getElementById('angleSlider'); | |
| const spacingSlider = document.getElementById('spacingSlider'); | |
| const densitySlider = document.getElementById('densitySlider'); | |
| const colorPicker = document.getElementById('colorPicker'); | |
| angleSlider.addEventListener('input', (e) => { | |
| this.angle = parseInt(e.target.value); | |
| document.getElementById('angleValue').textContent = `${this.angle}°`; | |
| document.getElementById('canvasInfo').textContent = `Angle: ${this.angle}° | Spacing: ${this.spacing}px`; | |
| this.draw(); | |
| }); | |
| spacingSlider.addEventListener('input', (e) => { | |
| this.spacing = parseInt(e.target.value); | |
| document.getElementById('spacingValue').textContent = `${this.spacing}px`; | |
| document.getElementById('canvasInfo').textContent = `Angle: ${this.angle}° | Spacing: ${this.spacing}px`; | |
| this.draw(); | |
| }); | |
| densitySlider.addEventListener('input', (e) => { | |
| this.density = parseInt(e.target.value); | |
| document.getElementById('densityValue').textContent = `${this.density} lines`; | |
| this.draw(); | |
| }); | |
| colorPicker.addEventListener('input', (e) => { | |
| this.color = e.target.value; | |
| this.draw(); | |
| }); | |
| } | |
| rotatePoint(x, y, centerX, centerY, angle) { | |
| const angleRad = (angle * Math.PI) / 180; | |
| const cos = Math.cos(angleRad); | |
| const sin = Math.sin(angleRad); | |
| const tempX = x - centerX; | |
| const tempY = y - centerY; | |
| const rotatedX = (tempX * cos) - (tempY * sin); | |
| const rotatedY = (tempX * sin) + (tempY * cos); | |
| return { | |
| x: rotatedX + centerX, | |
| y: rotatedY + centerY | |
| }; | |
| } | |
| draw() { | |
| this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); | |
| // Draw background grid | |
| this.ctx.strokeStyle = 'rgba(99, 102, 241, 0.1)'; | |
| this.ctx.lineWidth = 1; | |
| const gridSize = 50; | |
| for (let x = 0; x <= this.canvas.width; x += gridSize) { | |
| this.ctx.beginPath(); | |
| this.ctx.moveTo(x, 0); | |
| this.ctx.lineTo(x, this.canvas.height); | |
| this.ctx.stroke(); | |
| } | |
| for (let y = 0; y <= this.canvas.height; y += gridSize) { | |
| this.ctx.beginPath(); | |
| this.ctx.moveTo(0, y); | |
| this.ctx.lineTo(this.canvas.width, y); | |
| this.ctx.stroke(); | |
| } | |
| // Draw rotated grid lines | |
| this.ctx.strokeStyle = this.color; | |
| this.ctx.lineWidth = 2; | |
| const maxDimension = Math.max(this.canvas.width, this.canvas.height); | |
| const lineCount = Math.floor(maxDimension / this.spacing) * 2; | |
| for (let i = -lineCount / 2; i <= lineCount / 2; i++) { | |
| const offset = i * this.spacing; | |
| // Horizontal lines (before rotation) | |
| const p1 = { x: 0, y: this.centerY + offset }; | |
| const p2 = { x: this.canvas.width, y: this.centerY + offset }; | |
| // Rotate points | |
| const rotatedP1 = this.rotatePoint(p1.x, p1.y, this.centerX, this.centerY, this.angle); | |
| const rotatedP2 = this.rotatePoint(p2.x, p2.y, this.centerX, this.centerY, this.angle); | |
| // Draw line | |
| this.ctx.beginPath(); | |
| this.ctx.moveTo(rotatedP1.x, rotatedP1.y); | |
| this.ctx.lineTo(rotatedP2.x, rotatedP2.y); | |
| this.ctx.stroke(); | |
| } | |
| // Draw center point | |
| this.ctx.fillStyle = this.color; | |
| this.ctx.beginPath(); | |
| this.ctx.arc(this.centerX, this.centerY, 4, 0, Math.PI * 2); | |
| this.ctx.fill(); | |
| } | |
| } | |
| // Initialize the grid when the page loads | |
| document.addEventListener('DOMContentLoaded', () => { | |
| new RotatedGrid('gridCanvas'); | |
| }); | |
| </script> | |
| </body> | |
| </html> |