-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_quick.html
More file actions
254 lines (229 loc) · 8.94 KB
/
test_quick.html
File metadata and controls
254 lines (229 loc) · 8.94 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
<!DOCTYPE html>
<html>
<head>
<title>Quick Icon Test</title>
<script src="js/arena-configs.js"></script>
<script src="js/icon-generator.js"></script>
<style>
body {
font-family: monospace;
background: #0f1419;
color: #e6edf3;
padding: 20px;
}
.test-result {
margin: 10px 0;
padding: 10px;
background: #1a1f26;
border-left: 3px solid #00e676;
}
.test-result.fail { border-left-color: #ff5252; }
.icon-preview {
margin: 10px 0;
padding: 10px;
background: #1a1f26;
display: inline-block;
}
img {
border: 2px solid #00e676;
display: block;
}
</style>
</head>
<body>
<h1>Icon Generator Quick Test</h1>
<div id="results"></div>
<div id="icons"></div>
<script>
const results = document.getElementById('results');
const icons = document.getElementById('icons');
function logTest(name, passed, details) {
const div = document.createElement('div');
div.className = 'test-result' + (passed ? '' : ' fail');
div.innerHTML = `<strong>${passed ? '✓' : '✗'} ${name}</strong><br>${details}`;
results.appendChild(div);
console.log(passed ? '✓' : '✗', name, details);
}
function showIcon(name, dataURL) {
const div = document.createElement('div');
div.className = 'icon-preview';
const label = document.createElement('div');
label.textContent = name;
label.style.marginBottom = '5px';
label.style.fontWeight = 'bold';
const img = document.createElement('img');
img.src = dataURL;
img.width = 256;
img.height = 256;
div.appendChild(label);
div.appendChild(img);
icons.appendChild(div);
}
// Test 1: Check exports
try {
if (typeof IconGenerator === 'undefined') {
throw new Error('IconGenerator not exported to window');
}
if (!IconGenerator.generatePatternIcon) {
throw new Error('generatePatternIcon not found');
}
if (!IconGenerator.generateMotionIcon) {
throw new Error('generateMotionIcon not found');
}
logTest('Module Exports', true, 'All functions exported correctly');
} catch (error) {
logTest('Module Exports', false, error.message);
}
// Test 2: Generate full arena grating
try {
const dataURL = IconGenerator.generateTestIcon(256, 256, 'G6', 10, 2, 'grating');
if (!dataURL || !dataURL.startsWith('data:image/png')) {
throw new Error('Invalid data URL returned');
}
logTest('Full Arena Grating (G6 2x10)', true, `Generated ${dataURL.length} bytes`);
showIcon('Full Arena Grating', dataURL);
} catch (error) {
logTest('Full Arena Grating', false, error.message);
}
// Test 3: Partial arena with gap
try {
const specs = PANEL_SPECS['G6'];
const pixelsPerPanel = specs.pixels_per_panel;
const numCols = 10;
const numRows = 2;
const totalColPixels = numCols * pixelsPerPanel;
const totalRowPixels = numRows * pixelsPerPanel;
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.sin(col * Math.PI / 20) + 1) / 2;
}
}
const patternData = {
frames: [frameData],
rows: totalRowPixels,
cols: totalColPixels,
generation: 'G6',
grayscaleMode: 'GS16'
};
const arenaConfig = {
generation: 'G6',
num_rows: 2,
num_cols: 10,
columns_installed: [0, 1, 2, 3, 4, 5, 6, 7] // 8 of 10 = 72° gap
};
const dataURL = IconGenerator.generatePatternIcon(patternData, arenaConfig, {
width: 256,
height: 256,
innerRadiusRatio: 0.2,
backgroundColor: 'dark',
showOutlines: true
});
if (!dataURL || !dataURL.startsWith('data:image/png')) {
throw new Error('Invalid data URL returned');
}
logTest('Partial Arena (8 of 10 columns)', true, `Generated with 72° gap`);
showIcon('Partial Arena (288°)', dataURL);
} catch (error) {
logTest('Partial Arena', false, error.message);
}
// Test 4: Different perspective
try {
const dataURL = IconGenerator.generateTestIcon(256, 256, 'G6', 10, 2, 'grating');
const specs = PANEL_SPECS['G6'];
const pixelsPerPanel = specs.pixels_per_panel;
const numCols = 10;
const numRows = 2;
const totalColPixels = numCols * pixelsPerPanel;
const totalRowPixels = numRows * pixelsPerPanel;
const totalPixels = totalColPixels * totalRowPixels;
const frameData = new Array(totalPixels);
for (let i = 0; i < totalPixels; i++) {
const col = i % totalColPixels;
frameData[i] = 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
};
const dataURLDramatic = IconGenerator.generatePatternIcon(patternData, arenaConfig, {
width: 256,
height: 256,
innerRadiusRatio: 0.1, // More dramatic
backgroundColor: 'dark',
showOutlines: true
});
if (!dataURLDramatic || !dataURLDramatic.startsWith('data:image/png')) {
throw new Error('Invalid data URL returned');
}
logTest('Dramatic Perspective', true, 'Generated with innerRadius=0.1');
showIcon('Dramatic Perspective (0.1)', dataURLDramatic);
} catch (error) {
logTest('Dramatic Perspective', false, error.message);
}
// Test 5: Motion blur
try {
const specs = PANEL_SPECS['G6'];
const pixelsPerPanel = specs.pixels_per_panel;
const numCols = 10;
const numRows = 2;
const totalColPixels = numCols * pixelsPerPanel;
const totalRowPixels = numRows * pixelsPerPanel;
const totalPixels = totalColPixels * totalRowPixels;
// Create 10 frames with moving grating
const frames = [];
for (let f = 0; f < 10; f++) {
const frameData = new Array(totalPixels);
const offset = f * 5; // Move 5 pixels per frame
for (let i = 0; i < totalPixels; i++) {
const col = i % totalColPixels;
frameData[i] = Math.floor((col + offset) / 20) % 2;
}
frames.push(frameData);
}
const patternData = {
frames: frames,
rows: totalRowPixels,
cols: totalColPixels,
generation: 'G6',
grayscaleMode: 'GS2'
};
const arenaConfig = {
generation: 'G6',
num_rows: 2,
num_cols: 10,
columns_installed: null
};
const dataURL = IconGenerator.generateMotionIcon(patternData, arenaConfig, {
width: 256,
height: 256,
innerRadiusRatio: 0.2,
frameRange: [0, 9],
maxFrames: 10,
weightingFunction: 'exponential',
backgroundColor: 'dark',
showOutlines: true
});
if (!dataURL || !dataURL.startsWith('data:image/png')) {
throw new Error('Invalid data URL returned');
}
logTest('Motion Blur (10 frames)', true, 'Generated with exponential weighting');
showIcon('Motion Blur (Moving Grating)', dataURL);
} catch (error) {
logTest('Motion Blur', false, error.message);
}
console.log('=== All Tests Complete ===');
</script>
</body>
</html>