function ColorPanel({ data, expanded = false }) { const color = data || { temperature: 'Warm', contrast: 'Medium-High', saturation: 'Slightly Desaturated', shadows: 'Lifted, Teal tint', highlights: 'Warm, Orange push', palette: ['#1a2634', '#3d4f5f', '#d4a574', '#f5e6d3', '#8b5a2b'], } const items = [ { label: 'Temperature', value: color.temperature }, { label: 'Contrast', value: color.contrast }, { label: 'Saturation', value: color.saturation }, { label: 'Shadows', value: color.shadows }, { label: 'Highlights', value: color.highlights }, ] // Generate and download .cube LUT file const downloadLUT = () => { const size = 17 // Standard LUT size const toneCurve = color.toneCurve || [[0, 0], [50, 50], [100, 100]] // Interpolate tone curve value const applyToneCurve = (value) => { const v = value * 100 for (let i = 0; i < toneCurve.length - 1; i++) { const [x1, y1] = toneCurve[i] const [x2, y2] = toneCurve[i + 1] if (v >= x1 && v <= x2) { const t = (v - x1) / (x2 - x1) return (y1 + t * (y2 - y1)) / 100 } } return value } // Determine color adjustments from analysis const isWarm = color.temperature?.toLowerCase().includes('warm') const isCool = color.temperature?.toLowerCase().includes('cool') const hasTealShadows = color.shadows?.toLowerCase().includes('teal') const hasWarmHighlights = color.highlights?.toLowerCase().includes('warm') let lutContent = `TITLE "FrameMatch - Generated LUT"\n` lutContent += `# Generated from image analysis\n` lutContent += `LUT_3D_SIZE ${size}\n\n` for (let b = 0; b < size; b++) { for (let g = 0; g < size; g++) { for (let r = 0; r < size; r++) { let rVal = r / (size - 1) let gVal = g / (size - 1) let bVal = b / (size - 1) // Apply tone curve const luminance = 0.299 * rVal + 0.587 * gVal + 0.114 * bVal const curveMultiplier = applyToneCurve(luminance) / (luminance || 0.001) rVal = Math.min(1, rVal * curveMultiplier) gVal = Math.min(1, gVal * curveMultiplier) bVal = Math.min(1, bVal * curveMultiplier) // Apply temperature shift if (isWarm) { rVal = Math.min(1, rVal * 1.05) bVal = bVal * 0.95 } else if (isCool) { rVal = rVal * 0.95 bVal = Math.min(1, bVal * 1.05) } // Apply shadow tint (affects darker values) if (hasTealShadows && luminance < 0.4) { const shadowAmount = (0.4 - luminance) / 0.4 gVal = Math.min(1, gVal + shadowAmount * 0.03) bVal = Math.min(1, bVal + shadowAmount * 0.05) } // Apply highlight warmth (affects brighter values) if (hasWarmHighlights && luminance > 0.6) { const highlightAmount = (luminance - 0.6) / 0.4 rVal = Math.min(1, rVal + highlightAmount * 0.03) } lutContent += `${rVal.toFixed(6)} ${gVal.toFixed(6)} ${bVal.toFixed(6)}\n` } } } // Create and download file const blob = new Blob([lutContent], { type: 'text/plain' }) const url = URL.createObjectURL(blob) const a = document.createElement('a') a.href = url a.download = 'shot-match.cube' document.body.appendChild(a) a.click() document.body.removeChild(a) URL.revokeObjectURL(url) } // Generate SVG path from tone curve points // Points are [x, y] where x and y are 0-100, y needs to be flipped for SVG coordinates const generateCurvePath = (points) => { if (!points || points.length < 2) { // Fallback to linear curve return "M 0 100 L 100 0" } // Convert points to SVG coordinates (flip Y axis) const svgPoints = points.map(([x, y]) => [x, 100 - y]) // Create a smooth curve through the points using quadratic bezier let path = `M ${svgPoints[0][0]} ${svgPoints[0][1]}` for (let i = 1; i < svgPoints.length; i++) { const prev = svgPoints[i - 1] const curr = svgPoints[i] // Use quadratic bezier for smooth curve const cpX = (prev[0] + curr[0]) / 2 const cpY = prev[1] if (i === 1) { path += ` Q ${cpX} ${cpY}, ${curr[0]} ${curr[1]}` } else { path += ` T ${curr[0]} ${curr[1]}` } } return path } const curvePath = generateCurvePath(color.toneCurve) const fillPath = curvePath + " L 100 100 L 0 100 Z" return (

Color Grade

{!expanded && (
{color.palette?.map((c, i) => (
))}
)}
{items.map((item, index) => (
{item.label} {item.value}
))}
{expanded && (

Tone Curve

{/* Reference diagonal line (linear response) */} {/* Actual tone curve from image analysis */} {/* Control points visualization */} {color.toneCurve?.map(([x, y], i) => ( ))}
Shadows
Highlights
)}
) } export default ColorPanel