Spaces:
Running

File size: 1,321 Bytes
c7419b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// 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();
}