Devankkkk commited on
Commit
cd490cb
·
verified ·
1 Parent(s): 26580ae

Please make it fully functional and I can upload images from my gallery and the website can create brand visuals and place products in the images suggested

Browse files
Files changed (1) hide show
  1. index.html +155 -15
index.html CHANGED
@@ -4,11 +4,13 @@
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Aurora Luxe Visualizer</title>
7
- <script src="https://cdn.tailwindcss.com"></script>
 
8
  <script src="https://unpkg.com/feather-icons"></script>
9
  <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
  <script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script>
11
- <style>
 
12
  .hero-bg {
13
  background: linear-gradient(135deg, #F4EDE4 0%, #C9A669 50%, #101010 100%);
14
  }
@@ -34,7 +36,6 @@
34
  </button>
35
  </div>
36
  </nav>
37
-
38
  <!-- Hero Section -->
39
  <section class="hero-bg text-white py-20" id="vanta-bg">
40
  <div class="container mx-auto px-6 text-center">
@@ -45,14 +46,61 @@
45
  <input id="product-upload" type="file" accept="image/*" multiple class="hidden" />
46
  Upload Products
47
  </label>
48
- <button class="border-2 border-white text-white px-8 py-3 rounded-full font-medium hover:bg-white hover:text-amber-600 transition">
49
- View Examples
50
  </button>
51
  </div>
52
  </div>
53
  </section>
54
 
55
- <!-- Features -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  <section class="py-16 bg-gray-50">
57
  <div class="container mx-auto px-6">
58
  <h2 class="text-3xl font-bold text-center mb-12">Precision Visualization</h2>
@@ -170,24 +218,116 @@
170
  </div>
171
  </footer>
172
  <script>
173
- // Handle image uploads
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  document.getElementById('product-upload').addEventListener('change', function(e) {
175
  if (e.target.files.length > 0) {
176
- alert(`Uploading ${e.target.files.length} product images`);
177
- // Here you would typically upload to server
 
 
178
  }
179
  });
180
 
181
- document.getElementById('project-upload').addEventListener('change', function(e) {
182
- if (e.target.files.length > 0) {
183
- alert(`Uploading ${e.target.files.length} project images`);
184
- // Here you would typically upload to server
 
185
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  });
187
 
188
  // Initialize Vanta.js effect
189
- VANTA.GLOBE({
190
- el: "#vanta-bg",
191
  mouseControls: true,
192
  touchControls: true,
193
  gyroControls: false,
 
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Aurora Luxe Visualizer</title>
7
+ <meta name="description" content="Upload your products and create professional brand visuals instantly">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
  <script src="https://unpkg.com/feather-icons"></script>
10
  <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
11
  <script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script>
12
+ <script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
13
+ <style>
14
  .hero-bg {
15
  background: linear-gradient(135deg, #F4EDE4 0%, #C9A669 50%, #101010 100%);
16
  }
 
36
  </button>
37
  </div>
38
  </nav>
 
39
  <!-- Hero Section -->
40
  <section class="hero-bg text-white py-20" id="vanta-bg">
41
  <div class="container mx-auto px-6 text-center">
 
46
  <input id="product-upload" type="file" accept="image/*" multiple class="hidden" />
47
  Upload Products
48
  </label>
49
+ <button class="border-2 border-white text-white px-8 py-3 rounded-full font-medium hover:bg-white hover:text-amber-600 transition" id="generate-btn">
50
+ Generate Visuals
51
  </button>
52
  </div>
53
  </div>
54
  </section>
55
 
56
+ <!-- Visualization Canvas -->
57
+ <section class="py-16 bg-gray-50">
58
+ <div class="container mx-auto px-6">
59
+ <h2 class="text-3xl font-bold text-center mb-12">Your Visualizations</h2>
60
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-8" id="visualization-container">
61
+ <div class="bg-white p-6 rounded-lg shadow-md">
62
+ <div class="relative h-64 w-full bg-gray-200 rounded-md mb-4" id="canvas-container">
63
+ <img id="background-canvas" class="absolute inset-0 w-full h-full object-cover rounded-md" style="display: none;">
64
+ <img id="product-canvas" class="absolute inset-0 w-full h-full object-contain rounded-md" style="display: none;">
65
+ <div class="absolute inset-0 flex items-center justify-center text-gray-500">
66
+ Your visualization will appear here
67
+ </div>
68
+ </div>
69
+ <div class="flex flex-wrap gap-2 mb-4" id="background-options"></div>
70
+ <div class="flex space-x-2">
71
+ <button class="bg-amber-500 text-white px-4 py-2 rounded hover:bg-amber-600" id="download-btn">
72
+ <i data-feather="download" class="w-4 h-4 mr-1"></i> Download
73
+ </button>
74
+ <button class="border border-gray-300 text-gray-700 px-4 py-2 rounded hover:bg-gray-100" id="new-visual-btn">
75
+ <i data-feather="refresh-cw" class="w-4 h-4 mr-1"></i> New Visual
76
+ </button>
77
+ </div>
78
+ </div>
79
+ <div class="bg-white p-6 rounded-lg shadow-md">
80
+ <h3 class="text-xl font-bold mb-4">Customize Placement</h3>
81
+ <div class="space-y-4">
82
+ <div>
83
+ <label class="block text-gray-700 mb-2">Product Size</label>
84
+ <input type="range" id="product-size" min="0.1" max="1" step="0.1" value="0.5" class="w-full">
85
+ </div>
86
+ <div>
87
+ <label class="block text-gray-700 mb-2">Rotation</label>
88
+ <input type="range" id="product-rotation" min="0" max="360" step="1" value="0" class="w-full">
89
+ </div>
90
+ <div>
91
+ <label class="block text-gray-700 mb-2">Position X</label>
92
+ <input type="range" id="product-x" min="0" max="100" step="1" value="50" class="w-full">
93
+ </div>
94
+ <div>
95
+ <label class="block text-gray-700 mb-2">Position Y</label>
96
+ <input type="range" id="product-y" min="0" max="100" step="1" value="50" class="w-full">
97
+ </div>
98
+ </div>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ </section>
103
+ <!-- Features -->
104
  <section class="py-16 bg-gray-50">
105
  <div class="container mx-auto px-6">
106
  <h2 class="text-3xl font-bold text-center mb-12">Precision Visualization</h2>
 
218
  </div>
219
  </footer>
220
  <script>
221
+ // Global variables
222
+ let productImage = null;
223
+ let currentBackground = null;
224
+ const UNSPLASH_ACCESS_KEY = 'YOUR_UNSPLASH_ACCESS_KEY'; // Replace with your Unsplash key
225
+
226
+ // Get background images from Unsplash
227
+ async function getBackgroundImages(query = 'luxury') {
228
+ try {
229
+ const response = await fetch(`https://api.unsplash.com/search/photos?page=1&query=${query}&client_id=${UNSPLASH_ACCESS_KEY}`);
230
+ const data = await response.json();
231
+ return data.results;
232
+ } catch (error) {
233
+ console.error('Error fetching backgrounds:', error);
234
+ return [];
235
+ }
236
+ }
237
+
238
+ // Display background options
239
+ async function showBackgroundOptions() {
240
+ const backgrounds = await getBackgroundImages();
241
+ const container = document.getElementById('background-options');
242
+ container.innerHTML = '';
243
+
244
+ backgrounds.forEach((bg, index) => {
245
+ const img = document.createElement('img');
246
+ img.src = bg.urls.small;
247
+ img.alt = bg.alt_description || 'Background option';
248
+ img.dataset.fullUrl = bg.urls.regular;
249
+ img.className = 'w-20 h-20 object-cover rounded-md cursor-pointer hover:ring-2 hover:ring-amber-500';
250
+ img.addEventListener('click', () => setBackground(bg.urls.regular));
251
+ container.appendChild(img);
252
+ });
253
+ }
254
+
255
+ // Set background image
256
+ function setBackground(url) {
257
+ currentBackground = url;
258
+ const bgCanvas = document.getElementById('background-canvas');
259
+ bgCanvas.src = url;
260
+ bgCanvas.style.display = 'block';
261
+ }
262
+
263
+ // Handle product upload
264
  document.getElementById('product-upload').addEventListener('change', function(e) {
265
  if (e.target.files.length > 0) {
266
+ productImage = URL.createObjectURL(e.target.files[0]);
267
+ const productCanvas = document.getElementById('product-canvas');
268
+ productCanvas.src = productImage;
269
+ productCanvas.style.display = 'block';
270
  }
271
  });
272
 
273
+ // Generate visualization
274
+ document.getElementById('generate-btn').addEventListener('click', async function() {
275
+ if (!productImage) {
276
+ alert('Please upload a product image first');
277
+ return;
278
  }
279
+ await showBackgroundOptions();
280
+
281
+ // Apply default positioning
282
+ updateProductPosition();
283
+ });
284
+
285
+ // Update product position based on controls
286
+ function updateProductPosition() {
287
+ const productCanvas = document.getElementById('product-canvas');
288
+ if (!productCanvas) return;
289
+
290
+ const size = document.getElementById('product-size').value;
291
+ const rotation = document.getElementById('product-rotation').value;
292
+ const x = document.getElementById('product-x').value;
293
+ const y = document.getElementById('product-y').value;
294
+
295
+ productCanvas.style.transform = `translate(-50%, -50%) rotate(${rotation}deg) scale(${size})`;
296
+ productCanvas.style.left = `${x}%`;
297
+ productCanvas.style.top = `${y}%`;
298
+ }
299
+
300
+ // Add event listeners to control sliders
301
+ ['product-size', 'product-rotation', 'product-x', 'product-y'].forEach(id => {
302
+ document.getElementById(id).addEventListener('input', updateProductPosition);
303
+ });
304
+
305
+ // Download visualization
306
+ document.getElementById('download-btn').addEventListener('click', function() {
307
+ if (!productImage || !currentBackground) {
308
+ alert('Please generate a visualization first');
309
+ return;
310
+ }
311
+
312
+ const container = document.getElementById('canvas-container');
313
+ html2canvas(container).then(canvas => {
314
+ const link = document.createElement('a');
315
+ link.download = 'aurora-luxe-visualization.png';
316
+ link.href = canvas.toDataURL('image/png');
317
+ link.click();
318
+ });
319
+ });
320
+
321
+ // New visualization
322
+ document.getElementById('new-visual-btn').addEventListener('click', function() {
323
+ document.getElementById('background-options').innerHTML = '';
324
+ document.getElementById('background-canvas').style.display = 'none';
325
+ document.getElementById('product-canvas').style.display = 'none';
326
  });
327
 
328
  // Initialize Vanta.js effect
329
+ VANTA.GLOBE({
330
+ el: "#vanta-bg",
331
  mouseControls: true,
332
  touchControls: true,
333
  gyroControls: false,