-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_icon_generation.html
More file actions
213 lines (183 loc) · 7.31 KB
/
test_icon_generation.html
File metadata and controls
213 lines (183 loc) · 7.31 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
<!DOCTYPE html>
<html>
<head>
<title>Icon Generator Test</title>
<script src="js/arena-configs.js"></script>
<script src="js/icon-generator.js"></script>
</head>
<body>
<h1>Testing Icon Generator</h1>
<div id="output"></div>
<div id="icons"></div>
<script>
const output = document.getElementById('output');
const iconsDiv = document.getElementById('icons');
function log(msg) {
output.innerHTML += msg + '<br>';
console.log(msg);
}
// Test 1: Generate test icon for G6 full arena
try {
log('Test 1: G6 Full Arena (2x10) with grating pattern');
const dataURL = IconGenerator.generateTestIcon(256, 256, 'G6', 10, 2, 'grating');
log('✓ Generated successfully!');
const img = document.createElement('img');
img.src = dataURL;
img.style.border = '2px solid #00e676';
img.style.margin = '10px';
iconsDiv.appendChild(img);
} catch (error) {
log('✗ Error: ' + error.message);
console.error(error);
}
// Test 2: Generate for G6 partial arena
try {
log('Test 2: G6 Partial Arena (2x8of10) with sine pattern');
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;
// Generate sine pattern
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 / 30) + 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 columns
};
const dataURL = IconGenerator.generatePatternIcon(patternData, arenaConfig, {
width: 256,
height: 256,
innerRadiusRatio: 0.2
});
log('✓ Generated partial arena successfully!');
const img = document.createElement('img');
img.src = dataURL;
img.style.border = '2px solid #00e676';
img.style.margin = '10px';
iconsDiv.appendChild(img);
} catch (error) {
log('✗ Error: ' + error.message);
console.error(error);
}
// Test 3: Test motion blur with exponential weighting
try {
log('Test 3: Motion blur with 5 frames (exponential weighting)');
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;
// Generate 5 frames with moving grating
const frames = [];
for (let f = 0; f < 5; f++) {
const frameData = new Array(totalPixels);
const offset = f * 10; // Move by 10 pixels each frame
for (let row = 0; row < totalRowPixels; row++) {
for (let col = 0; col < totalColPixels; col++) {
const idx = row * totalColPixels + col;
frameData[idx] = 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 // Full arena
};
const dataURL = IconGenerator.generateMotionIcon(patternData, arenaConfig, {
width: 256,
height: 256,
innerRadiusRatio: 0.2,
frameRange: [0, 4],
maxFrames: 5,
weightingFunction: 'exponential'
});
log('✓ Generated motion blur icon successfully!');
const img = document.createElement('img');
img.src = dataURL;
img.style.border = '2px solid #ff9800';
img.style.margin = '10px';
iconsDiv.appendChild(img);
} catch (error) {
log('✗ Error: ' + error.message);
console.error(error);
}
// Test 4: Test different inner radius ratios
try {
log('Test 4: Different perspective (inner radius = 0.1)');
const dataURL = IconGenerator.generateTestIcon(256, 256, 'G6', 10, 2, 'grating');
// Generate with different settings
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.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 dataURLSmallInner = IconGenerator.generatePatternIcon(patternData, arenaConfig, {
width: 256,
height: 256,
innerRadiusRatio: 0.1 // More dramatic perspective
});
log('✓ Generated with small inner radius!');
const img = document.createElement('img');
img.src = dataURLSmallInner;
img.style.border = '2px solid #2196f3';
img.style.margin = '10px';
iconsDiv.appendChild(img);
} catch (error) {
log('✗ Error: ' + error.message);
console.error(error);
}
log('<br><strong>All tests completed!</strong>');
</script>
</body>
</html>