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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>RGB Spectrum Generator</title>
|
| 7 |
+
<!-- Import FontAwesome for Icons -->
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
|
| 10 |
+
<style>
|
| 11 |
+
:root {
|
| 12 |
+
--bg-color: #0f172a;
|
| 13 |
+
--card-bg: #1e293b;
|
| 14 |
+
--text-primary: #f8fafc;
|
| 15 |
+
--text-secondary: #94a3b8;
|
| 16 |
+
--accent: #3b82f6;
|
| 17 |
+
--accent-hover: #2563eb;
|
| 18 |
+
--border: #334155;
|
| 19 |
+
--success: #10b981;
|
| 20 |
+
--font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
* {
|
| 24 |
+
box-sizing: border-box;
|
| 25 |
+
margin: 0;
|
| 26 |
+
padding: 0;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
body {
|
| 30 |
+
font-family: var(--font-family);
|
| 31 |
+
background-color: var(--bg-color);
|
| 32 |
+
color: var(--text-primary);
|
| 33 |
+
line-height: 1.6;
|
| 34 |
+
min-height: 100vh;
|
| 35 |
+
display: flex;
|
| 36 |
+
flex-direction: column;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/* Header */
|
| 40 |
+
header {
|
| 41 |
+
background-color: rgba(30, 41, 59, 0.8);
|
| 42 |
+
backdrop-filter: blur(10px);
|
| 43 |
+
border-bottom: 1px solid var(--border);
|
| 44 |
+
padding: 1rem 2rem;
|
| 45 |
+
position: sticky;
|
| 46 |
+
top: 0;
|
| 47 |
+
z-index: 100;
|
| 48 |
+
display: flex;
|
| 49 |
+
justify-content: space-between;
|
| 50 |
+
align-items: center;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
.brand {
|
| 54 |
+
display: flex;
|
| 55 |
+
align-items: center;
|
| 56 |
+
gap: 12px;
|
| 57 |
+
font-size: 1.25rem;
|
| 58 |
+
font-weight: 700;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
.brand i {
|
| 62 |
+
color: var(--accent);
|
| 63 |
+
font-size: 1.5rem;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.anycoder-link {
|
| 67 |
+
font-size: 0.9rem;
|
| 68 |
+
color: var(--text-secondary);
|
| 69 |
+
text-decoration: none;
|
| 70 |
+
padding: 0.5rem 1rem;
|
| 71 |
+
border: 1px solid var(--border);
|
| 72 |
+
border-radius: 6px;
|
| 73 |
+
transition: all 0.3s ease;
|
| 74 |
+
display: flex;
|
| 75 |
+
align-items: center;
|
| 76 |
+
gap: 8px;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
.anycoder-link:hover {
|
| 80 |
+
color: var(--accent);
|
| 81 |
+
border-color: var(--accent);
|
| 82 |
+
background-color: rgba(59, 130, 246, 0.1);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
/* Main Content */
|
| 86 |
+
main {
|
| 87 |
+
flex: 1;
|
| 88 |
+
padding: 2rem;
|
| 89 |
+
max-width: 1600px;
|
| 90 |
+
margin: 0 auto;
|
| 91 |
+
width: 100%;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
.controls {
|
| 95 |
+
display: flex;
|
| 96 |
+
flex-wrap: wrap;
|
| 97 |
+
gap: 1rem;
|
| 98 |
+
margin-bottom: 2rem;
|
| 99 |
+
align-items: center;
|
| 100 |
+
justify-content: space-between;
|
| 101 |
+
background: var(--card-bg);
|
| 102 |
+
padding: 1.5rem;
|
| 103 |
+
border-radius: 12px;
|
| 104 |
+
border: 1px solid var(--border);
|
| 105 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
.control-group {
|
| 109 |
+
display: flex;
|
| 110 |
+
gap: 1rem;
|
| 111 |
+
align-items: center;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
.status-text {
|
| 115 |
+
color: var(--text-secondary);
|
| 116 |
+
font-size: 0.95rem;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
/* Buttons */
|
| 120 |
+
.btn {
|
| 121 |
+
padding: 0.75rem 1.5rem;
|
| 122 |
+
border-radius: 8px;
|
| 123 |
+
font-weight: 600;
|
| 124 |
+
cursor: pointer;
|
| 125 |
+
border: none;
|
| 126 |
+
display: inline-flex;
|
| 127 |
+
align-items: center;
|
| 128 |
+
gap: 8px;
|
| 129 |
+
transition: all 0.2s ease;
|
| 130 |
+
font-size: 0.95rem;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
.btn-primary {
|
| 134 |
+
background-color: var(--accent);
|
| 135 |
+
color: white;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
.btn-primary:hover {
|
| 139 |
+
background-color: var(--accent-hover);
|
| 140 |
+
transform: translateY(-1px);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
.btn-secondary {
|
| 144 |
+
background-color: transparent;
|
| 145 |
+
border: 1px solid var(--border);
|
| 146 |
+
color: var(--text-primary);
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
.btn-secondary:hover {
|
| 150 |
+
background-color: rgba(255, 255, 255, 0.05);
|
| 151 |
+
border-color: var(--text-secondary);
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
.btn:disabled {
|
| 155 |
+
opacity: 0.6;
|
| 156 |
+
cursor: not-allowed;
|
| 157 |
+
transform: none;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
/* Progress Bar */
|
| 161 |
+
.progress-container {
|
| 162 |
+
width: 100%;
|
| 163 |
+
height: 6px;
|
| 164 |
+
background-color: var(--bg-color);
|
| 165 |
+
border-radius: 3px;
|
| 166 |
+
overflow: hidden;
|
| 167 |
+
margin-top: 1rem;
|
| 168 |
+
display: none; /* Hidden by default */
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
.progress-bar {
|
| 172 |
+
height: 100%;
|
| 173 |
+
background-color: var(--success);
|
| 174 |
+
width: 0%;
|
| 175 |
+
transition: width 0.1s linear;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
/* Grid Layout */
|
| 179 |
+
.gallery {
|
| 180 |
+
display: grid;
|
| 181 |
+
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
| 182 |
+
gap: 1.5rem;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
/* Card Design */
|
| 186 |
+
.color-card {
|
| 187 |
+
background-color: var(--card-bg);
|
| 188 |
+
border-radius: 12px;
|
| 189 |
+
overflow: hidden;
|
| 190 |
+
border: 1px solid var(--border);
|
| 191 |
+
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
| 192 |
+
display: flex;
|
| 193 |
+
flex-direction: column;
|
| 194 |
+
animation: fadeIn 0.5s ease forwards;
|
| 195 |
+
opacity: 0;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
@keyframes fadeIn {
|
| 199 |
+
to { opacity: 1; }
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
.color-card:hover {
|
| 203 |
+
transform: translateY(-4px);
|
| 204 |
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
|
| 205 |
+
border-color: var(--accent);
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
.color-preview {
|
| 209 |
+
height: 180px;
|
| 210 |
+
width: 100%;
|
| 211 |
+
position: relative;
|
| 212 |
+
background-image:
|
| 213 |
+
linear-gradient(45deg, #ccc 25%, transparent 25%),
|
| 214 |
+
linear-gradient(-45deg, #ccc 25%, transparent 25%),
|
| 215 |
+
linear-gradient(45deg, transparent 75%, #ccc 75%),
|
| 216 |
+
linear-gradient(-45deg, transparent 75%, #ccc 75%);
|
| 217 |
+
background-size: 20px 20px;
|
| 218 |
+
background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
.color-swatch {
|
| 222 |
+
width: 100%;
|
| 223 |
+
height: 100%;
|
| 224 |
+
display: flex;
|
| 225 |
+
align-items: center;
|
| 226 |
+
justify-content: center;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
.color-info {
|
| 230 |
+
padding: 1rem;
|
| 231 |
+
display: flex;
|
| 232 |
+
flex-direction: column;
|
| 233 |
+
gap: 0.5rem;
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
.color-values {
|
| 237 |
+
font-family: 'Courier New', monospace;
|
| 238 |
+
font-size: 0.85rem;
|
| 239 |
+
color: var(--text-secondary);
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
.filename-label {
|
| 243 |
+
font-weight: 600;
|
| 244 |
+
color: var(--text-primary);
|
| 245 |
+
margin-bottom: 0.5rem;
|
| 246 |
+
font-size: 0.9rem;
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
.card-actions {
|
| 250 |
+
margin-top: 0.5rem;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
.btn-sm {
|
| 254 |
+
padding: 0.4rem 0.8rem;
|
| 255 |
+
font-size: 0.8rem;
|
| 256 |
+
width: 100%;
|
| 257 |
+
justify-content: center;
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
/* Toast Notification */
|
| 261 |
+
.toast {
|
| 262 |
+
position: fixed;
|
| 263 |
+
bottom: 2rem;
|
| 264 |
+
right: 2rem;
|
| 265 |
+
background-color: var(--card-bg);
|
| 266 |
+
border: 1px solid var(--accent);
|
| 267 |
+
color: var(--text-primary);
|
| 268 |
+
padding: 1rem 1.5rem;
|
| 269 |
+
border-radius: 8px;
|
| 270 |
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
|
| 271 |
+
transform: translateY(150%);
|
| 272 |
+
transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
| 273 |
+
z-index: 1000;
|
| 274 |
+
display: flex;
|
| 275 |
+
align-items: center;
|
| 276 |
+
gap: 10px;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
.toast.show {
|
| 280 |
+
transform: translateY(0);
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
.toast i {
|
| 284 |
+
color: var(--success);
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
/* Responsive */
|
| 288 |
+
@media (max-width: 768px) {
|
| 289 |
+
.controls {
|
| 290 |
+
flex-direction: column;
|
| 291 |
+
align-items: stretch;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
.control-group {
|
| 295 |
+
flex-direction: column;
|
| 296 |
+
width: 100%;
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
.btn {
|
| 300 |
+
width: 100%;
|
| 301 |
+
justify-content: center;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
.gallery {
|
| 305 |
+
grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
|
| 306 |
+
}
|
| 307 |
+
}
|
| 308 |
+
</style>
|
| 309 |
+
</head>
|
| 310 |
+
<body>
|
| 311 |
+
|
| 312 |
+
<header>
|
| 313 |
+
<div class="brand">
|
| 314 |
+
<i class="fa-solid fa-palette"></i>
|
| 315 |
+
<span>RGB Spectrum Gen</span>
|
| 316 |
+
</div>
|
| 317 |
+
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">
|
| 318 |
+
<i class="fa-solid fa-code"></i> Built with anycoder
|
| 319 |
+
</a>
|
| 320 |
+
</header>
|
| 321 |
+
|
| 322 |
+
<main>
|
| 323 |
+
<section class="controls">
|
| 324 |
+
<div class="control-group">
|
| 325 |
+
<div>
|
| 326 |
+
<h2 style="margin-bottom: 0.5rem;">Spectrum Generator</h2>
|
| 327 |
+
<p class="status-text" id="statusText">Ready to generate 500 unique shades.</p>
|
| 328 |
+
</div>
|
| 329 |
+
</div>
|
| 330 |
+
|
| 331 |
+
<div class="control-group">
|
| 332 |
+
<button id="generateBtn" class="btn btn-primary">
|
| 333 |
+
<i class="fa-solid fa-wand-magic-sparkles"></i> Generate Images
|
| 334 |
+
</button>
|
| 335 |
+
<button id="downloadAllBtn" class="btn btn-secondary" disabled>
|
| 336 |
+
<i class="fa-solid fa-download"></i> Download All
|
| 337 |
+
</button>
|
| 338 |
+
</div>
|
| 339 |
+
|
| 340 |
+
<div class="progress-container" id="progressContainer">
|
| 341 |
+
<div class="progress-bar" id="progressBar"></div>
|
| 342 |
+
</div>
|
| 343 |
+
</section>
|
| 344 |
+
|
| 345 |
+
<section id="gallery" class="gallery">
|
| 346 |
+
<!-- Images will be injected here -->
|
| 347 |
+
</section>
|
| 348 |
+
</main>
|
| 349 |
+
|
| 350 |
+
<div id="toast" class="toast">
|
| 351 |
+
<i class="fa-solid fa-circle-check"></i>
|
| 352 |
+
<span id="toastMessage">Operation successful</span>
|
| 353 |
+
</div>
|
| 354 |
+
|
| 355 |
+
<script>
|
| 356 |
+
/**
|
| 357 |
+
* RGB Spectrum Generator
|
| 358 |
+
* Uses HTML5 Canvas to generate 256x256 PNGs
|
| 359 |
+
*/
|
| 360 |
+
|
| 361 |
+
const CONFIG = {
|
| 362 |
+
count: 500,
|
| 363 |
+
width: 256,
|
| 364 |
+
height: 256,
|
| 365 |
+
delayBetweenDownloads: 150, // ms to prevent browser blocking
|
| 366 |
+
};
|
| 367 |
+
|
| 368 |
+
const elements = {
|
| 369 |
+
gallery: document.getElementById('gallery'),
|
| 370 |
+
generateBtn: document.getElementById('generateBtn'),
|
| 371 |
+
downloadAllBtn: document.getElementById('downloadAllBtn'),
|
| 372 |
+
statusText: document.getElementById('statusText'),
|
| 373 |
+
progressBar: document.getElementById('progressBar'),
|
| 374 |
+
progressContainer: document.getElementById('progressContainer'),
|
| 375 |
+
toast: document.getElementById('toast'),
|
| 376 |
+
toastMessage: document.getElementById('toastMessage')
|
| 377 |
+
};
|
| 378 |
+
|
| 379 |
+
// Store generated data to avoid re-rendering canvas
|
| 380 |
+
let generatedColors = [];
|
| 381 |
+
|
| 382 |
+
/**
|
| 383 |
+
* Convert HSL to RGB object
|
| 384 |
+
* h, s, l are in [0, 1]
|
| 385 |
+
* returns {r, g, b} in [0, 255]
|
| 386 |
+
*/
|
| 387 |
+
function hslToRgb(h, s, l) {
|
| 388 |
+
let r, g, b;
|
| 389 |
+
if (s === 0) {
|
| 390 |
+
r = g = b = l; // achromatic
|
| 391 |
+
} else {
|
| 392 |
+
const hue2rgb = (p, q, t) => {
|
| 393 |
+
if (t < 0) t += 1;
|
| 394 |
+
if (t > 1) t -= 1;
|
| 395 |
+
if (t < 1/6) return p + (q - p) * 6 * t;
|
| 396 |
+
if (t < 1/2) return q;
|
| 397 |
+
if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;
|
| 398 |
+
return p;
|
| 399 |
+
};
|
| 400 |
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
| 401 |
+
const p = 2 * l - q;
|
| 402 |
+
r = hue2rgb(p, q, h + 1/3);
|
| 403 |
+
g = hue2rgb(p, q, h);
|
| 404 |
+
b = hue2rgb(p, q, h - 1/3);
|
| 405 |
+
}
|
| 406 |
+
return {
|
| 407 |
+
r: Math.round(r * 255),
|
| 408 |
+
g: Math.round(g * 255),
|
| 409 |
+
b: Math.round(b * 255)
|
| 410 |
+
};
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
/**
|
| 414 |
+
* Generate Color Palette
|
| 415 |
+
* Creates 500 colors distributed across the spectrum with varying lightness (shades)
|
| 416 |
+
*/
|
| 417 |
+
function generateColorPalette() {
|
| 418 |
+
const colors = [];
|
| 419 |
+
for (let i = 0; i < CONFIG.count; i++) {
|
| 420 |
+
// Distribute Hue evenly 0 -> 1
|
| 421 |
+
const h = i / CONFIG.count;
|
| 422 |
+
|
| 423 |
+
// Oscillate Saturation between 0.6 and 1.0 for vibrancy
|
| 424 |
+
const s = 0.6 + (Math.sin(i * 0.1) * 0.2 + 0.2);
|
| 425 |
+
|
| 426 |
+
// Oscillate Lightness between 0.2 and 0.8 to get shades
|
| 427 |
+
// Using cosine to ensure we start and end reasonably visible
|
| 428 |
+
const l = 0.5 + (Math.cos(i * 0.05) * 0.3);
|
| 429 |
+
|
| 430 |
+
const rgb = hslToRgb(h, s, l);
|
| 431 |
+
|
| 432 |
+
// Create CSS string
|
| 433 |
+
const cssString = `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
|
| 434 |
+
|
| 435 |
+
// Create Filename: rgb(r,g,b).png
|
| 436 |
+
const filename = `rgb(${rgb.r},${rgb.g},${rgb.b}).png`;
|
| 437 |
+
|
| 438 |
+
colors.push({
|
| 439 |
+
rgb: rgb,
|
| 440 |
+
css: cssString,
|
| 441 |
+
filename: filename,
|
| 442 |
+
id: i
|
| 443 |
+
});
|
| 444 |
+
}
|
| 445 |
+
return colors;
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
/**
|
| 449 |
+
* Create a 256x256 PNG Data URL from a color string
|
| 450 |
+
*/
|
| 451 |
+
function createImageDataURL(colorCss) {
|
| 452 |
+
const canvas = document.createElement('canvas');
|
| 453 |
+
canvas.width = CONFIG.width;
|
| 454 |
+
canvas.height = CONFIG.height;
|
| 455 |
+
const ctx = canvas.getContext('2d');
|
| 456 |
+
|
| 457 |
+
// Fill background
|
| 458 |
+
ctx.fillStyle = colorCss;
|
| 459 |
+
ctx.fillRect(0, 0, CONFIG.width, CONFIG.height);
|
| 460 |
+
|
| 461 |
+
return canvas.toDataURL('image/png');
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
/**
|
| 465 |
+
* Render the Grid
|
| 466 |
+
*/
|
| 467 |
+
async function renderGallery() {
|
| 468 |
+
elements.gallery.innerHTML = '';
|
| 469 |
+
elements.statusText.textContent = `Generating ${CONFIG.count} images...`;
|
| 470 |
+
elements.progressContainer.style.display = 'block';
|
| 471 |
+
elements.generateBtn.disabled = true;
|
| 472 |
+
elements.downloadAllBtn.disabled = true;
|
| 473 |
+
|
| 474 |
+
generatedColors = generateColorPalette();
|
| 475 |
+
|
| 476 |
+
// Process in batches to keep UI responsive
|
| 477 |
+
const batchSize = 20;
|
| 478 |
+
let processed = 0;
|
| 479 |
+
|
| 480 |
+
for (let i = 0; i < generatedColors.length; i += batchSize) {
|
| 481 |
+
const batch = generatedColors.slice(i, i + batchSize);
|
| 482 |
+
|
| 483 |
+
const fragment = document.createDocumentFragment();
|
| 484 |
+
|
| 485 |
+
batch.forEach(color => {
|
| 486 |
+
const card = document.createElement('article');
|
| 487 |
+
card.className = 'color-card';
|
| 488 |
+
|
| 489 |
+
// Generate DataURL
|
| 490 |
+
const dataUrl = createImageDataURL(color.css);
|
| 491 |
+
|
| 492 |
+
card.innerHTML = `
|
| 493 |
+
<div class="color-preview">
|
| 494 |
+
<div class="color-swatch" style="background-color: ${color.css};"></div>
|
| 495 |
+
</div>
|
| 496 |
+
<div class="color-info">
|
| 497 |
+
<div class="filename-label">${color.filename}</div>
|
| 498 |
+
<div class="color-values">
|
| 499 |
+
R: ${color.rgb.r} G: ${color.rgb.g} B: ${color.rgb.b}
|
| 500 |
+
</div>
|
| 501 |
+
<div class="card-actions">
|
| 502 |
+
<button class="btn btn-secondary btn-sm" onclick="downloadSingle('${dataUrl}', '${color.filename}')">
|
| 503 |
+
<i class="fa-solid fa-download"></i> Download
|
| 504 |
+
</button>
|
| 505 |
+
</div>
|
| 506 |
+
</div>
|
| 507 |
+
`;
|
| 508 |
+
fragment.appendChild(card);
|
| 509 |
+
});
|
| 510 |
+
|
| 511 |
+
elements.gallery.appendChild(fragment);
|
| 512 |
+
|
| 513 |
+
// Update Progress
|
| 514 |
+
processed += batch.length;
|
| 515 |
+
const percent = (processed / CONFIG.count) * 100;
|
| 516 |
+
elements.progressBar.style.width = `${percent}%`;
|
| 517 |
+
|
| 518 |
+
// Allow UI to breathe
|
| 519 |
+
await new Promise(r => setTimeout(r, 10));
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
+
elements.statusText.textContent = `Generated ${CONFIG.count} images successfully.`;
|
| 523 |
+
elements.generateBtn.disabled = false;
|
| 524 |
+
elements.generateBtn.innerHTML = '<i class="fa-solid fa-rotate-right"></i> Regenerate';
|
| 525 |
+
elements.downloadAllBtn.disabled = false;
|
| 526 |
+
showToast('Images generated successfully!');
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
/**
|
| 530 |
+
* Trigger a single file download
|
| 531 |
+
*/
|
| 532 |
+
window.downloadSingle = function(dataUrl, filename) {
|
| 533 |
+
const a = document.createElement('a');
|
| 534 |
+
a.href = dataUrl;
|
| 535 |
+
a.download = filename;
|
| 536 |
+
document.body.appendChild(a);
|
| 537 |
+
a.click();
|
| 538 |
+
document.body.removeChild(a);
|
| 539 |
+
};
|
| 540 |
+
|
| 541 |
+
/**
|
| 542 |
+
* Download all images with a delay
|
| 543 |
+
*/
|
| 544 |
+
async function downloadAll() {
|
| 545 |
+
if (generatedColors.length === 0) return;
|
| 546 |
+
|
| 547 |
+
elements.downloadAllBtn.disabled = true;
|
| 548 |
+
elements.generateBtn.disabled = true;
|
| 549 |
+
elements.statusText.textContent = 'Downloading images... Please wait.';
|
| 550 |
+
elements.progressContainer.style.display = 'block';
|
| 551 |
+
elements.progressBar.style.width = '0%';
|
| 552 |
+
|
| 553 |
+
// We need to regenerate DataURLs or store them.
|
| 554 |
+
// For efficiency, let's just grab them from the DOM or regenerate on fly.
|
| 555 |
+
// Regenerating is safer to ensure we have the raw data.
|
| 556 |
+
|
| 557 |
+
for (let i = 0; i < generatedColors.length; i++) {
|
| 558 |
+
const color = generatedColors[i];
|
| 559 |
+
const dataUrl = createImageDataURL(color.css);
|
| 560 |
+
|
| 561 |
+
downloadSingle(dataUrl, color.filename);
|
| 562 |
+
|
| 563 |
+
// Update Progress
|
| 564 |
+
const percent = ((i + 1) / generatedColors.length) * 100;
|
| 565 |
+
elements.progressBar.style.width = `${percent}%`;
|
| 566 |
+
|
| 567 |
+
// Delay to prevent browser crash/blocking
|
| 568 |
+
await new Promise(r => setTimeout(r, CONFIG.delayBetweenDownloads));
|
| 569 |
+
}
|
| 570 |
+
|
| 571 |
+
elements.statusText.textContent = 'Download sequence complete.';
|
| 572 |
+
elements.downloadAllBtn.disabled = false;
|
| 573 |
+
elements.generateBtn.disabled = false;
|
| 574 |
+
showToast('Download sequence complete!');
|
| 575 |
+
};
|
| 576 |
+
|
| 577 |
+
/**
|
| 578 |
+
* Show Toast Notification
|
| 579 |
+
*/
|
| 580 |
+
function showToast(msg) {
|
| 581 |
+
elements.toastMessage.textContent = msg;
|
| 582 |
+
elements.toast.classList.add('show');
|
| 583 |
+
setTimeout(() => {
|
| 584 |
+
elements.toast.classList.remove('show');
|
| 585 |
+
}, 3000);
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
// Event Listeners
|
| 589 |
+
elements.generateBtn.addEventListener('click', renderGallery);
|
| 590 |
+
elements.downloadAllBtn.addEventListener('click', downloadAll);
|
| 591 |
+
|
| 592 |
+
</script>
|
| 593 |
+
</body>
|
| 594 |
+
</html>
|