Spaces:
Running
Running
Download index.html from VisionBleuLED/vision-bleu-ai: direct link, hf CLI and curl.
- Browser
- Download file 32.1 kB
-
https://huggingface.co/spaces/VisionBleuLED/vision-bleu-ai/resolve/main/index.html
- Command line
-
hf download hf://spaces/VisionBleuLED/vision-bleu-ai/index.html
-
curl -L -o index.html https://huggingface.co/spaces/VisionBleuLED/vision-bleu-ai/resolve/main/index.html
32.1 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Lumina AI - RGBW Lighting Designer</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/fabric@5.3.1/dist/fabric.min.js"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| .canvas-container { | |
| box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1); | |
| border-radius: 12px; | |
| overflow: hidden; | |
| } | |
| .tool-btn.active { | |
| background-color: #3b82f6; | |
| color: white; | |
| } | |
| .light-preview { | |
| transition: all 0.3s ease; | |
| box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); | |
| } | |
| .light-preview:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); | |
| } | |
| .loading-spinner { | |
| animation: spin 1s linear infinite; | |
| } | |
| @keyframes spin { | |
| 0% { transform: rotate(0deg); } | |
| 100% { transform: rotate(360deg); } | |
| } | |
| .drawing-guide { | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| pointer-events: none; | |
| opacity: 0.7; | |
| } | |
| .led-circle { | |
| border-radius: 50%; | |
| width: 12px; | |
| height: 12px; | |
| display: inline-block; | |
| margin-right: 5px; | |
| } | |
| .color-preview { | |
| width: 24px; | |
| height: 24px; | |
| border-radius: 4px; | |
| display: inline-block; | |
| margin-right: 8px; | |
| border: 1px solid #ddd; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50 min-h-screen"> | |
| <div class="container mx-auto px-4 py-8"> | |
| <!-- Header --> | |
| <header class="mb-8 text-center"> | |
| <h1 class="text-4xl font-bold text-gray-800 mb-2">Lumina AI</h1> | |
| <p class="text-lg text-gray-600">Design RGBW LED lighting for your architectural projects</p> | |
| </header> | |
| <!-- Main App Container --> | |
| <div class="grid grid-cols-1 lg:grid-cols-3 gap-8"> | |
| <!-- Left Panel - Upload & Tools --> | |
| <div class="bg-white p-6 rounded-xl shadow-md"> | |
| <h2 class="text-xl font-semibold mb-4 text-gray-800">1. Upload Property Image</h2> | |
| <!-- Image Upload --> | |
| <div class="mb-6"> | |
| <div class="border-2 border-dashed border-gray-300 rounded-lg p-6 text-center cursor-pointer hover:border-blue-500 transition-colors" id="dropZone"> | |
| <input type="file" id="imageUpload" accept="image/*" class="hidden"> | |
| <div class="flex flex-col items-center justify-center"> | |
| <i class="fas fa-cloud-upload-alt text-4xl text-blue-500 mb-2"></i> | |
| <p class="text-gray-600">Drag & drop your property photo here</p> | |
| <p class="text-sm text-gray-500 mt-1">or click to browse</p> | |
| </div> | |
| </div> | |
| <div class="mt-2 text-sm text-gray-500"> | |
| <p>Supported formats: JPG, PNG (Max 10MB)</p> | |
| </div> | |
| </div> | |
| <!-- Drawing Tools --> | |
| <h2 class="text-xl font-semibold mb-4 text-gray-800">2. Draw LED Elements</h2> | |
| <div class="grid grid-cols-2 gap-2 mb-4"> | |
| <button id="lightbarTool" class="tool-btn p-2 border rounded-md hover:bg-gray-100 active"> | |
| <i class="fas fa-grip-lines" style="color: #ff0000;"></i> RGBW Lightbar (Red) | |
| </button> | |
| <button id="spotTool" class="tool-btn p-2 border rounded-md hover:bg-gray-100"> | |
| <i class="fas fa-circle" style="color: #3b82f6;"></i> RGBW Spot (Blue) | |
| </button> | |
| </div> | |
| <!-- Lighting Parameters --> | |
| <div class="mb-4"> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Lightbar Thickness</label> | |
| <input type="range" id="lightbarThickness" min="2" max="10" value="4" class="w-full"> | |
| </div> | |
| <div class="mb-4"> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Spot Size</label> | |
| <input type="range" id="spotSize" min="8" max="20" value="12" class="w-full"> | |
| </div> | |
| <!-- RGBW Color Controls --> | |
| <h2 class="text-xl font-semibold mb-4 text-gray-800">3. RGBW Color Settings</h2> | |
| <div class="grid grid-cols-2 gap-4 mb-4"> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Red</label> | |
| <input type="range" id="redValue" min="0" max="255" value="255" class="w-full"> | |
| </div> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Green</label> | |
| <input type="range" id="greenValue" min="0" max="255" value="255" class="w-full"> | |
| </div> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Blue</label> | |
| <input type="range" id="blueValue" min="0" max="255" value="255" class="w-full"> | |
| </div> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">White</label> | |
| <input type="range" id="whiteValue" min="0" max="255" value="255" class="w-full"> | |
| </div> | |
| </div> | |
| <div class="mb-6 p-3 bg-gray-100 rounded-lg"> | |
| <div class="flex items-center justify-between"> | |
| <span class="text-sm font-medium">Color Preview:</span> | |
| <span id="rgbwPreview" class="color-preview"></span> | |
| <span class="text-xs text-gray-600" id="rgbwValues">RGBW(255,255,255,255)</span> | |
| </div> | |
| </div> | |
| <!-- Generate Button --> | |
| <button id="generateBtn" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-3 px-4 rounded-lg font-medium transition-colors flex items-center justify-center"> | |
| <i class="fas fa-magic mr-2"></i> Generate Lighting Visualization | |
| </button> | |
| </div> | |
| <!-- Center Panel - Canvas --> | |
| <div class="lg:col-span-2"> | |
| <div class="bg-white p-6 rounded-xl shadow-md"> | |
| <h2 class="text-xl font-semibold mb-4 text-gray-800">Lighting Design Canvas</h2> | |
| <!-- Canvas Container --> | |
| <div class="canvas-container relative"> | |
| <canvas id="designCanvas" width="800" height="600" class="border rounded-lg bg-gray-100 w-full"></canvas> | |
| <div id="drawingGuide" class="drawing-guide"></div> | |
| </div> | |
| <!-- Canvas Controls --> | |
| <div class="flex justify-between mt-4"> | |
| <div> | |
| <button id="clearGuidesBtn" class="px-4 py-2 bg-gray-200 hover:bg-gray-300 rounded-md text-gray-700 mr-2"> | |
| <i class="fas fa-trash-alt mr-1"></i> Clear All | |
| </button> | |
| <button id="undoBtn" class="px-4 py-2 bg-gray-200 hover:bg-gray-300 rounded-md text-gray-700"> | |
| <i class="fas fa-undo mr-1"></i> Undo | |
| </button> | |
| </div> | |
| <div> | |
| <button id="zoomInBtn" class="px-3 py-2 bg-gray-200 hover:bg-gray-300 rounded-md text-gray-700 mr-2"> | |
| <i class="fas fa-search-plus"></i> | |
| </button> | |
| <button id="zoomOutBtn" class="px-3 py-2 bg-gray-200 hover:bg-gray-300 rounded-md text-gray-700"> | |
| <i class="fas fa-search-minus"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Results Section --> | |
| <div id="resultsSection" class="bg-white p-6 rounded-xl shadow-md mt-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-xl font-semibold text-gray-800">Lighting Specifications</h2> | |
| <button id="saveDesignBtn" class="px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-md"> | |
| <i class="fas fa-download mr-1"></i> Export Design | |
| </button> | |
| </div> | |
| <div class="grid grid-cols-1 gap-4" id="resultsContainer"> | |
| <div class="p-4 border rounded-lg"> | |
| <h3 class="font-medium mb-2">RGBW Lightbars</h3> | |
| <div id="lightbarSpecs" class="text-sm text-gray-700"> | |
| <!-- Lightbar specs will appear here --> | |
| <p class="text-gray-500 italic">Draw red lines to specify lightbar positions</p> | |
| </div> | |
| </div> | |
| <div class="p-4 border rounded-lg"> | |
| <h3 class="font-medium mb-2">RGBW Spot Lights</h3> | |
| <div id="spotSpecs" class="text-sm text-gray-700"> | |
| <!-- Spot light specs will appear here --> | |
| <p class="text-gray-500 italic">Draw blue circles to specify spot positions</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Loading Overlay --> | |
| <div id="loadingOverlay" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50"> | |
| <div class="bg-white p-8 rounded-xl max-w-md text-center"> | |
| <div class="flex justify-center mb-4"> | |
| <i class="fas fa-spinner loading-spinner text-4xl text-blue-500"></i> | |
| </div> | |
| <h3 class="text-xl font-semibold mb-2">Generating Lighting Visualization</h3> | |
| <p class="text-gray-600">Calculating light distribution and creating realistic render based on your RGBW specifications.</p> | |
| <div class="w-full bg-gray-200 rounded-full h-2.5 mt-4"> | |
| <div id="progressBar" class="bg-blue-600 h-2.5 rounded-full" style="width: 0%"></div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize Fabric.js canvas | |
| const canvas = new fabric.Canvas('designCanvas'); | |
| let currentTool = 'lightbar'; | |
| let isDrawing = false; | |
| let currentObject = null; | |
| let undoStack = []; | |
| let backgroundImage = null; | |
| // RGBW Values | |
| let red = 255; | |
| let green = 255; | |
| let blue = 255; | |
| let white = 255; | |
| // DOM Elements | |
| const dropZone = document.getElementById('dropZone'); | |
| const imageUpload = document.getElementById('imageUpload'); | |
| const lightbarTool = document.getElementById('lightbarTool'); | |
| const spotTool = document.getElementById('spotTool'); | |
| const lightbarThickness = document.getElementById('lightbarThickness'); | |
| const spotSize = document.getElementById('spotSize'); | |
| const redValue = document.getElementById('redValue'); | |
| const greenValue = document.getElementById('greenValue'); | |
| const blueValue = document.getElementById('blueValue'); | |
| const whiteValue = document.getElementById('whiteValue'); | |
| const rgbwPreview = document.getElementById('rgbwPreview'); | |
| const rgbwValues = document.getElementById('rgbwValues'); | |
| const generateBtn = document.getElementById('generateBtn'); | |
| const clearGuidesBtn = document.getElementById('clearGuidesBtn'); | |
| const undoBtn = document.getElementById('undoBtn'); | |
| const zoomInBtn = document.getElementById('zoomInBtn'); | |
| const zoomOutBtn = document.getElementById('zoomOutBtn'); | |
| const saveDesignBtn = document.getElementById('saveDesignBtn'); | |
| const loadingOverlay = document.getElementById('loadingOverlay'); | |
| const progressBar = document.getElementById('progressBar'); | |
| const lightbarSpecs = document.getElementById('lightbarSpecs'); | |
| const spotSpecs = document.getElementById('spotSpecs'); | |
| // Update RGBW preview | |
| function updateRGBWPreview() { | |
| // Calculate the mixed color (RGB + white) | |
| const r = Math.min(255, red + white); | |
| const g = Math.min(255, green + white); | |
| const b = Math.min(255, blue + white); | |
| rgbwPreview.style.backgroundColor = `rgb(${r},${g},${b})`; | |
| rgbwValues.textContent = `RGBW(${red},${green},${blue},${white})`; | |
| } | |
| // Event listeners for RGBW sliders | |
| redValue.addEventListener('input', function() { | |
| red = parseInt(this.value); | |
| updateRGBWPreview(); | |
| }); | |
| greenValue.addEventListener('input', function() { | |
| green = parseInt(this.value); | |
| updateRGBWPreview(); | |
| }); | |
| blueValue.addEventListener('input', function() { | |
| blue = parseInt(this.value); | |
| updateRGBWPreview(); | |
| }); | |
| whiteValue.addEventListener('input', function() { | |
| white = parseInt(this.value); | |
| updateRGBWPreview(); | |
| }); | |
| // Initialize preview | |
| updateRGBWPreview(); | |
| // Set up tool buttons | |
| lightbarTool.addEventListener('click', function() { | |
| currentTool = 'lightbar'; | |
| lightbarTool.classList.add('active'); | |
| spotTool.classList.remove('active'); | |
| }); | |
| spotTool.addEventListener('click', function() { | |
| currentTool = 'spot'; | |
| spotTool.classList.add('active'); | |
| lightbarTool.classList.remove('active'); | |
| }); | |
| // Handle image upload | |
| dropZone.addEventListener('click', function() { | |
| imageUpload.click(); | |
| }); | |
| dropZone.addEventListener('dragover', function(e) { | |
| e.preventDefault(); | |
| dropZone.classList.add('border-blue-500'); | |
| dropZone.classList.remove('border-gray-300'); | |
| }); | |
| dropZone.addEventListener('dragleave', function() { | |
| dropZone.classList.remove('border-blue-500'); | |
| dropZone.classList.add('border-gray-300'); | |
| }); | |
| dropZone.addEventListener('drop', function(e) { | |
| e.preventDefault(); | |
| dropZone.classList.remove('border-blue-500'); | |
| dropZone.classList.add('border-gray-300'); | |
| if (e.dataTransfer.files.length) { | |
| imageUpload.files = e.dataTransfer.files; | |
| handleImageUpload(); | |
| } | |
| }); | |
| imageUpload.addEventListener('change', handleImageUpload); | |
| function handleImageUpload() { | |
| const file = imageUpload.files[0]; | |
| if (!file) return; | |
| const reader = new FileReader(); | |
| reader.onload = function(e) { | |
| fabric.Image.fromURL(e.target.result, function(img) { | |
| // Clear canvas | |
| canvas.clear(); | |
| // Scale image to fit canvas while maintaining aspect ratio | |
| const scale = Math.min( | |
| canvas.width / img.width, | |
| canvas.height / img.height | |
| ); | |
| img.set({ | |
| left: 0, | |
| top: 0, | |
| scaleX: scale, | |
| scaleY: scale, | |
| selectable: false | |
| }); | |
| backgroundImage = img; | |
| canvas.add(img); | |
| canvas.renderAll(); | |
| }); | |
| }; | |
| reader.readAsDataURL(file); | |
| } | |
| // Canvas drawing events | |
| canvas.on('mouse:down', function(options) { | |
| if (!backgroundImage) return; | |
| isDrawing = true; | |
| const pointer = canvas.getPointer(options.e); | |
| if (currentTool === 'lightbar') { | |
| // Start drawing a lightbar (red line) | |
| currentObject = new fabric.Line([pointer.x, pointer.y, pointer.x, pointer.y], { | |
| stroke: '#ff0000', | |
| strokeWidth: parseInt(lightbarThickness.value), | |
| selectable: false | |
| }); | |
| canvas.add(currentObject); | |
| } else if (currentTool === 'spot') { | |
| // Start drawing a spot light (blue circle) | |
| const size = parseInt(spotSize.value); | |
| currentObject = new fabric.Circle({ | |
| left: pointer.x - size/2, | |
| top: pointer.y - size/2, | |
| radius: size/2, | |
| fill: '#3b82f6', | |
| selectable: false | |
| }); | |
| canvas.add(currentObject); | |
| isDrawing = false; // Spots are single click | |
| // Add to undo stack | |
| saveToUndoStack(); | |
| // Update specs | |
| updateSpecifications(); | |
| } | |
| }); | |
| canvas.on('mouse:move', function(options) { | |
| if (!isDrawing || !currentObject || currentTool !== 'lightbar') return; | |
| const pointer = canvas.getPointer(options.e); | |
| if (currentTool === 'lightbar') { | |
| currentObject.set({ | |
| x2: pointer.x, | |
| y2: pointer.y | |
| }); | |
| canvas.renderAll(); | |
| } | |
| }); | |
| canvas.on('mouse:up', function() { | |
| if (!isDrawing || !currentObject) return; | |
| isDrawing = false; | |
| // Add to undo stack | |
| saveToUndoStack(); | |
| // Update specs | |
| updateSpecifications(); | |
| }); | |
| // Save current state to undo stack | |
| function saveToUndoStack() { | |
| undoStack.push(JSON.stringify(canvas.toJSON())); | |
| } | |
| // Undo functionality | |
| undoBtn.addEventListener('click', function() { | |
| if (undoStack.length === 0) return; | |
| undoStack.pop(); // Remove current state | |
| if (undoStack.length > 0) { | |
| canvas.loadFromJSON(undoStack[undoStack.length - 1], function() { | |
| canvas.renderAll(); | |
| }); | |
| } else { | |
| canvas.clear(); | |
| if (backgroundImage) { | |
| canvas.add(backgroundImage); | |
| } | |
| } | |
| updateSpecifications(); | |
| }); | |
| // Clear all guides | |
| clearGuidesBtn.addEventListener('click', function() { | |
| if (!confirm('Are you sure you want to clear all lighting elements?')) return; | |
| canvas.clear(); | |
| undoStack = []; | |
| if (backgroundImage) { | |
| canvas.add(backgroundImage); | |
| } | |
| updateSpecifications(); | |
| }); | |
| // Zoom controls | |
| zoomInBtn.addEventListener('click', function() { | |
| const objects = canvas.getObjects(); | |
| objects.forEach(obj => { | |
| obj.scaleX *= 1.1; | |
| obj.scaleY *= 1.1; | |
| }); | |
| canvas.renderAll(); | |
| }); | |
| zoomOutBtn.addEventListener('click', function() { | |
| const objects = canvas.getObjects(); | |
| objects.forEach(obj => { | |
| obj.scaleX *= 0.9; | |
| obj.scaleY *= 0.9; | |
| }); | |
| canvas.renderAll(); | |
| }); | |
| // Generate lighting visualization | |
| generateBtn.addEventListener('click', function() { | |
| if (!backgroundImage) { | |
| alert('Please upload a property image first.'); | |
| return; | |
| } | |
| // Show loading overlay | |
| loadingOverlay.classList.remove('hidden'); | |
| let progress = 0; | |
| const interval = setInterval(() => { | |
| progress += 10; | |
| progressBar.style.width = `${Math.min(progress, 90)}%`; | |
| if (progress >= 100) { | |
| clearInterval(interval); | |
| setTimeout(() => { | |
| loadingOverlay.classList.add('hidden'); | |
| progressBar.style.width = '0%'; | |
| simulateLightingEffect(); | |
| }, 500); | |
| } | |
| }, 200); | |
| }); | |
| // Simulate lighting effect (this would be replaced with actual AI processing) | |
| function simulateLightingEffect() { | |
| // In a real implementation, this would call an AI service | |
| // For now, we'll just add some glow effects to the elements | |
| const objects = canvas.getObjects(); | |
| objects.forEach(obj => { | |
| if (obj instanceof fabric.Line && obj.stroke === '#ff0000') { | |
| // Add glow to lightbars | |
| obj.set({ | |
| shadow: new fabric.Shadow({ | |
| color: `rgba(${red}, ${green}, ${blue}, 0.7)`, | |
| blur: 20, | |
| offsetX: 0, | |
| offsetY: 0 | |
| }) | |
| }); | |
| } else if (obj instanceof fabric.Circle && obj.fill === '#3b82f6') { | |
| // Add glow to spots | |
| obj.set({ | |
| fill: `rgba(${red}, ${green}, ${blue}, 0.8)`, | |
| shadow: new fabric.Shadow({ | |
| color: `rgba(${red}, ${green}, ${blue}, 0.7)`, | |
| blur: 15, | |
| offsetX: 0, | |
| offsetY: 0 | |
| }) | |
| }); | |
| } | |
| }); | |
| canvas.renderAll(); | |
| // Show success message | |
| alert('Lighting visualization generated! The glow effects simulate how the RGBW lighting would appear.'); | |
| } | |
| // Update specifications list | |
| function updateSpecifications() { | |
| const lightbars = []; | |
| const spots = []; | |
| canvas.getObjects().forEach(obj => { | |
| if (obj instanceof fabric.Line && obj.stroke === '#ff0000') { | |
| // Calculate length in pixels (approximate) | |
| const dx = obj.x2 - obj.x1; | |
| const dy = obj.y2 - obj.y1; | |
| const length = Math.sqrt(dx*dx + dy*dy).toFixed(0); | |
| lightbars.push({ | |
| length: length, | |
| thickness: obj.strokeWidth, | |
| position: { x1: obj.x1, y1: obj.y1, x2: obj.x2, y2: obj.y2 } | |
| }); | |
| } else if (obj instanceof fabric.Circle && obj.fill === '#3b82f6') { | |
| spots.push({ | |
| diameter: (obj.radius * 2).toFixed(0), | |
| position: { x: obj.left + obj.radius, y: obj.top + obj.radius } | |
| }); | |
| } | |
| }); | |
| // Update lightbar specs | |
| if (lightbars.length > 0) { | |
| let html = '<div class="space-y-2">'; | |
| lightbars.forEach((bar, index) => { | |
| html += ` | |
| <div class="p-2 border rounded flex justify-between items-center"> | |
| <div> | |
| <span class="led-circle bg-red-500"></span> | |
| <span>Lightbar #${index+1}</span> | |
| </div> | |
| <div class="text-xs text-gray-600"> | |
| Length: ${bar.length}px | Thickness: ${bar.thickness}px | |
| </div> | |
| </div> | |
| `; | |
| }); | |
| html += '</div>'; | |
| lightbarSpecs.innerHTML = html; | |
| } else { | |
| lightbarSpecs.innerHTML = '<p class="text-gray-500 italic">Draw red lines to specify lightbar positions</p>'; | |
| } | |
| // Update spot specs | |
| if (spots.length > 0) { | |
| let html = '<div class="space-y-2">'; | |
| spots.forEach((spot, index) => { | |
| html += ` | |
| <div class="p-2 border rounded flex justify-between items-center"> | |
| <div> | |
| <span class="led-circle bg-blue-500"></span> | |
| <span>Spot #${index+1}</span> | |
| </div> | |
| <div class="text-xs text-gray-600"> | |
| Diameter: ${spot.diameter}px | |
| </div> | |
| </div> | |
| `; | |
| }); | |
| html += '</div>'; | |
| spotSpecs.innerHTML = html; | |
| } else { | |
| spotSpecs.innerHTML = '<p class="text-gray-500 italic">Draw blue circles to specify spot positions</p>'; | |
| } | |
| } | |
| // Export design | |
| saveDesignBtn.addEventListener('click', function() { | |
| // Get all lighting elements | |
| const lightbars = []; | |
| const spots = []; | |
| canvas.getObjects().forEach(obj => { | |
| if (obj instanceof fabric.Line && obj.stroke === '#ff0000') { | |
| const dx = obj.x2 - obj.x1; | |
| const dy = obj.y2 - obj.y1; | |
| const length = Math.sqrt(dx*dx + dy*dy).toFixed(0); | |
| lightbars.push({ | |
| type: 'lightbar', | |
| color: { r: red, g: green, b: blue, w: white }, | |
| length: length, | |
| thickness: obj.strokeWidth, | |
| start: { x: obj.x1, y: obj.y1 }, | |
| end: { x: obj.x2, y: obj.y2 } | |
| }); | |
| } else if (obj instanceof fabric.Circle && obj.fill === '#3b82f6') { | |
| spots.push({ | |
| type: 'spot', | |
| color: { r: red, g: green, b: blue, w: white }, | |
| diameter: (obj.radius * 2).toFixed(0), | |
| position: { x: obj.left + obj.radius, y: obj.top + obj.radius } | |
| }); | |
| } | |
| }); | |
| // Create a JSON specification | |
| const spec = { | |
| project: 'Architectural Lighting Design', | |
| date: new Date().toISOString(), | |
| rgbwSettings: { red, green, blue, white }, | |
| lightbars, | |
| spots, | |
| backgroundImage: backgroundImage ? backgroundImage.getSrc() : null | |
| }; | |
| // Create a download link | |
| const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(spec, null, 2)); | |
| const downloadAnchor = document.createElement('a'); | |
| downloadAnchor.setAttribute("href", dataStr); | |
| downloadAnchor.setAttribute("download", "lighting-design-spec.json"); | |
| document.body.appendChild(downloadAnchor); | |
| downloadAnchor.click(); | |
| document.body.removeChild(downloadAnchor); | |
| // Also offer image download | |
| if (confirm('Would you like to download the canvas as an image as well?')) { | |
| const imageData = canvas.toDataURL({ | |
| format: 'png', | |
| quality: 1 | |
| }); | |
| const imgDownload = document.createElement('a'); | |
| imgDownload.setAttribute("href", imageData); | |
| imgDownload.setAttribute("download", "lighting-design.png"); | |
| document.body.appendChild(imgDownload); | |
| imgDownload.click(); | |
| document.body.removeChild(imgDownload); | |
| } | |
| }); | |
| }); | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=VisionBleuLED/vision-bleu-ai" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |