-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-icons-html.html
More file actions
75 lines (66 loc) · 2.44 KB
/
create-icons-html.html
File metadata and controls
75 lines (66 loc) · 2.44 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html>
<head>
<title>Icon Generator</title>
</head>
<body>
<h2>Icon Generator</h2>
<p>Click the buttons to download icons:</p>
<button onclick="downloadIcon(16)">Download 16x16</button>
<button onclick="downloadIcon(48)">Download 48x48</button>
<button onclick="downloadIcon(128)">Download 128x128</button>
<canvas id="canvas" style="display:none;"></canvas>
<script>
function createIcon(size) {
const canvas = document.getElementById('canvas');
canvas.width = size;
canvas.height = size;
const ctx = canvas.getContext('2d');
// Blue background with rounded corners
const radius = size * 0.15;
ctx.fillStyle = '#4a90e2';
ctx.beginPath();
ctx.moveTo(radius, 0);
ctx.lineTo(size - radius, 0);
ctx.quadraticCurveTo(size, 0, size, radius);
ctx.lineTo(size, size - radius);
ctx.quadraticCurveTo(size, size, size - radius, size);
ctx.lineTo(radius, size);
ctx.quadraticCurveTo(0, size, 0, size - radius);
ctx.lineTo(0, radius);
ctx.quadraticCurveTo(0, 0, radius, 0);
ctx.closePath();
ctx.fill();
// White "W" text
ctx.fillStyle = 'white';
ctx.font = `bold ${size * 0.6}px Arial`;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText('W', size / 2, size / 2 + size * 0.05);
return canvas.toDataURL('image/png');
}
function downloadIcon(size) {
const dataUrl = createIcon(size);
const link = document.createElement('a');
link.download = `icon${size}.png`;
link.href = dataUrl;
link.click();
}
// Auto-generate and download all icons
function generateAll() {
setTimeout(() => downloadIcon(16), 100);
setTimeout(() => downloadIcon(48), 300);
setTimeout(() => downloadIcon(128), 500);
}
// Uncomment the next line to auto-generate on page load
// window.onload = generateAll;
</script>
<hr>
<h3>Instructions:</h3>
<ol>
<li>Open this HTML file in a browser</li>
<li>Click each button to download the icons</li>
<li>Save them in the extension directory as icon16.png, icon48.png, icon128.png</li>
</ol>
</body>
</html>