Spaces:
Running
Running
Download script.js from FLEED993/sketchmaster-pro: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/spaces/FLEED993/sketchmaster-pro/resolve/main/script.js
- Command line
-
hf download hf://spaces/FLEED993/sketchmaster-pro/script.js
-
curl -L -o script.js https://huggingface.co/spaces/FLEED993/sketchmaster-pro/resolve/main/script.js
1.32 kB
| // Shared JavaScript functionality | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Initialize any shared functionality here | |
| console.log('SketchMaster Pro loaded!'); | |
| // Color palette selection | |
| document.querySelectorAll('.rounded-full').forEach(color => { | |
| color.addEventListener('click', function() { | |
| document.querySelectorAll('.rounded-full').forEach(c => { | |
| c.classList.remove('ring-2', 'ring-offset-2', 'ring-primary-500'); | |
| }); | |
| this.classList.add('ring-2', 'ring-offset-2', 'ring-primary-500'); | |
| // Update current drawing color | |
| const ctx = document.getElementById('drawingCanvas').getContext('2d'); | |
| ctx.strokeStyle = window.getComputedStyle(this).backgroundColor; | |
| }); | |
| }); | |
| }); | |
| // Clear canvas function | |
| function clearCanvas() { | |
| const canvas = document.getElementById('drawingCanvas'); | |
| const ctx = canvas.getContext('2d'); | |
| ctx.clearRect(0, 0, canvas.width, canvas.height); | |
| } | |
| // Save canvas function | |
| function saveCanvas() { | |
| const canvas = document.getElementById('drawingCanvas'); | |
| const dataURL = canvas.toDataURL('image/png'); | |
| const link = document.createElement('a'); | |
| link.download = 'sketchmaster-drawing.png'; | |
| link.href = dataURL; | |
| link.click(); | |
| } |