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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>Artisan Image Studio</title>
|
| 7 |
+
<style>
|
| 8 |
+
:root {
|
| 9 |
+
--primary-color: #6366f1;
|
| 10 |
+
--primary-hover: #4f46e5;
|
| 11 |
+
--bg-color: #0f172a;
|
| 12 |
+
--card-bg: #1e293b;
|
| 13 |
+
--text-main: #f8fafc;
|
| 14 |
+
--text-muted: #94a3b8;
|
| 15 |
+
--border-color: #334155;
|
| 16 |
+
--success-color: #10b981;
|
| 17 |
+
}
|
| 18 |
|
| 19 |
+
* {
|
| 20 |
+
box-sizing: border-box;
|
| 21 |
+
margin: 0;
|
| 22 |
+
padding: 0;
|
| 23 |
+
}
|
| 24 |
|
| 25 |
+
body {
|
| 26 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 27 |
+
background-color: var(--bg-color);
|
| 28 |
+
color: var(--text-main);
|
| 29 |
+
line-height: 1.6;
|
| 30 |
+
display: flex;
|
| 31 |
+
flex-direction: column;
|
| 32 |
+
min-height: 100vh;
|
| 33 |
+
}
|
| 34 |
|
| 35 |
+
/* Header & Footer */
|
| 36 |
+
header {
|
| 37 |
+
background-color: var(--card-bg);
|
| 38 |
+
padding: 1rem 2rem;
|
| 39 |
+
border-bottom: 1px solid var(--border-color);
|
| 40 |
+
display: flex;
|
| 41 |
+
justify-content: space-between;
|
| 42 |
+
align-items: center;
|
| 43 |
+
}
|
| 44 |
|
| 45 |
+
h1 {
|
| 46 |
+
font-size: 1.5rem;
|
| 47 |
+
font-weight: 700;
|
| 48 |
+
color: var(--primary-color);
|
| 49 |
+
display: flex;
|
| 50 |
+
align-items: center;
|
| 51 |
+
gap: 10px;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.footer-link {
|
| 55 |
+
font-size: 0.9rem;
|
| 56 |
+
color: var(--text-muted);
|
| 57 |
+
text-decoration: none;
|
| 58 |
+
transition: color 0.3s;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
.footer-link:hover {
|
| 62 |
+
color: var(--primary-color);
|
| 63 |
+
text-decoration: underline;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
main {
|
| 67 |
+
flex: 1;
|
| 68 |
+
display: grid;
|
| 69 |
+
grid-template-columns: 350px 1fr;
|
| 70 |
+
gap: 2rem;
|
| 71 |
+
padding: 2rem;
|
| 72 |
+
max-width: 1400px;
|
| 73 |
+
margin: 0 auto;
|
| 74 |
+
width: 100%;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/* Sidebar Controls */
|
| 78 |
+
.controls-panel {
|
| 79 |
+
background-color: var(--card-bg);
|
| 80 |
+
padding: 2rem;
|
| 81 |
+
border-radius: 1rem;
|
| 82 |
+
border: 1px solid var(--border-color);
|
| 83 |
+
height: fit-content;
|
| 84 |
+
display: flex;
|
| 85 |
+
flex-direction: column;
|
| 86 |
+
gap: 2rem;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
.control-group {
|
| 90 |
+
display: flex;
|
| 91 |
+
flex-direction: column;
|
| 92 |
+
gap: 0.5rem;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
label {
|
| 96 |
+
font-size: 0.9rem;
|
| 97 |
+
font-weight: 600;
|
| 98 |
+
color: var(--text-muted);
|
| 99 |
+
text-transform: uppercase;
|
| 100 |
+
letter-spacing: 0.5px;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
/* File Input Styling */
|
| 104 |
+
.file-upload-area {
|
| 105 |
+
border: 2px dashed var(--border-color);
|
| 106 |
+
border-radius: 0.75rem;
|
| 107 |
+
padding: 2rem;
|
| 108 |
+
text-align: center;
|
| 109 |
+
cursor: pointer;
|
| 110 |
+
transition: all 0.3s ease;
|
| 111 |
+
position: relative;
|
| 112 |
+
background-color: rgba(255,255,255,0.02);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
.file-upload-area:hover {
|
| 116 |
+
border-color: var(--primary-color);
|
| 117 |
+
background-color: rgba(99, 102, 241, 0.1);
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
input[type="file"] {
|
| 121 |
+
position: absolute;
|
| 122 |
+
top: 0;
|
| 123 |
+
left: 0;
|
| 124 |
+
width: 100%;
|
| 125 |
+
height: 100%;
|
| 126 |
+
opacity: 0;
|
| 127 |
+
cursor: pointer;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
.upload-icon {
|
| 131 |
+
font-size: 3rem;
|
| 132 |
+
color: var(--primary-color);
|
| 133 |
+
margin-bottom: 1rem;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
/* Sliders */
|
| 137 |
+
.range-container {
|
| 138 |
+
display: flex;
|
| 139 |
+
align-items: center;
|
| 140 |
+
gap: 1rem;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
input[type="range"] {
|
| 144 |
+
flex: 1;
|
| 145 |
+
height: 6px;
|
| 146 |
+
background: var(--border-color);
|
| 147 |
+
border-radius: 5px;
|
| 148 |
+
appearance: none;
|
| 149 |
+
cursor: pointer;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
input[type="range"]::-webkit-slider-thumb {
|
| 153 |
+
appearance: none;
|
| 154 |
+
width: 20px;
|
| 155 |
+
height: 20px;
|
| 156 |
+
background: var(--primary-color);
|
| 157 |
+
border-radius: 50%;
|
| 158 |
+
cursor: pointer;
|
| 159 |
+
transition: transform 0.2s;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
input[type="range"]::-webkit-slider-thumb:hover {
|
| 163 |
+
transform: scale(1.2);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
.value-display {
|
| 167 |
+
font-family: monospace;
|
| 168 |
+
font-size: 1.2rem;
|
| 169 |
+
color: var(--primary-color);
|
| 170 |
+
width: 50px;
|
| 171 |
+
text-align: right;
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
/* Buttons */
|
| 175 |
+
.action-btn {
|
| 176 |
+
background-color: var(--primary-color);
|
| 177 |
+
color: white;
|
| 178 |
+
padding: 1rem;
|
| 179 |
+
border: none;
|
| 180 |
+
border-radius: 0.5rem;
|
| 181 |
+
font-size: 1rem;
|
| 182 |
+
font-weight: 600;
|
| 183 |
+
cursor: pointer;
|
| 184 |
+
transition: background-color 0.3s, transform 0.2s;
|
| 185 |
+
width: 100%;
|
| 186 |
+
display: flex;
|
| 187 |
+
justify-content: center;
|
| 188 |
+
align-items: center;
|
| 189 |
+
gap: 0.5rem;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
.action-btn:hover {
|
| 193 |
+
background-color: var(--primary-hover);
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
.action-btn:active {
|
| 197 |
+
transform: scale(0.98);
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
.action-btn:disabled {
|
| 201 |
+
background-color: var(--border-color);
|
| 202 |
+
cursor: not-allowed;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
/* Main Preview Area */
|
| 206 |
+
.preview-area {
|
| 207 |
+
display: flex;
|
| 208 |
+
flex-direction: column;
|
| 209 |
+
align-items: center;
|
| 210 |
+
justify-content: center;
|
| 211 |
+
background-color: var(--bg-color);
|
| 212 |
+
border-radius: 1rem;
|
| 213 |
+
border: 1px solid var(--border-color);
|
| 214 |
+
position: relative;
|
| 215 |
+
overflow: hidden;
|
| 216 |
+
min-height: 500px;
|
| 217 |
+
background-image:
|
| 218 |
+
linear-gradient(var(--border-color) 1px, transparent 1px),
|
| 219 |
+
linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
|
| 220 |
+
background-size: 20px 20px;
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
.canvas-container {
|
| 224 |
+
position: relative;
|
| 225 |
+
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
|
| 226 |
+
max-width: 90%;
|
| 227 |
+
max-height: 80vh;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
canvas {
|
| 231 |
+
display: block;
|
| 232 |
+
max-width: 100%;
|
| 233 |
+
height: auto;
|
| 234 |
+
border-radius: 4px;
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
.placeholder-text {
|
| 238 |
+
position: absolute;
|
| 239 |
+
top: 50%;
|
| 240 |
+
left: 50%;
|
| 241 |
+
transform: translate(-50%, -50%);
|
| 242 |
+
text-align: center;
|
| 243 |
+
color: var(--text-muted);
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
.loader {
|
| 247 |
+
border: 4px solid rgba(255, 255, 255, 0.1);
|
| 248 |
+
border-left-color: var(--primary-color);
|
| 249 |
+
border-radius: 50%;
|
| 250 |
+
width: 40px;
|
| 251 |
+
height: 40px;
|
| 252 |
+
animation: spin 1s linear infinite;
|
| 253 |
+
position: absolute;
|
| 254 |
+
top: 50%;
|
| 255 |
+
left: 50%;
|
| 256 |
+
transform: translate(-50%, -50%);
|
| 257 |
+
display: none;
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
@keyframes spin {
|
| 261 |
+
0% { transform: translate(-50%, -50%) rotate(0deg); }
|
| 262 |
+
100% { transform: translate(-50%, -50%) rotate(360deg); }
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
/* Responsive Design */
|
| 266 |
+
@media (max-width: 768px) {
|
| 267 |
+
main {
|
| 268 |
+
grid-template-columns: 1fr;
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
.controls-panel {
|
| 272 |
+
width: 100%;
|
| 273 |
+
padding: 1.5rem;
|
| 274 |
+
}
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
/* Toast Notification */
|
| 278 |
+
.toast {
|
| 279 |
+
position: fixed;
|
| 280 |
+
bottom: 20px;
|
| 281 |
+
right: 20px;
|
| 282 |
+
background-color: var(--card-bg);
|
| 283 |
+
border-left: 4px solid var(--primary-color);
|
| 284 |
+
padding: 1rem 1.5rem;
|
| 285 |
+
border-radius: 4px;
|
| 286 |
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
|
| 287 |
+
transform: translateY(100px);
|
| 288 |
+
transition: transform 0.3s ease-in-out;
|
| 289 |
+
z-index: 1000;
|
| 290 |
+
display: flex;
|
| 291 |
+
align-items: center;
|
| 292 |
+
gap: 10px;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
.toast.show {
|
| 296 |
+
transform: translateY(0);
|
| 297 |
+
}
|
| 298 |
+
</style>
|
| 299 |
+
<!-- Importing FontAwesome for Icons -->
|
| 300 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 301 |
+
</head>
|
| 302 |
+
<body>
|
| 303 |
+
|
| 304 |
+
<header>
|
| 305 |
+
<h1><i class="fa-solid fa-paint-brush"></i> Artisan Studio</h1>
|
| 306 |
+
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="footer-link">Built with anycoder</a>
|
| 307 |
+
</header>
|
| 308 |
+
|
| 309 |
+
<main>
|
| 310 |
+
<!-- Controls Sidebar -->
|
| 311 |
+
<aside class="controls-panel">
|
| 312 |
+
|
| 313 |
+
<!-- Upload Section -->
|
| 314 |
+
<div class="control-group">
|
| 315 |
+
<label for="imageUpload"><i class="fa-solid fa-cloud-arrow-up"></i> 1. Upload Source Image</label>
|
| 316 |
+
<div class="file-upload-area" id="dropZone">
|
| 317 |
+
<input type="file" id="imageUpload" accept="image/*">
|
| 318 |
+
<i class="fa-solid fa-image upload-icon"></i>
|
| 319 |
+
<p>Click to upload or drag & drop</p>
|
| 320 |
+
<p style="font-size: 0.8rem; margin-top: 0.5rem; color: var(--text-muted)">Supported: JPG, PNG, WEBP</p>
|
| 321 |
+
</div>
|
| 322 |
+
</div>
|
| 323 |
+
|
| 324 |
+
<!-- Settings Section -->
|
| 325 |
+
<div class="control-group">
|
| 326 |
+
<label><i class="fa-solid fa-sliders"></i> 2. Processing Options</label>
|
| 327 |
+
|
| 328 |
+
<div class="control-group" style="margin-top: 1rem;">
|
| 329 |
+
<label for="detailLevel">Detail Enhancement</label>
|
| 330 |
+
<div class="range-container">
|
| 331 |
+
<input type="range" id="detailLevel" min="0" max="100" value="50">
|
| 332 |
+
<span class="value-display" id="detailValue">50%</span>
|
| 333 |
+
</div>
|
| 334 |
+
</div>
|
| 335 |
+
|
| 336 |
+
<div class="control-group" style="margin-top: 1rem;">
|
| 337 |
+
<label for="styleIntensity">Style Intensity</label>
|
| 338 |
+
<div class="range-container">
|
| 339 |
+
<input type="range" id="styleIntensity" min="0" max="100" value="30">
|
| 340 |
+
<span class="value-display" id="styleValue">30%</span>
|
| 341 |
+
</div>
|
| 342 |
+
</div>
|
| 343 |
+
|
| 344 |
+
<div class="control-group" style="margin-top: 1rem;">
|
| 345 |
+
<label for="outputFormat">Output Format</label>
|
| 346 |
+
<select id="outputFormat" style="padding: 0.5rem; background: var(--bg-color); color: var(--text-main); border: 1px solid var(--border-color); border-radius: 0.5rem;">
|
| 347 |
+
<option value="png">PNG (High Quality)</option>
|
| 348 |
+
<option value="jpeg">JPEG (Optimized)</option>
|
| 349 |
+
<option value="webp">WEBP (Compressed)</option>
|
| 350 |
+
</select>
|
| 351 |
+
</div>
|
| 352 |
+
</div>
|
| 353 |
+
|
| 354 |
+
<!-- Action Section -->
|
| 355 |
+
<button id="processBtn" class="action-btn" disabled>
|
| 356 |
+
<i class="fa-solid fa-wand-magic-sparkles"></i> Apply Effects
|
| 357 |
+
</button>
|
| 358 |
+
|
| 359 |
+
<button id="downloadBtn" class="action-btn" style="background-color: var(--success-color);" disabled>
|
| 360 |
+
<i class="fa-solid fa-download"></i> Download Result
|
| 361 |
+
</button>
|
| 362 |
+
|
| 363 |
+
</aside>
|
| 364 |
+
|
| 365 |
+
<!-- Main Preview Area -->
|
| 366 |
+
<section class="preview-area" id="previewArea">
|
| 367 |
+
<div class="loader" id="loader"></div>
|
| 368 |
+
<div class="placeholder-text" id="placeholderText">
|
| 369 |
+
<i class="fa-solid fa-image" style="font-size: 4rem; margin-bottom: 1rem; opacity: 0.5;"></i>
|
| 370 |
+
<h3>No Image Loaded</h3>
|
| 371 |
+
<p style="margin-top: 0.5rem">Upload an image to begin editing</p>
|
| 372 |
+
</div>
|
| 373 |
+
|
| 374 |
+
<div class="canvas-container" id="canvasContainer" style="display: none;">
|
| 375 |
+
<canvas id="imageCanvas"></canvas>
|
| 376 |
+
</div>
|
| 377 |
+
</section>
|
| 378 |
+
</main>
|
| 379 |
+
|
| 380 |
+
<div class="toast" id="toast">
|
| 381 |
+
<i class="fa-solid fa-check-circle" style="color: var(--success-color);"></i>
|
| 382 |
+
<span id="toastMessage">Action Successful</span>
|
| 383 |
+
</div>
|
| 384 |
+
|
| 385 |
+
<script>
|
| 386 |
+
// DOM Elements
|
| 387 |
+
const imageUpload = document.getElementById('imageUpload');
|
| 388 |
+
const dropZone = document.getElementById('dropZone');
|
| 389 |
+
const processBtn = document.getElementById('processBtn');
|
| 390 |
+
const downloadBtn = document.getElementById('downloadBtn');
|
| 391 |
+
const detailSlider = document.getElementById('detailLevel');
|
| 392 |
+
const styleSlider = document.getElementById('styleIntensity');
|
| 393 |
+
const detailValue = document.getElementById('detailValue');
|
| 394 |
+
const styleValue = document.getElementById('styleValue');
|
| 395 |
+
const previewArea = document.getElementById('previewArea');
|
| 396 |
+
const placeholderText = document.getElementById('placeholderText');
|
| 397 |
+
const canvasContainer = document.getElementById('canvasContainer');
|
| 398 |
+
const canvas = document.getElementById('imageCanvas');
|
| 399 |
+
const ctx = canvas.getContext('2d');
|
| 400 |
+
const loader = document.getElementById('loader');
|
| 401 |
+
const toast = document.getElementById('toast');
|
| 402 |
+
const toastMessage = document.getElementById('toastMessage');
|
| 403 |
+
const outputFormat = document.getElementById('outputFormat');
|
| 404 |
+
|
| 405 |
+
// State
|
| 406 |
+
let currentImage = null;
|
| 407 |
+
let isProcessing = false;
|
| 408 |
+
|
| 409 |
+
// Event Listeners for Sliders
|
| 410 |
+
detailSlider.addEventListener('input', (e) => {
|
| 411 |
+
detailValue.textContent = `${e.target.value}%`;
|
| 412 |
+
});
|
| 413 |
+
|
| 414 |
+
styleSlider.addEventListener('input', (e) => {
|
| 415 |
+
styleValue.textContent = `${e.target.value}%`;
|
| 416 |
+
});
|
| 417 |
+
|
| 418 |
+
// Drag and Drop Logic
|
| 419 |
+
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
|
| 420 |
+
dropZone.addEventListener(eventName, preventDefaults, false);
|
| 421 |
+
});
|
| 422 |
+
|
| 423 |
+
function preventDefaults(e) {
|
| 424 |
+
e.preventDefault();
|
| 425 |
+
e.stopPropagation();
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
dropZone.addEventListener('dragover', () => {
|
| 429 |
+
dropZone.style.borderColor = 'var(--primary-color)';
|
| 430 |
+
dropZone.style.backgroundColor = 'rgba(99, 102, 241, 0.1)';
|
| 431 |
+
});
|
| 432 |
+
|
| 433 |
+
dropZone.addEventListener('dragleave', () => {
|
| 434 |
+
dropZone.style.borderColor = 'var(--border-color)';
|
| 435 |
+
dropZone.style.backgroundColor = 'rgba(255,255,255,0.02)';
|
| 436 |
+
});
|
| 437 |
+
|
| 438 |
+
dropZone.addEventListener('drop', (e) => {
|
| 439 |
+
const files = e.dataTransfer.files;
|
| 440 |
+
if (files.length > 0) {
|
| 441 |
+
handleFiles(files[0]);
|
| 442 |
+
}
|
| 443 |
+
});
|
| 444 |
+
|
| 445 |
+
imageUpload.addEventListener('change', (e) => {
|
| 446 |
+
if (e.target.files.length > 0) {
|
| 447 |
+
handleFiles(e.target.files[0]);
|
| 448 |
+
}
|
| 449 |
+
});
|
| 450 |
+
|
| 451 |
+
function handleFiles(file) {
|
| 452 |
+
if (!file.type.startsWith('image/')) {
|
| 453 |
+
showToast('Please upload a valid image file.', 'error');
|
| 454 |
+
return;
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
const reader = new FileReader();
|
| 458 |
+
reader.onload = (e) => {
|
| 459 |
+
const img = new Image();
|
| 460 |
+
img.onload = () => {
|
| 461 |
+
// Initialize Canvas
|
| 462 |
+
canvas.width = img.width;
|
| 463 |
+
canvas.height = img.height;
|
| 464 |
+
ctx.drawImage(img, 0, 0);
|
| 465 |
+
currentImage = img;
|
| 466 |
+
|
| 467 |
+
// Update UI
|
| 468 |
+
placeholderText.style.display = 'none';
|
| 469 |
+
canvasContainer.style.display = 'block';
|
| 470 |
+
processBtn.disabled = false;
|
| 471 |
+
downloadBtn.disabled = true; // Disable download until processed at least once
|
| 472 |
+
showToast('Image loaded successfully');
|
| 473 |
+
};
|
| 474 |
+
img.src = e.target.result;
|
| 475 |
+
};
|
| 476 |
+
reader.readAsDataURL(file);
|
| 477 |
+
}
|
| 478 |
+
|
| 479 |
+
// Processing Logic (Simulation)
|
| 480 |
+
processBtn.addEventListener('click', () => {
|
| 481 |
+
if (!currentImage || isProcessing) return;
|
| 482 |
+
|
| 483 |
+
isProcessing = true;
|
| 484 |
+
processBtn.disabled = true;
|
| 485 |
+
processBtn.innerHTML = '<i class="fa-solid fa-circle-notch fa-spin"></i> Processing...';
|
| 486 |
+
loader.style.display = 'block';
|
| 487 |
+
|
| 488 |
+
// Simulate processing delay
|
| 489 |
+
setTimeout(() => {
|
| 490 |
+
// Apply a "Filter" effect (Sepia + Contrast for demo purposes)
|
| 491 |
+
// In a real app, this would connect to a backend API
|
| 492 |
+
const detail = parseInt(detailSlider.value);
|
| 493 |
+
const style = parseInt(styleSlider.value);
|
| 494 |
+
|
| 495 |
+
// Clear canvas
|
| 496 |
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
| 497 |
+
|
| 498 |
+
// Draw original
|
| 499 |
+
ctx.drawImage(currentImage, 0, 0);
|
| 500 |
+
|
| 501 |
+
// Apply simulated filters based on sliders
|
| 502 |
+
// Note: This is purely visual simulation for the frontend
|
| 503 |
+
ctx.globalCompositeOperation = 'overlay';
|
| 504 |
+
|
| 505 |
+
// Create a gradient overlay based on style intensity
|
| 506 |
+
const gradient = ctx.createLinearGradient(0, 0, canvas.width, canvas.height);
|
| 507 |
+
gradient.addColorStop(0, `rgba(99, 102, 241, ${style / 200})`); // Primary color tint
|
| 508 |
+
gradient.addColorStop(1, `rgba(236, 72, 153, ${style / 200})`); // Accent tint
|
| 509 |
+
|
| 510 |
+
ctx.fillStyle = gradient;
|
| 511 |
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
| 512 |
+
|
| 513 |
+
// Adjust brightness/contrast based on detail slider
|
| 514 |
+
ctx.filter = `contrast(${1 + (detail / 200)}) brightness(${1 + (detail / 300)})`;
|
| 515 |
+
ctx.drawImage(canvas, 0, 0); // Re-draw on top of filter
|
| 516 |
+
ctx.filter = 'none'; // Reset filter
|
| 517 |
+
|
| 518 |
+
ctx.globalCompositeOperation = 'source-over';
|
| 519 |
+
|
| 520 |
+
processBtn.disabled = false;
|
| 521 |
+
processBtn.innerHTML = '<i class="fa-solid fa-wand-magic-sparkles"></i> Re-Apply Effects';
|
| 522 |
+
downloadBtn.disabled = false;
|
| 523 |
+
loader.style.display = 'none';
|
| 524 |
+
isProcessing = false;
|
| 525 |
+
showToast('Image processing complete!');
|
| 526 |
+
}, 1500);
|
| 527 |
+
});
|
| 528 |
+
|
| 529 |
+
// Download Logic
|
| 530 |
+
downloadBtn.addEventListener('click', () => {
|
| 531 |
+
if (!canvas.toDataURL()) return;
|
| 532 |
+
|
| 533 |
+
const link = document.createElement('a');
|
| 534 |
+
link.download = `edited-image.${outputFormat.value}`;
|
| 535 |
+
link.href = canvas.toDataURL(`image/${outputFormat.value}`);
|
| 536 |
+
link.click();
|
| 537 |
+
showToast('Download started');
|
| 538 |
+
});
|
| 539 |
+
|
| 540 |
+
// Toast Notification System
|
| 541 |
+
function showToast(message, type = 'success') {
|
| 542 |
+
toastMessage.textContent = message;
|
| 543 |
+
if (type === 'error') {
|
| 544 |
+
toast.style.borderLeftColor = '#ef4444';
|
| 545 |
+
toast.querySelector('i').style.color = '#ef4444';
|
| 546 |
+
} else {
|
| 547 |
+
toast.style.borderLeftColor = 'var(--success-color)';
|
| 548 |
+
toast.querySelector('i').style.color = 'var(--success-color)';
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
+
toast.classList.add('show');
|
| 552 |
+
|
| 553 |
+
setTimeout(() => {
|
| 554 |
+
toast.classList.remove('show');
|
| 555 |
+
}, 3000);
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
// Initialize
|
| 559 |
+
showToast('Welcome to Artisan Studio');
|
| 560 |
+
</script>
|
| 561 |
+
</body>
|
| 562 |
+
</html>
|