-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_generate_icons.html
More file actions
296 lines (258 loc) · 9.83 KB
/
test_generate_icons.html
File metadata and controls
296 lines (258 loc) · 9.83 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<!DOCTYPE html>
<html>
<head>
<title>Generate Test Icons</title>
<script src="js/arena-configs.js"></script>
<script src="js/icon-generator.js"></script>
<style>
body {
font-family: monospace;
padding: 20px;
background: #0f1419;
color: #e6edf3;
}
.icon {
margin: 20px 0;
padding: 15px;
background: #1a1f26;
border: 1px solid #2d3640;
}
.icon h3 {
margin: 0 0 10px 0;
color: #00e676;
}
.icon img {
border: 2px solid #00e676;
}
.download-btn {
margin: 10px 0;
padding: 8px 16px;
background: #00e676;
color: #0f1419;
border: none;
cursor: pointer;
font-family: monospace;
font-weight: bold;
}
</style>
</head>
<body>
<h1>Icon Generator Test - PNG Generation</h1>
<p>Generating test icons...</p>
<div id="icons"></div>
<script>
const iconsDiv = document.getElementById('icons');
function addIcon(title, dataURL, filename) {
const div = document.createElement('div');
div.className = 'icon';
const h3 = document.createElement('h3');
h3.textContent = title;
div.appendChild(h3);
const img = document.createElement('img');
img.src = dataURL;
img.width = 256;
img.height = 256;
div.appendChild(img);
const btn = document.createElement('button');
btn.className = 'download-btn';
btn.textContent = `Download ${filename}`;
btn.onclick = () => {
const link = document.createElement('a');
link.download = filename;
link.href = dataURL;
link.click();
};
div.appendChild(btn);
iconsDiv.appendChild(div);
console.log('✓ Generated:', title);
}
// Test 1: All-on pattern (G6 full arena)
try {
console.log('Test 1: All-on pattern');
const specs = PANEL_SPECS['G6'];
const numCols = 10, numRows = 2;
const totalColPixels = numCols * specs.pixels_per_panel;
const totalRowPixels = numRows * specs.pixels_per_panel;
const totalPixels = totalColPixels * totalRowPixels;
const frameData = new Array(totalPixels).fill(1);
const patternData = {
frames: [frameData],
rows: totalRowPixels,
cols: totalColPixels,
generation: 'G6',
grayscaleMode: 'GS2'
};
const arenaConfig = {
generation: 'G6',
num_rows: 2,
num_cols: 10,
columns_installed: null,
column_order: 'cw'
};
const dataURL = IconGenerator.generatePatternIcon(patternData, arenaConfig, {
width: 256,
height: 256,
innerRadiusRatio: 0.2,
backgroundColor: 'dark',
showOutlines: true
});
addIcon('Test 1: All-On (Full Arena)', dataURL, 'test1_allon_full.png');
} catch (error) {
console.error('Test 1 failed:', error);
}
// Test 2: Grating pattern (should show clear stripes)
try {
console.log('Test 2: Grating pattern');
const specs = PANEL_SPECS['G6'];
const numCols = 10, numRows = 2;
const totalColPixels = numCols * specs.pixels_per_panel;
const totalRowPixels = numRows * specs.pixels_per_panel;
const totalPixels = totalColPixels * totalRowPixels;
const frameData = new Array(totalPixels);
for (let row = 0; row < totalRowPixels; row++) {
for (let col = 0; col < totalColPixels; col++) {
const idx = row * totalColPixels + col;
frameData[idx] = Math.floor(col / 20) % 2;
}
}
const patternData = {
frames: [frameData],
rows: totalRowPixels,
cols: totalColPixels,
generation: 'G6',
grayscaleMode: 'GS2'
};
const arenaConfig = {
generation: 'G6',
num_rows: 2,
num_cols: 10,
columns_installed: null,
column_order: 'cw'
};
const dataURL = IconGenerator.generatePatternIcon(patternData, arenaConfig, {
width: 256,
height: 256,
innerRadiusRatio: 0.2,
backgroundColor: 'dark',
showOutlines: true
});
addIcon('Test 2: Grating (20px stripes)', dataURL, 'test2_grating.png');
} catch (error) {
console.error('Test 2 failed:', error);
}
// Test 3: Sine pattern (should show smooth gradient)
try {
console.log('Test 3: Sine pattern');
const specs = PANEL_SPECS['G6'];
const numCols = 10, numRows = 2;
const totalColPixels = numCols * specs.pixels_per_panel;
const totalRowPixels = numRows * specs.pixels_per_panel;
const totalPixels = totalColPixels * totalRowPixels;
const frameData = new Array(totalPixels);
for (let row = 0; row < totalRowPixels; row++) {
for (let col = 0; col < totalColPixels; col++) {
const idx = row * totalColPixels + col;
// GS16 requires values 0-15
frameData[idx] = Math.round((Math.sin(col * Math.PI / 30) + 1) / 2 * 15);
}
}
const patternData = {
frames: [frameData],
rows: totalRowPixels,
cols: totalColPixels,
generation: 'G6',
grayscaleMode: 'GS16'
};
const arenaConfig = {
generation: 'G6',
num_rows: 2,
num_cols: 10,
columns_installed: null,
column_order: 'cw'
};
const dataURL = IconGenerator.generatePatternIcon(patternData, arenaConfig, {
width: 256,
height: 256,
innerRadiusRatio: 0.2,
backgroundColor: 'dark',
showOutlines: true
});
addIcon('Test 3: Sine Pattern (GS16)', dataURL, 'test3_sine.png');
} catch (error) {
console.error('Test 3 failed:', error);
}
// Test 4: Partial arena (7 of 10 columns - R/L symmetric gap at bottom)
try {
console.log('Test 4: Partial arena');
const specs = PANEL_SPECS['G6'];
const numCols = 10, numRows = 2;
const totalColPixels = numCols * specs.pixels_per_panel;
const totalRowPixels = numRows * specs.pixels_per_panel;
const totalPixels = totalColPixels * totalRowPixels;
const frameData = new Array(totalPixels).fill(1);
const patternData = {
frames: [frameData],
rows: totalRowPixels,
cols: totalColPixels,
generation: 'G6',
grayscaleMode: 'GS2'
};
const arenaConfig = {
generation: 'G6',
num_rows: 2,
num_cols: 10,
columns_installed: [3,4,5,6,7,8,9], // Missing columns 0,1,2 (gap at bottom, R/L symmetric)
column_order: 'cw'
};
const dataURL = IconGenerator.generatePatternIcon(patternData, arenaConfig, {
width: 256,
height: 256,
innerRadiusRatio: 0.2,
backgroundColor: 'white', // White background to see gaps clearly
showOutlines: true,
showGaps: true
});
addIcon('Test 4: Partial Arena (7 of 10 cols, gap at bottom, white bg)', dataURL, 'test4_partial_white.png');
} catch (error) {
console.error('Test 4 failed:', error);
}
// Test 5: Partial arena with dark background
try {
console.log('Test 5: Partial arena dark bg');
const specs = PANEL_SPECS['G6'];
const numCols = 10, numRows = 2;
const totalColPixels = numCols * specs.pixels_per_panel;
const totalRowPixels = numRows * specs.pixels_per_panel;
const totalPixels = totalColPixels * totalRowPixels;
const frameData = new Array(totalPixels).fill(1);
const patternData = {
frames: [frameData],
rows: totalRowPixels,
cols: totalColPixels,
generation: 'G6',
grayscaleMode: 'GS2'
};
const arenaConfig = {
generation: 'G6',
num_rows: 2,
num_cols: 10,
columns_installed: [3,4,5,6,7,8,9], // Missing columns 0,1,2
column_order: 'cw'
};
const dataURL = IconGenerator.generatePatternIcon(patternData, arenaConfig, {
width: 256,
height: 256,
innerRadiusRatio: 0.2,
backgroundColor: 'dark',
showOutlines: true,
showGaps: true
});
addIcon('Test 5: Partial Arena (dark bg)', dataURL, 'test5_partial_dark.png');
} catch (error) {
console.error('Test 5 failed:', error);
}
console.log('\n=== All tests complete! ===');
console.log('Please download and examine each PNG file.');
</script>
</body>
</html>