|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>Generate PNG Icons</title> |
| 7 | + <style> |
| 8 | + body { |
| 9 | + font-family: system-ui, -apple-system, sans-serif; |
| 10 | + max-width: 800px; |
| 11 | + margin: 40px auto; |
| 12 | + padding: 20px; |
| 13 | + background: #f5f5f5; |
| 14 | + } |
| 15 | + .container { |
| 16 | + background: white; |
| 17 | + padding: 30px; |
| 18 | + border-radius: 12px; |
| 19 | + box-shadow: 0 2px 8px rgba(0,0,0,0.1); |
| 20 | + } |
| 21 | + h1 { |
| 22 | + color: #333; |
| 23 | + margin-bottom: 10px; |
| 24 | + } |
| 25 | + .instructions { |
| 26 | + background: #e3f2fd; |
| 27 | + padding: 15px; |
| 28 | + border-radius: 8px; |
| 29 | + margin: 20px 0; |
| 30 | + color: #1565c0; |
| 31 | + } |
| 32 | + .icons-preview { |
| 33 | + display: flex; |
| 34 | + gap: 30px; |
| 35 | + margin: 30px 0; |
| 36 | + align-items: flex-start; |
| 37 | + } |
| 38 | + .icon-item { |
| 39 | + text-align: center; |
| 40 | + } |
| 41 | + .icon-item canvas { |
| 42 | + border: 1px solid #ddd; |
| 43 | + border-radius: 4px; |
| 44 | + margin-bottom: 10px; |
| 45 | + } |
| 46 | + button { |
| 47 | + background: #10b981; |
| 48 | + color: white; |
| 49 | + border: none; |
| 50 | + padding: 12px 24px; |
| 51 | + border-radius: 6px; |
| 52 | + font-size: 16px; |
| 53 | + cursor: pointer; |
| 54 | + margin-right: 10px; |
| 55 | + } |
| 56 | + button:hover { |
| 57 | + background: #059669; |
| 58 | + } |
| 59 | + .success { |
| 60 | + background: #d4edda; |
| 61 | + color: #155724; |
| 62 | + padding: 15px; |
| 63 | + border-radius: 8px; |
| 64 | + margin-top: 20px; |
| 65 | + display: none; |
| 66 | + } |
| 67 | + </style> |
| 68 | +</head> |
| 69 | +<body> |
| 70 | + <div class="container"> |
| 71 | + <h1>🎨 Tab Manager Icon Generator</h1> |
| 72 | + <p>Generate PNG icons for your Chrome extension</p> |
| 73 | + |
| 74 | + <div class="instructions"> |
| 75 | + <strong>Instructions:</strong> |
| 76 | + <ol> |
| 77 | + <li>Click "Generate Icons" to create the PNG files</li> |
| 78 | + <li>Click each "Download" button to save the icons</li> |
| 79 | + <li>Save them in the <code>icons/</code> folder with the correct names</li> |
| 80 | + <li>Reload your extension in Chrome</li> |
| 81 | + </ol> |
| 82 | + </div> |
| 83 | + |
| 84 | + <button onclick="generateIcons()">Generate Icons</button> |
| 85 | + |
| 86 | + <div class="icons-preview" id="preview"></div> |
| 87 | + |
| 88 | + <div class="success" id="success"> |
| 89 | + ✓ Icons generated! Click the download buttons above to save them. |
| 90 | + </div> |
| 91 | + </div> |
| 92 | + |
| 93 | + <script> |
| 94 | + function drawIcon(canvas, size) { |
| 95 | + const ctx = canvas.getContext('2d'); |
| 96 | + const scale = size / 48; |
| 97 | + |
| 98 | + ctx.scale(scale, scale); |
| 99 | + |
| 100 | + // Background with rounded corners |
| 101 | + ctx.fillStyle = '#10b981'; |
| 102 | + roundRect(ctx, 0, 0, 48, 48, 8); |
| 103 | + ctx.fill(); |
| 104 | + |
| 105 | + // Window/Tab icon - white background |
| 106 | + ctx.fillStyle = 'white'; |
| 107 | + roundRect(ctx, 9, 12, 30, 24, 2); |
| 108 | + ctx.fill(); |
| 109 | + |
| 110 | + // Top bar (header) |
| 111 | + ctx.fillStyle = '#059669'; |
| 112 | + roundRect(ctx, 9, 12, 30, 7, 2); |
| 113 | + ctx.fill(); |
| 114 | + |
| 115 | + // Lines representing text |
| 116 | + ctx.strokeStyle = '#10b981'; |
| 117 | + ctx.lineWidth = 2; |
| 118 | + ctx.lineCap = 'round'; |
| 119 | + |
| 120 | + // First line |
| 121 | + ctx.beginPath(); |
| 122 | + ctx.moveTo(14, 24); |
| 123 | + ctx.lineTo(34, 24); |
| 124 | + ctx.stroke(); |
| 125 | + |
| 126 | + // Second line (shorter) |
| 127 | + ctx.beginPath(); |
| 128 | + ctx.moveTo(14, 29); |
| 129 | + ctx.lineTo(26, 29); |
| 130 | + ctx.stroke(); |
| 131 | + } |
| 132 | + |
| 133 | + function roundRect(ctx, x, y, width, height, radius) { |
| 134 | + ctx.beginPath(); |
| 135 | + ctx.moveTo(x + radius, y); |
| 136 | + ctx.lineTo(x + width - radius, y); |
| 137 | + ctx.quadraticCurveTo(x + width, y, x + width, y + radius); |
| 138 | + ctx.lineTo(x + width, y + height - radius); |
| 139 | + ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height); |
| 140 | + ctx.lineTo(x + radius, y + height); |
| 141 | + ctx.quadraticCurveTo(x, y + height, x, y + height - radius); |
| 142 | + ctx.lineTo(x, y + radius); |
| 143 | + ctx.quadraticCurveTo(x, y, x + radius, y); |
| 144 | + ctx.closePath(); |
| 145 | + } |
| 146 | + |
| 147 | + function downloadCanvas(canvas, filename) { |
| 148 | + canvas.toBlob(function(blob) { |
| 149 | + const url = URL.createObjectURL(blob); |
| 150 | + const a = document.createElement('a'); |
| 151 | + a.href = url; |
| 152 | + a.download = filename; |
| 153 | + a.click(); |
| 154 | + URL.revokeObjectURL(url); |
| 155 | + }); |
| 156 | + } |
| 157 | + |
| 158 | + function generateIcons() { |
| 159 | + const preview = document.getElementById('preview'); |
| 160 | + preview.innerHTML = ''; |
| 161 | + |
| 162 | + const sizes = [ |
| 163 | + { size: 16, name: 'icon16.png' }, |
| 164 | + { size: 48, name: 'icon48.png' }, |
| 165 | + { size: 128, name: 'icon128.png' } |
| 166 | + ]; |
| 167 | + |
| 168 | + sizes.forEach(({ size, name }) => { |
| 169 | + const item = document.createElement('div'); |
| 170 | + item.className = 'icon-item'; |
| 171 | + |
| 172 | + const canvas = document.createElement('canvas'); |
| 173 | + canvas.width = size; |
| 174 | + canvas.height = size; |
| 175 | + drawIcon(canvas, size); |
| 176 | + |
| 177 | + const label = document.createElement('div'); |
| 178 | + label.textContent = `${size}x${size}`; |
| 179 | + label.style.fontWeight = 'bold'; |
| 180 | + label.style.marginBottom = '8px'; |
| 181 | + |
| 182 | + const button = document.createElement('button'); |
| 183 | + button.textContent = `Download ${name}`; |
| 184 | + button.onclick = () => downloadCanvas(canvas, name); |
| 185 | + |
| 186 | + item.appendChild(label); |
| 187 | + item.appendChild(canvas); |
| 188 | + item.appendChild(button); |
| 189 | + preview.appendChild(item); |
| 190 | + }); |
| 191 | + |
| 192 | + document.getElementById('success').style.display = 'block'; |
| 193 | + } |
| 194 | + </script> |
| 195 | +</body> |
| 196 | +</html> |
0 commit comments