nuts / files / src / gallery.ts
gallery.ts
| 1 | // Gallery mode — rendered when ?gallery is present in the URL. |
| 2 | // Mounts a single <canvas> with all item variants drawn statically. |
| 3 | // No physics, no UI. Used by the screenshot script in scripts/screenshot.ts. |
| 4 | |
| 5 | import { renderGallery } from './renderer' |
| 6 | |
| 7 | export function runGallery(): void { |
| 8 | document.body.style.cssText = 'margin:0;padding:0;background:#1a1a1a;overflow:auto' |
| 9 | |
| 10 | // Hide all UI overlays so only the canvas shows |
| 11 | for (const id of ['start-overlay', 'fullscreen-overlay', 'toolbar', 'settings-panel']) { |
| 12 | const el = document.getElementById(id) |
| 13 | if (el) { el.hidden = true; (el as HTMLElement).style.display = 'none' } |
| 14 | } |
| 15 | |
| 16 | const canvas = document.getElementById('canvas') as HTMLCanvasElement |
| 17 | renderGallery(canvas) |
| 18 | |
| 19 | // Stretch the <canvas> element to its natural pixel size so the screenshot |
| 20 | // tool captures it without scaling artifacts |
| 21 | canvas.style.width = `${canvas.width}px` |
| 22 | canvas.style.height = `${canvas.height}px` |
| 23 | |
| 24 | // Signal to Playwright that the gallery is ready |
| 25 | document.body.setAttribute('data-gallery-ready', 'true') |
| 26 | } |