diff --git a/src/components/sections/HeroSection.tsx b/src/components/sections/HeroSection.tsx index 3fe6fc2..fd65dc3 100644 --- a/src/components/sections/HeroSection.tsx +++ b/src/components/sections/HeroSection.tsx @@ -201,9 +201,8 @@ export function HeroSection({ diff --git a/src/components/ui/GrainTransformShowcase.tsx b/src/components/ui/GrainTransformShowcase.tsx index 04f778d..40975e5 100644 --- a/src/components/ui/GrainTransformShowcase.tsx +++ b/src/components/ui/GrainTransformShowcase.tsx @@ -1,17 +1,7 @@ 'use client'; -import React, { useRef, useState, useEffect, useCallback } from 'react'; -import { - Sparkles, - Play, - Pause, - RotateCcw, - Zap, - Eye, - SlidersHorizontal, - Layers, - Wand2 -} from 'lucide-react'; +import React from 'react'; +import { motion } from 'framer-motion'; interface GrainTransformShowcaseProps { beforeUrl: string; @@ -20,466 +10,221 @@ interface GrainTransformShowcaseProps { afterLabel?: string; aspectRatio?: string; className?: string; - initialMode?: 'transform' | 'slider'; } +// Ultra-fast SVG fractal noise data URI (GPU-cached, 0% CPU overhead) +const NOISE_SVG_DATA_URI = `data:image/svg+xml;utf8,`; + export function GrainTransformShowcase({ beforeUrl, afterUrl, - beforeLabel = 'RAW INPUT PHOTO', - afterLabel = 'AI SYNTHESIZED (4K)', + beforeLabel = 'BEFORE', + afterLabel = 'AFTER', aspectRatio = 'aspect-[4/3] lg:aspect-auto lg:h-full', className = '', }: GrainTransformShowcaseProps) { - const [isPlaying, setIsPlaying] = useState(true); - const [progress, setProgress] = useState(0); // 0.0 to 1.0 (Diffusion Step) - const [grainSeed, setGrainSeed] = useState(1); - const [isScrubbing, setIsScrubbing] = useState(false); - const [peekRaw, setPeekRaw] = useState(false); - - const containerRef = useRef(null); - const noiseCanvasRef = useRef(null); - const animFrameRef = useRef(0); - const lastTimeRef = useRef(0); - const phaseRef = useRef<'forward' | 'holdAfter' | 'reverse' | 'holdBefore'>('forward'); - const holdTimerRef = useRef(0); - - // Full-Frame Generative Neural Latent Grain Canvas Simulation - // Creates dancing multicolored grain particles across the ENTIRE image like diffusion models - useEffect(() => { - const canvas = noiseCanvasRef.current; - if (!canvas) return; - const ctx = canvas.getContext('2d'); - if (!ctx) return; - - let noiseAnimId: number; - const resize = () => { - const rect = canvas.getBoundingClientRect(); - if (rect.width > 0 && rect.height > 0) { - // Scaled internal buffer for high density granular performance - canvas.width = Math.min(rect.width, 640); - canvas.height = Math.min(rect.height, 480); - } - }; - resize(); - window.addEventListener('resize', resize); - - // Dynamic Grain Particles that swirl in latent space - const particles: Array<{ - x: number; - y: number; - vx: number; - vy: number; - size: number; - alpha: number; - hue: number; - }> = []; - - // Pre-seed ambient latent particles - for (let i = 0; i < 45; i++) { - particles.push({ - x: Math.random() * (canvas.width || 600), - y: Math.random() * (canvas.height || 450), - vx: (Math.random() - 0.5) * 1.8, - vy: (Math.random() - 0.5) * 1.8, - size: Math.random() * 2.2 + 0.6, - alpha: Math.random() * 0.7 + 0.2, - hue: Math.floor(Math.random() * 60) + 220, // Blue-Indigo-Violet - }); - } - - const render = () => { - if (canvas.width === 0 || canvas.height === 0) { - noiseAnimId = requestAnimationFrame(render); - return; - } - - ctx.clearRect(0, 0, canvas.width, canvas.height); - - // Noise intensity peaks at progress = 0.5 (deep latent space) - // 0.0 -> 0.0 intensity, 0.5 -> 1.0 intensity, 1.0 -> 0.0 intensity - const noiseIntensity = Math.sin(progress * Math.PI); - - if (noiseIntensity > 0.04) { - // 1. Procedural High-Density Grain Static - const imgData = ctx.createImageData(canvas.width, canvas.height); - const buffer = new Uint32Array(imgData.data.buffer); - const len = buffer.length; - - // Density increases dramatically during midpoint - const grainAlpha = Math.floor(noiseIntensity * 140); - const colorShift = Math.sin(Date.now() * 0.003) * 15; - - for (let i = 0; i < len; i += 2) { - if (Math.random() < noiseIntensity * 0.85) { - const val = (Math.random() * 255) | 0; - const r = Math.min(255, val + colorShift); - const g = Math.min(255, val + 10); - const b = Math.min(255, val + 35); - // Little-endian RGBA packing: ABGR - buffer[i] = (grainAlpha << 24) | (b << 16) | (g << 8) | r; - } - } - ctx.putImageData(imgData, 0, 0); - - // 2. Swirling Latent Sparkle Particles - for (let i = 0; i < particles.length; i++) { - const p = particles[i]; - p.x += p.vx * (1 + noiseIntensity * 2); - p.y += p.vy * (1 + noiseIntensity * 2); - - if (p.x < 0) p.x = canvas.width; - if (p.x > canvas.width) p.x = 0; - if (p.y < 0) p.y = canvas.height; - if (p.y > canvas.height) p.y = 0; - - ctx.fillStyle = `hsla(${p.hue}, 85%, 70%, ${p.alpha * noiseIntensity})`; - ctx.beginPath(); - ctx.arc(p.x, p.y, p.size * (1 + noiseIntensity * 0.5), 0, Math.PI * 2); - ctx.fill(); - } - } - - noiseAnimId = requestAnimationFrame(render); - }; - - render(); - - return () => { - cancelAnimationFrame(noiseAnimId); - window.removeEventListener('resize', resize); - }; - }, [progress]); - - // Main Diffusion Synthesis Animation Clock (Procedural sampling loop) - useEffect(() => { - if (!isPlaying || isScrubbing) { - cancelAnimationFrame(animFrameRef.current); - return; - } - - const duration = 3200; // 3.2s full diffusion synthesis - const holdDuration = 2200; // 2.2s admiring hold on 4K result - - const loop = (timestamp: number) => { - if (!lastTimeRef.current) lastTimeRef.current = timestamp; - const delta = timestamp - lastTimeRef.current; - lastTimeRef.current = timestamp; - - setGrainSeed((prev) => (prev % 99) + 1); - - if (phaseRef.current === 'forward') { - setProgress((prev) => { - const next = prev + delta / duration; - if (next >= 1.0) { - phaseRef.current = 'holdAfter'; - holdTimerRef.current = 0; - return 1.0; - } - return next; - }); - } else if (phaseRef.current === 'holdAfter') { - holdTimerRef.current += delta; - if (holdTimerRef.current >= holdDuration) { - phaseRef.current = 'reverse'; - } - } else if (phaseRef.current === 'reverse') { - setProgress((prev) => { - // Smooth rewind back to raw photo - const next = prev - (delta / 1400); - if (next <= 0.0) { - phaseRef.current = 'holdBefore'; - holdTimerRef.current = 0; - return 0.0; - } - return next; - }); - } else if (phaseRef.current === 'holdBefore') { - holdTimerRef.current += delta; - if (holdTimerRef.current >= 900) { - phaseRef.current = 'forward'; - } - } - - animFrameRef.current = requestAnimationFrame(loop); - }; - - animFrameRef.current = requestAnimationFrame(loop); - - return () => { - cancelAnimationFrame(animFrameRef.current); - lastTimeRef.current = 0; - }; - }, [isPlaying, isScrubbing]); - - const handleManualScrub = (e: React.ChangeEvent) => { - setIsScrubbing(true); - setIsPlaying(false); - setProgress(parseFloat(e.target.value)); - }; - - const handleScrubEnd = () => { - setIsScrubbing(false); - }; - - const handleReplay = () => { - setProgress(0); - phaseRef.current = 'forward'; - lastTimeRef.current = 0; - setIsPlaying(true); - }; - - // Math for Generative Latent Diffusion Transition - // Entire Before image transforms into grains across the whole screen, then crystallizes into After - const effectiveProgress = peekRaw ? 0 : progress; - - // Diffusion Curve (smooth S-curve) - const diffusionStep = Math.min(30, Math.floor(effectiveProgress * 30)); - const noiseIntensity = Math.sin(effectiveProgress * Math.PI); // 0 -> 1 -> 0 - - // Pixel displacement scale: breaks image into scattered granular particles - const displacementScale = Math.round(noiseIntensity * 36); - - // Before image dissolves out from 0.0 to 0.55 - const beforeOpacity = effectiveProgress <= 0.5 - ? Math.max(0, 1 - Math.pow(effectiveProgress / 0.48, 1.4)) - : 0; - - // After image crystallizes in from 0.45 to 1.0 - const afterOpacity = effectiveProgress >= 0.45 - ? Math.min(1, Math.pow((effectiveProgress - 0.45) / 0.52, 1.3)) - : 0; - - // Dynamic status text resembling generative diffusion models - const getStatusInfo = () => { - if (peekRaw) return { text: 'Original Raw Input Photo', color: 'bg-slate-400' }; - if (effectiveProgress < 0.12) return { text: 'Raw Input Photo • Ready for Synthesis', color: 'bg-blue-400' }; - if (effectiveProgress < 0.45) return { text: `Forward Diffusion • Dissolving into Grains (${diffusionStep}/30)`, color: 'bg-amber-400 animate-pulse' }; - if (effectiveProgress < 0.65) return { text: `Neural Latent Synthesis • Denoising Tensor (${diffusionStep}/30)`, color: 'bg-indigo-400 animate-ping' }; - if (effectiveProgress < 0.94) return { text: `Reverse Diffusion • Crystallizing 4K Details (${diffusionStep}/30)`, color: 'bg-sky-400 animate-pulse' }; - return { text: 'AI Synthesis Complete • Lossless 4K Masterpiece', color: 'bg-emerald-400' }; - }; - - const status = getStatusInfo(); - const percent = Math.round(effectiveProgress * 100); + // Constant Animation Cycle: 8-second seamless looping timeline + // 0.0s - 2.5s: Before image active + // 2.5s - 4.0s: Before image dissolves into full neural grain field + // 4.0s - 6.5s: After image crystallizes and shines + // 6.5s - 8.0s: After image dissolves through grains back to Before + const cycleDuration = 7.5; return (
- {/* Hidden SVG Filter Definition for Physical Procedural Grain Displacement */} - - - {/* Top Floating Glass Header Bar */} -
- {/* Dynamic Generative Model Status Pill */} -
- - {status.text} -
- - {/* Quick Actions (Peek Raw Photo / Diffusion Step Counter) */} -
- {/* Hold to Peek Raw Photo */} - - - {/* Model Iteration Pill */} -
- - Step {diffusionStep}/30 -
-
-
- - {/* Main Full-Frame Generative Diffusion Stage (NO SLIDING - WHOLE IMAGE TRANSFORMS) */} -
+ {/* Visual Display Stage */} +
- {/* Layer 1: Ambient Backdrop Gradient */} -
+ {/* Layer 1: Ambient Background */} +
- {/* Layer 2: The Raw Input Photo (Whole Image converts into grains via displacement & blur) */} - {/* eslint-disable-next-line @next/next/no-img-element */} - {beforeLabel} 2 - ? `url(#neural-grain-displace-${grainSeed}) blur(${noiseIntensity * 3.5}px)` - : 'none', - transform: `scale(${1 + noiseIntensity * 0.04})`, + {/* Layer 2: Raw Input Image (Framer-Motion Hardware Accelerated) */} + - - {/* Layer 3: The AI Synthesized Result (Resolves cleanly out of the noise) */} - {/* eslint-disable-next-line @next/next/no-img-element */} - {afterLabel} 2 - ? `url(#neural-grain-displace-${grainSeed}) blur(${noiseIntensity * 2.8}px)` - : 'none', - transform: `scale(${1.02 - (1 - noiseIntensity) * 0.02})`, + transition={{ + duration: cycleDuration, + repeat: Infinity, + times: [0, 0.28, 0.44, 0.5, 0.56, 0.92, 1], + ease: 'easeInOut', }} - /> - - {/* Layer 4: Whole-Image Generative Noise Canvas (Procedural Dancing Grain Particles) */} - - - {/* Layer 5: High-Frequency Film Grain Overlay (Subtle photographic latent emulsion) */} -
- - - - - - - -
- - {/* Layer 6: Mid-Diffusion Latent Glow Wave (Aurora Pulse across center at peak grain state) */} - {noiseIntensity > 0.3 && ( -
- )} + - {/* Layer 7: Final Completion Flash Sheen (Runs momentarily when reaching 100% synthesis) */} - {effectiveProgress > 0.94 && ( -
- )} + {/* Layer 3: AI Synthesized Result Image (Framer-Motion Hardware Accelerated) */} + + {/* eslint-disable-next-line @next/next/no-img-element */} + {afterLabel} + - {/* Corner Dynamic Tags */} -
- + {/* Layer 4: Whole-Image Generative Latent Grain Field (Constant High-Frequency Animation) */} + + + {/* Layer 5: High-Density Micro-Grain Shimmer Layer */} + + + {/* Layer 6: Prismatic Latent Neural Glow (Shimmers during grain transformation) */} + + + {/* Layer 7: Final Completion Sheen Flash */} + + + {/* Minimalist Floating Tags (ONLY BEFORE AND AFTER - NO CLUTTER TEXT) */} +
+ {beforeLabel} - +
-
- = 0.55 - ? 'bg-blue-600/90 text-white border-blue-400/40 shadow-lg shadow-blue-500/20' - : 'bg-black/30 text-slate-500 border-transparent opacity-30' - }`}> + +
+ {afterLabel} - -
-
-
- - {/* Bottom Interactive Generative Timeline & Controls */} -
-
- {/* Play / Pause Toggle */} - - - {/* Replay Full Synthesis from Beginning */} - - - {/* Generative Diffusion Progress Scrubber */} -
- - {/* Glowing Gradient Progress Fill */} -
+
- {/* Numerical % Progress Indicator */} - - {percent}% - -
- - {/* Informative Sub-Bar */} -
- - - Neural Diffusion Generative Model (Whole-Image Transformation) - - - Drag slider to inspect grain sampling frame-by-frame -
diff --git a/src/components/ui/Navbar.tsx b/src/components/ui/Navbar.tsx index 56b6bc6..a8d2761 100644 --- a/src/components/ui/Navbar.tsx +++ b/src/components/ui/Navbar.tsx @@ -36,64 +36,21 @@ export function Navbar({ config, currentLocale }: NavbarProps) { return (
- {/* 1. Progressive Multi-Tier Gradient Blur Canopy (Extends 120px down from the top) */} -
- {/* Tier 1: Deep subtle blur (softest edge at the bottom) */} + {/* 1. Ultra-Smooth High-Performance Gradient Blur Canopy (Zero lag, locks at 60/120fps) */} +
+ {/* Single hardware-accelerated progressive blur */}
- {/* Tier 2: Low-mid progressive blur */} + {/* Seamless Color Melt into warm canvas background (#FAF8F5) */}
- - {/* Tier 3: Medium progressive blur */} -
- - {/* Tier 4: Strong progressive blur */} -
- - {/* Tier 5: Ultra dense frosted blur under the main header */} -
- - {/* Progressive Color Tint: Melts scrolling content softly into the warm page canvas background (#FAF8F5) */} -
- - {/* Soft feather at bottom */} -
{/* 2. Top Prismatic Micro-Highlight */}