-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicon-generator.html
More file actions
172 lines (152 loc) · 4.77 KB
/
icon-generator.html
File metadata and controls
172 lines (152 loc) · 4.77 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!doctype html>
<html>
<head>
<title>Page Reader Assistant Icon Generator</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
background: #f5f5f5;
}
.container {
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
max-width: 600px;
}
canvas {
border: 1px solid #ddd;
margin: 10px;
border-radius: 8px;
}
button {
background: #007bff;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
margin: 5px;
}
button:hover {
background: #0056b3;
}
.preview {
display: flex;
align-items: center;
gap: 20px;
margin: 20px 0;
}
</style>
</head>
<body>
<div class="container">
<h1>Page Reader Assistant Icon Generator</h1>
<div class="preview">
<div>
<h3>128x128</h3>
<canvas id="icon128" width="128" height="128"></canvas>
<br />
<button onclick="downloadIcon(128)">Download 128x128</button>
</div>
<div>
<h3>48x48</h3>
<canvas id="icon48" width="48" height="48"></canvas>
<br />
<button onclick="downloadIcon(48)">Download 48x48</button>
</div>
<div>
<h3>16x16</h3>
<canvas id="icon16" width="16" height="16"></canvas>
<br />
<button onclick="downloadIcon(16)">Download 16x16</button>
</div>
</div>
<button onclick="generateAllIcons()">Generate All Icons</button>
<button onclick="downloadAll()">Download All as ZIP</button>
</div>
<script>
function drawIcon(canvas, size) {
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, size, size);
// Set up colors
const primaryColor = "#2c3e50"; // Dark blue-gray
const accentColor = "#34495e"; // Slightly lighter blue-gray
// Draw background (optional - can be transparent)
ctx.fillStyle = "white";
ctx.fillRect(0, 0, size, size);
// Center point
const centerX = size / 2;
const centerY = size / 2;
// Draw broadcast/signal lines
ctx.strokeStyle = primaryColor;
ctx.lineCap = "round";
// Left side curved lines
const lineWidth = Math.max(1, size * 0.08);
ctx.lineWidth = lineWidth;
// Calculate radii for the curved lines
const innerRadius = size * 0.25;
const middleRadius = size * 0.35;
const outerRadius = size * 0.45;
// Left curves
ctx.beginPath();
ctx.arc(centerX, centerY, innerRadius, Math.PI * 0.6, Math.PI * 1.4);
ctx.stroke();
ctx.beginPath();
ctx.arc(centerX, centerY, middleRadius, Math.PI * 0.7, Math.PI * 1.3);
ctx.stroke();
ctx.beginPath();
ctx.arc(centerX, centerY, outerRadius, Math.PI * 0.8, Math.PI * 1.2);
ctx.stroke();
// Right curves (mirror of left)
ctx.beginPath();
ctx.arc(centerX, centerY, innerRadius, Math.PI * 1.6, Math.PI * 0.4);
ctx.stroke();
ctx.beginPath();
ctx.arc(centerX, centerY, middleRadius, Math.PI * 1.7, Math.PI * 0.3);
ctx.stroke();
ctx.beginPath();
ctx.arc(centerX, centerY, outerRadius, Math.PI * 1.8, Math.PI * 0.2);
ctx.stroke();
// Draw "AA" text in center
ctx.fillStyle = primaryColor;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
// Adjust font size based on canvas size
let fontSize;
if (size <= 16) {
fontSize = size * 0.5;
} else if (size <= 48) {
fontSize = size * 0.4;
} else {
fontSize = size * 0.35;
}
ctx.font = `bold ${fontSize}px Arial, sans-serif`;
ctx.fillText("AA", centerX, centerY);
}
function generateAllIcons() {
[16, 48, 128].forEach((size) => {
const canvas = document.getElementById(`icon${size}`);
drawIcon(canvas, size);
});
}
function downloadIcon(size) {
const canvas = document.getElementById(`icon${size}`);
const link = document.createElement("a");
link.download = `icon${size}.png`;
link.href = canvas.toDataURL("image/png");
link.click();
}
function downloadAll() {
// For simplicity, download individually
// In a real implementation, you'd use JSZip
[16, 48, 128].forEach((size) => {
setTimeout(() => downloadIcon(size), size * 10);
});
}
// Generate icons on page load
generateAllIcons();
</script>
</body>
</html>