-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
400 lines (368 loc) · 19.3 KB
/
Copy pathindex.html
File metadata and controls
400 lines (368 loc) · 19.3 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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Pixel2Code — GIF to C/C++ Array Converter for OLED/LCD embedded displays. Export GIF animations as Arduino, ESP32, or plain C arrays.">
<meta name="author" content="Surya.S">
<title>Pixel2Code — GIF to C/C++ Converter</title>
<!-- Favicon placeholder -->
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
<!-- Bootstrap CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap Icons -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&family=Barlow:wght@300;400;500;600&display=swap" rel="stylesheet">
<!-- App Styles -->
<link rel="stylesheet" href="assets/css/styles.css">
</head>
<body>
<!-- ═══════════════════════════════════════════
HELP MODAL
═══════════════════════════════════════════ -->
<div class="modal fade" id="helpModal" tabindex="-1" aria-labelledby="helpModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="helpModalLabel">
<i class="bi bi-book me-2"></i>Pixel.2Code — Converter Guide
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="row g-4">
<div class="col-md-6">
<p class="guide-step-title" data-step="1">Upload GIF</p>
<p class="guide-item"><i class="bi bi-upload"></i>Click "Choose File" to upload from your computer</p>
<p class="guide-item"><i class="bi bi-link"></i>Or paste a GIF URL and click "Load URL"</p>
</div>
<div class="col-md-6">
<p class="guide-step-title" data-step="2">Configure Output</p>
<p class="guide-item"><i class="bi bi-aspect-ratio"></i>Set display dimensions matching your OLED/LCD</p>
<p class="guide-item"><i class="bi bi-grid"></i>Choose pixel scanning mode for optimal output</p>
</div>
<div class="col-md-6">
<p class="guide-step-title" data-step="3">Process Image</p>
<p class="guide-item"><i class="bi bi-sliders"></i>Adjust threshold for B/W conversion quality</p>
<p class="guide-item"><i class="bi bi-arrows-angle-expand"></i>Choose scale mode for perfect display fit</p>
<p class="guide-item"><i class="bi bi-symmetry-horizontal"></i>Apply flips and rotation transforms</p>
</div>
<div class="col-md-6">
<p class="guide-step-title" data-step="4">Generate Code</p>
<p class="guide-item"><i class="bi bi-code-square"></i>Set a variable name for your animation</p>
<p class="guide-item"><i class="bi bi-cpu"></i>Choose target platform (Arduino, ESP32, plain C)</p>
<p class="guide-item"><i class="bi bi-file-earmark-arrow-down"></i>Save as .h file or copy generated code</p>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- ═══════════════════════════════════════════
MAIN CONTENT
═══════════════════════════════════════════ -->
<div class="main-wrapper">
<!-- ── HEADER ── -->
<header class="site-header">
<div class="brand-badge">
<span class="pulse-dot"></span>
⚡ Esp32 Embedded Tools
</div>
<h1 class="site-logo">
<span class="logo-spark">Pixel</span><span class="logo-dot">.</span>2Code
</h1>
<p class="site-subtitle">GIF → C/C++ Array Converter for OLED & LCD Displays</p>
<!-- Social / Nav Links -->
<div class="social-links">
<a href="https://instagram.com/sparky.fpv" target="_blank" rel="noopener" class="social-btn instagram">
<i class="bi bi-instagram"></i> sparky.fpv
</a>
<a href="https://www.youtube.com/@sparky.390" target="_blank" rel="noopener" class="social-btn youtube">
<i class="bi bi-youtube"></i> YouTube Channel
</a>
<a href="https://github.com/sparky390" target="_blank" rel="noopener" class="social-btn github">
<i class="bi bi-github"></i> GitHub
</a>
<button type="button" class="social-btn help-btn" data-bs-toggle="modal" data-bs-target="#helpModal">
<i class="bi bi-question-circle"></i> Help Guide
</button>
</div>
</header>
<!-- ── STATS ROW ── -->
<div class="stats-row">
<div class="stat-card">
<div class="stat-number" id="frameCount">0</div>
<div class="stat-label">Frames</div>
</div>
<div class="stat-card">
<div class="stat-number" id="resolution">128×64</div>
<div class="stat-label">Resolution</div>
</div>
<div class="stat-card">
<div class="stat-number" id="fileSize">0 KB</div>
<div class="stat-label">File Size</div>
</div>
<div class="stat-card">
<div class="stat-number" id="compression">100%</div>
<div class="stat-label">Optimized</div>
</div>
</div>
<!-- ── UPLOAD CARD ── -->
<div class="section-card">
<div class="section-header">
<i class="bi bi-cloud-arrow-up-fill section-header-icon"></i>
<h5>Upload GIF Source</h5>
</div>
<div class="section-body">
<div class="row g-4">
<!-- Left: Upload controls -->
<div class="col-md-6">
<h6 class="fw-label text-orange mb-3"><i class="bi bi-pc-display me-2"></i>Local File</h6>
<div class="mb-3">
<label for="gifUpload" class="form-label">Choose GIF File</label>
<input type="file" class="form-control" id="gifUpload" accept=".gif">
</div>
<div class="mb-3">
<label for="gifUrlInput" class="form-label">Or Load from URL</label>
<div class="input-group">
<input type="url" class="form-control" id="gifUrlInput" placeholder="https://example.com/animation.gif">
<button class="btn btn-outline" type="button" id="loadUrlBtn">
<i class="bi bi-cloud-download"></i> Load
</button>
</div>
</div>
<label class="toggle-label mt-3">
<div class="toggle-switch">
<input type="checkbox" id="previewEnabled" checked>
<span class="toggle-slider"></span>
</div>
Enable Live Preview
</label>
</div>
<!-- Right: Output config -->
<div class="col-md-6">
<h6 class="fw-label text-orange mb-3"><i class="bi bi-gear-wide-connected me-2"></i>Output Config</h6>
<div class="mb-3">
<label class="form-label">Display Dimensions</label>
<div class="input-group">
<input type="number" class="form-control" id="canvasWidth" placeholder="Width" min="1" value="128" aria-label="Width">
<span class="input-group-text">×</span>
<input type="number" class="form-control" id="canvasHeight" placeholder="Height" min="1" value="64" aria-label="Height">
<span class="input-group-text">px</span>
</div>
</div>
<div class="mb-3">
<label for="drawMode" class="form-label">Pixel Scanning Method</label>
<select class="form-select" id="drawMode">
<option value="horizontal" selected>Horizontal (MSB first)</option>
<option value="vertical">Vertical (MSB first)</option>
<option value="horizontal_bytes">Horizontal Bytes</option>
</select>
</div>
</div>
</div>
</div>
</div>
<!-- ── IMAGE PROCESSING CARD ── -->
<div class="section-card">
<div class="section-header">
<i class="bi bi-sliders2 section-header-icon"></i>
<h5>Image Processing</h5>
</div>
<div class="section-body">
<div class="row g-3">
<!-- Threshold -->
<div class="col-md-4">
<label class="form-label">
Threshold: <span id="thresholdValue" class="text-orange">128</span>
</label>
<input type="range" class="form-range" min="0" max="255" id="threshold" value="128">
<div class="d-flex" style="justify-content:space-between; margin-top:4px;">
<small class="text-muted-custom">Dark</small>
<small class="text-muted-custom">Light</small>
</div>
</div>
<!-- Scale Mode -->
<div class="col-md-4">
<label for="scaleMode" class="form-label">Scaling Algorithm</label>
<select class="form-select" id="scaleMode">
<option value="fit">Fit to Frame</option>
<option value="fit_width">Fit Width</option>
<option value="fit_height">Fit Height</option>
<option value="stretch">Stretch</option>
<option value="custom">Custom Scale</option>
</select>
<div id="customScaleDiv" class="d-none mt-2">
<div class="input-group">
<span class="input-group-text">Scale</span>
<input type="number" class="form-control" id="customScale" value="1" step="0.1" min="0.1">
</div>
</div>
</div>
<!-- Color Processing -->
<div class="col-md-4">
<label class="form-label">Color Processing</label>
<label class="toggle-label">
<div class="toggle-switch">
<input type="checkbox" id="invertColors">
<span class="toggle-slider"></span>
</div>
Invert Colors
</label>
</div>
</div>
<hr class="section-divider">
<h6 class="fw-label text-orange mb-3"><i class="bi bi-arrow-repeat me-2"></i>Transformations</h6>
<div class="row g-3">
<!-- Flips -->
<div class="col-md-4">
<label class="form-label">Flip</label>
<div class="d-flex" style="flex-direction:column; gap:12px;">
<label class="toggle-label">
<div class="toggle-switch">
<input type="checkbox" id="flipHorizontal">
<span class="toggle-slider"></span>
</div>
Flip Horizontal
</label>
<label class="toggle-label">
<div class="toggle-switch">
<input type="checkbox" id="flipVertical">
<span class="toggle-slider"></span>
</div>
Flip Vertical
</label>
</div>
</div>
<!-- Rotation -->
<div class="col-md-4">
<label for="rotation" class="form-label">Rotation Angle</label>
<select class="form-select" id="rotation">
<option value="0">0°</option>
<option value="90">90°</option>
<option value="180">180°</option>
<option value="270">270°</option>
</select>
</div>
<!-- Presets -->
<div class="col-md-4">
<label class="form-label">Quick Presets</label>
<div class="preset-group">
<button class="btn btn-ghost w-100" onclick="applyPreset('oled')">
<i class="bi bi-display"></i> OLED
</button>
<button class="btn btn-ghost w-100" onclick="applyPreset('tft')">
<i class="bi bi-tv"></i> TFT
</button>
</div>
</div>
</div>
</div>
</div>
<!-- ── PREVIEW SECTION ── -->
<div class="preview-section" id="previewSection">
<span class="preview-label">Live Preview</span>
<p class="preview-title"><i class="bi bi-play-circle me-2"></i>Animation Preview</p>
<div id="framesPreview" class="text-center mb-4"></div>
<div class="frame-controls">
<button id="prevFrame" class="btn btn-ghost" disabled>
<i class="bi bi-chevron-left"></i> Prev
</button>
<span id="frameCounter" class="frame-counter">Frame: 0 / 0</span>
<button id="nextFrame" class="btn btn-ghost" disabled>
Next <i class="bi bi-chevron-right"></i>
</button>
<button id="playPause" class="btn btn-primary" disabled>
<i class="bi bi-play-fill"></i> Play
</button>
</div>
</div>
<!-- ── CODE FORMAT CARD ── -->
<div class="section-card">
<div class="section-header">
<i class="bi bi-code-square section-header-icon"></i>
<h5>Code Output Format</h5>
</div>
<div class="section-body">
<div class="row g-3">
<div class="col-md-6">
<label for="variableName" class="form-label">Structure Name</label>
<input type="text" class="form-control" id="variableName" placeholder="myAnimation" value="myAnimation">
<small class="form-text">Name for the GIF data structure in generated code</small>
</div>
<div class="col-md-6">
<label for="outputFormat" class="form-label">Target Platform</label>
<select class="form-select" id="outputFormat">
<option value="arduino" selected>Arduino (PROGMEM)</option>
<option value="plain">C/C++ Plain (const)</option>
<option value="esp8266">ESP8266 / ESP32 (PROGMEM)</option>
</select>
<small class="form-text">Platform-specific memory storage optimization</small>
</div>
</div>
</div>
</div>
<!-- ── CONVERT + OUTPUT ── -->
<div class="mb-4">
<button id="convertButton" class="btn-convert mb-4" disabled>
<i class="bi bi-magic me-2"></i>Convert GIF to C/C++ Array
</button>
<label class="form-label fw-label text-orange mb-2">
<i class="bi bi-file-earmark-code me-2"></i>Generated Code
</label>
<div class="code-output-wrapper">
<div class="code-toolbar">
<div class="code-toolbar-dots">
<span></span><span></span><span></span>
</div>
<button class="btn btn-ghost btn-sm" onclick="saveAsHeader()" title="Save as .h file">
<i class="bi bi-file-earmark-arrow-down"></i>
<span class="d-none d-md-inline">Save .h</span>
</button>
<button class="btn btn-ghost btn-sm" onclick="copyCode()" title="Copy to clipboard">
<i class="bi bi-clipboard"></i>
<span class="d-none d-md-inline">Copy</span>
</button>
<button class="btn btn-ghost btn-sm" onclick="clearCode()" title="Clear output">
<i class="bi bi-x-circle"></i>
<span class="d-none d-md-inline">Clear</span>
</button>
</div>
<pre id="codeOutput" class="code-output">// Upload or select a GIF and click "Convert GIF" to see the result
// Example output will appear here in C/C++ array format
// Perfect for Arduino, ESP32, STM32, and other microcontrollers</pre>
</div>
</div>
<!-- ── FOOTER ── -->
<footer class="site-footer">
<div class="footer-brand">Made with ❤️ by Surya.S</div>
<p class="footer-tagline">Professional GIF → C/C++ Converter for Embedded Systems</p>
<div class="footer-links">
<a href="https://instagram.com/sparky.fpv" target="_blank" rel="noopener" class="social-btn instagram">
<i class="bi bi-instagram"></i> Instagram
</a>
<a href="https://www.youtube.com/@sparky.390" target="_blank" rel="noopener" class="social-btn youtube">
<i class="bi bi-youtube"></i> YouTube
</a>
<a href="https://github.com/sparky390" target="_blank" rel="noopener" class="social-btn github">
<i class="bi bi-github"></i> GitHub
</a>
</div>
<p class="footer-heart">
Made for developers who build hardware
</p>
</footer>
</div><!-- /.main-wrapper -->
<!-- ── SCRIPTS ── -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/buzzfeed/libgif-js@master/libgif.js"></script>
<script src="assets/js/app.js"></script>
</body>
</html>