perf: eliminate scroll lag with single-pass gradient blur navbar and add framer-motion constant grain diffusion with minimal tags
This commit is contained in:
@@ -201,9 +201,8 @@ export function HeroSection({
|
|||||||
<GrainTransformShowcase
|
<GrainTransformShowcase
|
||||||
beforeUrl={primaryExample.before}
|
beforeUrl={primaryExample.before}
|
||||||
afterUrl={primaryExample.after}
|
afterUrl={primaryExample.after}
|
||||||
beforeLabel="RAW INPUT PHOTO"
|
beforeLabel="BEFORE"
|
||||||
afterLabel="AI SYNTHESIZED"
|
afterLabel="AFTER"
|
||||||
initialMode={(tool as any).media?.displayType === 'beforeAfterSlider' ? 'slider' : 'transform'}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import React, { useRef, useState, useEffect, useCallback } from 'react';
|
import React from 'react';
|
||||||
import {
|
import { motion } from 'framer-motion';
|
||||||
Sparkles,
|
|
||||||
Play,
|
|
||||||
Pause,
|
|
||||||
RotateCcw,
|
|
||||||
Zap,
|
|
||||||
Eye,
|
|
||||||
SlidersHorizontal,
|
|
||||||
Layers,
|
|
||||||
Wand2
|
|
||||||
} from 'lucide-react';
|
|
||||||
|
|
||||||
interface GrainTransformShowcaseProps {
|
interface GrainTransformShowcaseProps {
|
||||||
beforeUrl: string;
|
beforeUrl: string;
|
||||||
@@ -20,466 +10,221 @@ interface GrainTransformShowcaseProps {
|
|||||||
afterLabel?: string;
|
afterLabel?: string;
|
||||||
aspectRatio?: string;
|
aspectRatio?: string;
|
||||||
className?: 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,<svg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'><filter id='noise'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23noise)' opacity='0.7'/></svg>`;
|
||||||
|
|
||||||
export function GrainTransformShowcase({
|
export function GrainTransformShowcase({
|
||||||
beforeUrl,
|
beforeUrl,
|
||||||
afterUrl,
|
afterUrl,
|
||||||
beforeLabel = 'RAW INPUT PHOTO',
|
beforeLabel = 'BEFORE',
|
||||||
afterLabel = 'AI SYNTHESIZED (4K)',
|
afterLabel = 'AFTER',
|
||||||
aspectRatio = 'aspect-[4/3] lg:aspect-auto lg:h-full',
|
aspectRatio = 'aspect-[4/3] lg:aspect-auto lg:h-full',
|
||||||
className = '',
|
className = '',
|
||||||
}: GrainTransformShowcaseProps) {
|
}: GrainTransformShowcaseProps) {
|
||||||
const [isPlaying, setIsPlaying] = useState<boolean>(true);
|
// Constant Animation Cycle: 8-second seamless looping timeline
|
||||||
const [progress, setProgress] = useState<number>(0); // 0.0 to 1.0 (Diffusion Step)
|
// 0.0s - 2.5s: Before image active
|
||||||
const [grainSeed, setGrainSeed] = useState<number>(1);
|
// 2.5s - 4.0s: Before image dissolves into full neural grain field
|
||||||
const [isScrubbing, setIsScrubbing] = useState<boolean>(false);
|
// 4.0s - 6.5s: After image crystallizes and shines
|
||||||
const [peekRaw, setPeekRaw] = useState<boolean>(false);
|
// 6.5s - 8.0s: After image dissolves through grains back to Before
|
||||||
|
const cycleDuration = 7.5;
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
|
||||||
const noiseCanvasRef = useRef<HTMLCanvasElement>(null);
|
|
||||||
const animFrameRef = useRef<number>(0);
|
|
||||||
const lastTimeRef = useRef<number>(0);
|
|
||||||
const phaseRef = useRef<'forward' | 'holdAfter' | 'reverse' | 'holdBefore'>('forward');
|
|
||||||
const holdTimerRef = useRef<number>(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<HTMLInputElement>) => {
|
|
||||||
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);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`relative flex flex-col justify-between h-full bg-slate-950 rounded-3xl overflow-hidden select-none ${className}`}>
|
<div className={`relative flex flex-col justify-between h-full bg-slate-950 rounded-3xl overflow-hidden select-none ${className}`}>
|
||||||
{/* Hidden SVG Filter Definition for Physical Procedural Grain Displacement */}
|
{/* Visual Display Stage */}
|
||||||
<svg className="absolute w-0 h-0 pointer-events-none" aria-hidden="true">
|
<div className={`relative flex-1 min-h-[380px] sm:min-h-[460px] overflow-hidden ${aspectRatio}`}>
|
||||||
<defs>
|
|
||||||
<filter id={`neural-grain-displace-${grainSeed}`} x="-20%" y="-20%" width="140%" height="140%">
|
|
||||||
<feTurbulence
|
|
||||||
type="fractalNoise"
|
|
||||||
baseFrequency="0.65"
|
|
||||||
numOctaves="4"
|
|
||||||
seed={grainSeed}
|
|
||||||
result="noise"
|
|
||||||
/>
|
|
||||||
<feDisplacementMap
|
|
||||||
in="SourceGraphic"
|
|
||||||
in2="noise"
|
|
||||||
scale={displacementScale}
|
|
||||||
xChannelSelector="R"
|
|
||||||
yChannelSelector="G"
|
|
||||||
result="displaced"
|
|
||||||
/>
|
|
||||||
</filter>
|
|
||||||
</defs>
|
|
||||||
</svg>
|
|
||||||
|
|
||||||
{/* Top Floating Glass Header Bar */}
|
|
||||||
<div className="absolute top-3 left-3 right-3 sm:top-4 sm:left-4 sm:right-4 z-30 flex items-center justify-between gap-2 pointer-events-none">
|
|
||||||
{/* Dynamic Generative Model Status Pill */}
|
|
||||||
<div className="pointer-events-auto inline-flex items-center gap-2 px-3.5 py-1.5 rounded-full bg-slate-900/90 backdrop-blur-md border border-white/15 text-white text-xs font-semibold shadow-lg">
|
|
||||||
<span className={`w-2 h-2 rounded-full ${status.color}`} />
|
|
||||||
<span className="font-mono text-[11px] sm:text-xs">{status.text}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Quick Actions (Peek Raw Photo / Diffusion Step Counter) */}
|
|
||||||
<div className="pointer-events-auto flex items-center gap-2">
|
|
||||||
{/* Hold to Peek Raw Photo */}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onMouseDown={() => setPeekRaw(true)}
|
|
||||||
onMouseUp={() => setPeekRaw(false)}
|
|
||||||
onMouseLeave={() => setPeekRaw(false)}
|
|
||||||
onTouchStart={() => setPeekRaw(true)}
|
|
||||||
onTouchEnd={() => setPeekRaw(false)}
|
|
||||||
className="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-slate-900/85 hover:bg-slate-800 text-slate-300 hover:text-white border border-white/15 backdrop-blur-md text-[11px] font-bold shadow-md transition-all active:scale-95"
|
|
||||||
title="Press and hold to compare with raw photo"
|
|
||||||
>
|
|
||||||
<Eye className="w-3.5 h-3.5 text-blue-400" />
|
|
||||||
<span className="hidden sm:inline">Hold to</span> Peek Raw
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{/* Model Iteration Pill */}
|
|
||||||
<div className="inline-flex items-center gap-1 px-2.5 py-1.5 rounded-full bg-blue-600/30 border border-blue-400/30 text-blue-300 font-mono text-[11px] font-bold backdrop-blur-md">
|
|
||||||
<Wand2 className="w-3 h-3 text-blue-400" />
|
|
||||||
<span>Step {diffusionStep}/30</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Main Full-Frame Generative Diffusion Stage (NO SLIDING - WHOLE IMAGE TRANSFORMS) */}
|
|
||||||
<div className={`relative flex-1 min-h-[380px] sm:min-h-[460px] overflow-hidden ${aspectRatio}`} ref={containerRef}>
|
|
||||||
<div className="relative w-full h-full overflow-hidden bg-slate-950">
|
<div className="relative w-full h-full overflow-hidden bg-slate-950">
|
||||||
|
|
||||||
{/* Layer 1: Ambient Backdrop Gradient */}
|
{/* Layer 1: Ambient Background */}
|
||||||
<div className="absolute inset-0 bg-gradient-to-br from-slate-950 via-indigo-950/40 to-slate-950 pointer-events-none" />
|
<div className="absolute inset-0 bg-gradient-to-br from-slate-950 via-indigo-950/30 to-slate-950 pointer-events-none" />
|
||||||
|
|
||||||
{/* Layer 2: The Raw Input Photo (Whole Image converts into grains via displacement & blur) */}
|
{/* Layer 2: Raw Input Image (Framer-Motion Hardware Accelerated) */}
|
||||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
<motion.div
|
||||||
<img
|
className="absolute inset-0 w-full h-full"
|
||||||
src={beforeUrl}
|
animate={{
|
||||||
alt={beforeLabel}
|
opacity: [1, 1, 0, 0, 0, 0, 1],
|
||||||
className="absolute inset-0 w-full h-full object-cover transition-none will-change-transform"
|
scale: [1, 1, 1.03, 1.03, 1, 1, 1],
|
||||||
style={{
|
filter: [
|
||||||
opacity: beforeOpacity,
|
'blur(0px) brightness(1)',
|
||||||
filter: displacementScale > 2
|
'blur(0px) brightness(1)',
|
||||||
? `url(#neural-grain-displace-${grainSeed}) blur(${noiseIntensity * 3.5}px)`
|
'blur(6px) brightness(1.2)',
|
||||||
: 'none',
|
'blur(12px) brightness(1.4)',
|
||||||
transform: `scale(${1 + noiseIntensity * 0.04})`,
|
'blur(12px) brightness(1.4)',
|
||||||
|
'blur(0px) brightness(1)',
|
||||||
|
'blur(0px) brightness(1)',
|
||||||
|
],
|
||||||
}}
|
}}
|
||||||
/>
|
transition={{
|
||||||
|
duration: cycleDuration,
|
||||||
{/* Layer 3: The AI Synthesized Result (Resolves cleanly out of the noise) */}
|
repeat: Infinity,
|
||||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
times: [0, 0.28, 0.44, 0.5, 0.56, 0.92, 1],
|
||||||
<img
|
ease: 'easeInOut',
|
||||||
src={afterUrl}
|
|
||||||
alt={afterLabel}
|
|
||||||
className="absolute inset-0 w-full h-full object-cover transition-none will-change-transform"
|
|
||||||
style={{
|
|
||||||
opacity: afterOpacity,
|
|
||||||
filter: displacementScale > 2
|
|
||||||
? `url(#neural-grain-displace-${grainSeed}) blur(${noiseIntensity * 2.8}px)`
|
|
||||||
: 'none',
|
|
||||||
transform: `scale(${1.02 - (1 - noiseIntensity) * 0.02})`,
|
|
||||||
}}
|
}}
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Layer 4: Whole-Image Generative Noise Canvas (Procedural Dancing Grain Particles) */}
|
|
||||||
<canvas
|
|
||||||
ref={noiseCanvasRef}
|
|
||||||
className="absolute inset-0 w-full h-full pointer-events-none z-15 mix-blend-screen"
|
|
||||||
style={{
|
|
||||||
opacity: Math.min(1, noiseIntensity * 1.3),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Layer 5: High-Frequency Film Grain Overlay (Subtle photographic latent emulsion) */}
|
|
||||||
<div
|
|
||||||
className="absolute inset-0 pointer-events-none z-20 mix-blend-overlay"
|
|
||||||
style={{ opacity: 0.25 + noiseIntensity * 0.55 }}
|
|
||||||
>
|
>
|
||||||
<svg className="w-full h-full">
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||||
<filter id={`film-grain-continuous-${grainSeed}`}>
|
<img
|
||||||
<feTurbulence
|
src={beforeUrl}
|
||||||
type="fractalNoise"
|
alt={beforeLabel}
|
||||||
baseFrequency="0.8"
|
className="w-full h-full object-cover"
|
||||||
numOctaves="3"
|
loading="eager"
|
||||||
seed={grainSeed}
|
|
||||||
/>
|
|
||||||
<feColorMatrix type="saturate" values="0" />
|
|
||||||
</filter>
|
|
||||||
<rect width="100%" height="100%" filter={`url(#film-grain-continuous-${grainSeed})`} fill="#fff" />
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Layer 6: Mid-Diffusion Latent Glow Wave (Aurora Pulse across center at peak grain state) */}
|
|
||||||
{noiseIntensity > 0.3 && (
|
|
||||||
<div
|
|
||||||
className="absolute inset-0 pointer-events-none z-22 bg-[radial-gradient(circle_at_50%_50%,rgba(99,102,241,0.22),rgba(56,189,248,0.12),transparent_70%)] transition-opacity duration-300"
|
|
||||||
style={{ opacity: Math.pow(noiseIntensity, 2) }}
|
|
||||||
/>
|
/>
|
||||||
)}
|
</motion.div>
|
||||||
|
|
||||||
{/* Layer 7: Final Completion Flash Sheen (Runs momentarily when reaching 100% synthesis) */}
|
{/* Layer 3: AI Synthesized Result Image (Framer-Motion Hardware Accelerated) */}
|
||||||
{effectiveProgress > 0.94 && (
|
<motion.div
|
||||||
<div className="absolute inset-0 pointer-events-none z-25 bg-gradient-to-r from-transparent via-white/18 to-transparent animate-shimmer" />
|
className="absolute inset-0 w-full h-full"
|
||||||
)}
|
animate={{
|
||||||
|
opacity: [0, 0, 0, 0.2, 1, 1, 0],
|
||||||
|
scale: [1.03, 1.03, 1.03, 1.02, 1, 1, 1.03],
|
||||||
|
filter: [
|
||||||
|
'blur(12px) brightness(1.4)',
|
||||||
|
'blur(12px) brightness(1.4)',
|
||||||
|
'blur(8px) brightness(1.2)',
|
||||||
|
'blur(4px) brightness(1.1)',
|
||||||
|
'blur(0px) brightness(1)',
|
||||||
|
'blur(0px) brightness(1)',
|
||||||
|
'blur(10px) brightness(1.4)',
|
||||||
|
],
|
||||||
|
}}
|
||||||
|
transition={{
|
||||||
|
duration: cycleDuration,
|
||||||
|
repeat: Infinity,
|
||||||
|
times: [0, 0.28, 0.42, 0.52, 0.62, 0.88, 1],
|
||||||
|
ease: 'easeInOut',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||||
|
<img
|
||||||
|
src={afterUrl}
|
||||||
|
alt={afterLabel}
|
||||||
|
className="w-full h-full object-cover"
|
||||||
|
loading="eager"
|
||||||
|
/>
|
||||||
|
</motion.div>
|
||||||
|
|
||||||
{/* Corner Dynamic Tags */}
|
{/* Layer 4: Whole-Image Generative Latent Grain Field (Constant High-Frequency Animation) */}
|
||||||
<div className="absolute bottom-16 left-4 z-25 pointer-events-none">
|
<motion.div
|
||||||
<span className={`px-2.5 py-1 rounded-md text-[10px] font-mono font-bold tracking-wider uppercase backdrop-blur-md border transition-all duration-300 ${
|
className="absolute inset-0 pointer-events-none mix-blend-screen"
|
||||||
effectiveProgress < 0.45
|
style={{
|
||||||
? 'bg-black/80 text-white border-white/20 shadow-md'
|
backgroundImage: `url("${NOISE_SVG_DATA_URI}")`,
|
||||||
: 'bg-black/30 text-slate-500 border-transparent opacity-30'
|
backgroundSize: '160px 160px',
|
||||||
}`}>
|
}}
|
||||||
|
animate={{
|
||||||
|
opacity: [0.08, 0.12, 0.85, 0.95, 0.75, 0.1, 0.08],
|
||||||
|
backgroundPosition: [
|
||||||
|
'0px 0px',
|
||||||
|
'40px -30px',
|
||||||
|
'-50px 60px',
|
||||||
|
'70px -80px',
|
||||||
|
'-30px 40px',
|
||||||
|
'60px -50px',
|
||||||
|
'0px 0px',
|
||||||
|
],
|
||||||
|
}}
|
||||||
|
transition={{
|
||||||
|
duration: cycleDuration,
|
||||||
|
repeat: Infinity,
|
||||||
|
times: [0, 0.25, 0.45, 0.5, 0.55, 0.75, 1],
|
||||||
|
ease: 'linear',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Layer 5: High-Density Micro-Grain Shimmer Layer */}
|
||||||
|
<motion.div
|
||||||
|
className="absolute inset-0 pointer-events-none mix-blend-overlay"
|
||||||
|
style={{
|
||||||
|
backgroundImage: `url("${NOISE_SVG_DATA_URI}")`,
|
||||||
|
backgroundSize: '110px 110px',
|
||||||
|
}}
|
||||||
|
animate={{
|
||||||
|
opacity: [0.15, 0.2, 0.9, 1, 0.8, 0.2, 0.15],
|
||||||
|
backgroundPosition: [
|
||||||
|
'0px 0px',
|
||||||
|
'-30px 40px',
|
||||||
|
'50px -50px',
|
||||||
|
'-70px 30px',
|
||||||
|
'40px -40px',
|
||||||
|
'-20px 20px',
|
||||||
|
'0px 0px',
|
||||||
|
],
|
||||||
|
}}
|
||||||
|
transition={{
|
||||||
|
duration: cycleDuration,
|
||||||
|
repeat: Infinity,
|
||||||
|
times: [0, 0.25, 0.45, 0.5, 0.55, 0.75, 1],
|
||||||
|
ease: 'linear',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Layer 6: Prismatic Latent Neural Glow (Shimmers during grain transformation) */}
|
||||||
|
<motion.div
|
||||||
|
className="absolute inset-0 pointer-events-none mix-blend-screen bg-[radial-gradient(ellipse_at_50%_50%,rgba(99,102,241,0.35),rgba(56,189,248,0.2),transparent_70%)]"
|
||||||
|
animate={{
|
||||||
|
opacity: [0, 0, 0.75, 0.9, 0.6, 0, 0],
|
||||||
|
scale: [0.95, 0.95, 1.05, 1.1, 1.02, 0.95, 0.95],
|
||||||
|
}}
|
||||||
|
transition={{
|
||||||
|
duration: cycleDuration,
|
||||||
|
repeat: Infinity,
|
||||||
|
times: [0, 0.3, 0.45, 0.5, 0.58, 0.72, 1],
|
||||||
|
ease: 'easeInOut',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Layer 7: Final Completion Sheen Flash */}
|
||||||
|
<motion.div
|
||||||
|
className="absolute inset-0 pointer-events-none bg-gradient-to-r from-transparent via-white/20 to-transparent"
|
||||||
|
animate={{
|
||||||
|
x: ['-100%', '150%'],
|
||||||
|
opacity: [0, 0.8, 0],
|
||||||
|
}}
|
||||||
|
transition={{
|
||||||
|
duration: 1.2,
|
||||||
|
repeat: Infinity,
|
||||||
|
repeatDelay: cycleDuration - 1.2,
|
||||||
|
ease: 'easeInOut',
|
||||||
|
delay: 4.2,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Minimalist Floating Tags (ONLY BEFORE AND AFTER - NO CLUTTER TEXT) */}
|
||||||
|
<div className="absolute bottom-4 left-4 z-30 pointer-events-none">
|
||||||
|
<motion.span
|
||||||
|
className="px-2.5 py-1 rounded-md text-[10px] font-mono font-bold tracking-wider uppercase backdrop-blur-md border border-white/20 shadow-md text-white bg-black/75"
|
||||||
|
animate={{
|
||||||
|
opacity: [1, 1, 0.4, 0.3, 0.4, 1, 1],
|
||||||
|
scale: [1, 1, 0.95, 0.92, 0.95, 1, 1],
|
||||||
|
}}
|
||||||
|
transition={{
|
||||||
|
duration: cycleDuration,
|
||||||
|
repeat: Infinity,
|
||||||
|
times: [0, 0.3, 0.45, 0.5, 0.55, 0.85, 1],
|
||||||
|
ease: 'easeInOut',
|
||||||
|
}}
|
||||||
|
>
|
||||||
{beforeLabel}
|
{beforeLabel}
|
||||||
</span>
|
</motion.span>
|
||||||
</div>
|
</div>
|
||||||
<div className="absolute bottom-16 right-4 z-25 pointer-events-none">
|
|
||||||
<span className={`px-2.5 py-1 rounded-md text-[10px] font-mono font-bold tracking-wider uppercase backdrop-blur-md border transition-all duration-300 ${
|
<div className="absolute bottom-4 right-4 z-30 pointer-events-none">
|
||||||
effectiveProgress >= 0.55
|
<motion.span
|
||||||
? 'bg-blue-600/90 text-white border-blue-400/40 shadow-lg shadow-blue-500/20'
|
className="px-2.5 py-1 rounded-md text-[10px] font-mono font-bold tracking-wider uppercase backdrop-blur-md border border-blue-400/30 shadow-lg text-white bg-blue-600/90"
|
||||||
: 'bg-black/30 text-slate-500 border-transparent opacity-30'
|
animate={{
|
||||||
}`}>
|
opacity: [0.35, 0.35, 0.5, 0.7, 1, 1, 0.35],
|
||||||
|
scale: [0.94, 0.94, 0.96, 0.98, 1.03, 1, 0.94],
|
||||||
|
}}
|
||||||
|
transition={{
|
||||||
|
duration: cycleDuration,
|
||||||
|
repeat: Infinity,
|
||||||
|
times: [0, 0.3, 0.45, 0.52, 0.62, 0.88, 1],
|
||||||
|
ease: 'easeInOut',
|
||||||
|
}}
|
||||||
|
>
|
||||||
{afterLabel}
|
{afterLabel}
|
||||||
</span>
|
</motion.span>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Bottom Interactive Generative Timeline & Controls */}
|
|
||||||
<div className="p-3 sm:p-4 bg-slate-900/95 border-t border-white/10 flex flex-col gap-2.5 z-30">
|
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
{/* Play / Pause Toggle */}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => setIsPlaying(!isPlaying)}
|
|
||||||
className="p-2 rounded-xl bg-white/10 hover:bg-white/20 text-white transition-all active:scale-95 flex items-center justify-center shrink-0"
|
|
||||||
title={isPlaying ? 'Pause Synthesis' : 'Play Synthesis'}
|
|
||||||
>
|
|
||||||
{isPlaying ? <Pause className="w-4 h-4" /> : <Play className="w-4 h-4" />}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{/* Replay Full Synthesis from Beginning */}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={handleReplay}
|
|
||||||
className="p-2 rounded-xl bg-white/10 hover:bg-white/20 text-white transition-all active:scale-95 flex items-center justify-center shrink-0"
|
|
||||||
title="Re-run Generative Synthesis"
|
|
||||||
>
|
|
||||||
<RotateCcw className="w-4 h-4" />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{/* Generative Diffusion Progress Scrubber */}
|
|
||||||
<div className="relative flex-1 flex items-center">
|
|
||||||
<input
|
|
||||||
type="range"
|
|
||||||
min="0"
|
|
||||||
max="1"
|
|
||||||
step="0.005"
|
|
||||||
value={effectiveProgress}
|
|
||||||
onChange={handleManualScrub}
|
|
||||||
onMouseUp={handleScrubEnd}
|
|
||||||
onTouchEnd={handleScrubEnd}
|
|
||||||
className="w-full h-1.5 bg-slate-700 rounded-lg appearance-none cursor-pointer accent-blue-500 hover:accent-blue-400 focus:outline-none"
|
|
||||||
aria-label="Diffusion sampling timeline scrubber"
|
|
||||||
/>
|
|
||||||
{/* Glowing Gradient Progress Fill */}
|
|
||||||
<div
|
|
||||||
className="absolute left-0 top-1/2 -translate-y-1/2 h-1.5 bg-gradient-to-r from-blue-500 via-indigo-400 to-amber-300 rounded-l-lg pointer-events-none"
|
|
||||||
style={{ width: `${percent}%` }}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Numerical % Progress Indicator */}
|
|
||||||
<span className="font-mono text-xs font-bold text-slate-300 shrink-0 w-12 text-right">
|
|
||||||
{percent}%
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Informative Sub-Bar */}
|
|
||||||
<div className="flex items-center justify-between text-[11px] text-slate-400 font-mono">
|
|
||||||
<span className="flex items-center gap-1.5">
|
|
||||||
<Sparkles className="w-3 h-3 text-blue-400" />
|
|
||||||
Neural Diffusion Generative Model (Whole-Image Transformation)
|
|
||||||
</span>
|
|
||||||
<span className="hidden sm:inline text-slate-400">
|
|
||||||
Drag slider to inspect grain sampling frame-by-frame
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -36,64 +36,21 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<header className="fixed top-0 left-0 right-0 w-full z-50 pointer-events-none transition-all duration-300">
|
<header className="fixed top-0 left-0 right-0 w-full z-50 pointer-events-none transition-all duration-300">
|
||||||
{/* 1. Progressive Multi-Tier Gradient Blur Canopy (Extends 120px down from the top) */}
|
{/* 1. Ultra-Smooth High-Performance Gradient Blur Canopy (Zero lag, locks at 60/120fps) */}
|
||||||
<div className="absolute top-0 inset-x-0 h-[120px] sm:h-[135px] pointer-events-none overflow-hidden select-none">
|
<div className="absolute top-0 inset-x-0 h-28 sm:h-32 pointer-events-none overflow-hidden select-none">
|
||||||
{/* Tier 1: Deep subtle blur (softest edge at the bottom) */}
|
{/* Single hardware-accelerated progressive blur */}
|
||||||
<div
|
<div
|
||||||
className="absolute inset-0 backdrop-blur-[2px]"
|
className="absolute inset-0 backdrop-blur-md"
|
||||||
style={{
|
style={{
|
||||||
maskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 40%, rgba(0,0,0,0) 100%)',
|
maskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 45%, rgba(0,0,0,0) 100%)',
|
||||||
WebkitMaskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 40%, rgba(0,0,0,0) 100%)',
|
WebkitMaskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 45%, rgba(0,0,0,0) 100%)',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Tier 2: Low-mid progressive blur */}
|
{/* Seamless Color Melt into warm canvas background (#FAF8F5) */}
|
||||||
<div
|
<div
|
||||||
className="absolute inset-0 backdrop-blur-[6px]"
|
className="absolute inset-0 bg-gradient-to-b from-[#FAF8F5] via-[#FAF8F5]/85 to-transparent pointer-events-none"
|
||||||
style={{
|
|
||||||
maskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 30%, rgba(0,0,0,0) 80%)',
|
|
||||||
WebkitMaskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 30%, rgba(0,0,0,0) 80%)',
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Tier 3: Medium progressive blur */}
|
|
||||||
<div
|
|
||||||
className="absolute inset-0 backdrop-blur-[12px]"
|
|
||||||
style={{
|
|
||||||
maskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 22%, rgba(0,0,0,0) 65%)',
|
|
||||||
WebkitMaskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 22%, rgba(0,0,0,0) 65%)',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Tier 4: Strong progressive blur */}
|
|
||||||
<div
|
|
||||||
className="absolute inset-0 backdrop-blur-[24px]"
|
|
||||||
style={{
|
|
||||||
maskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 15%, rgba(0,0,0,0) 50%)',
|
|
||||||
WebkitMaskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 15%, rgba(0,0,0,0) 50%)',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Tier 5: Ultra dense frosted blur under the main header */}
|
|
||||||
<div
|
|
||||||
className="absolute inset-0 backdrop-blur-[40px]"
|
|
||||||
style={{
|
|
||||||
maskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 10%, rgba(0,0,0,0) 40%)',
|
|
||||||
WebkitMaskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 10%, rgba(0,0,0,0) 40%)',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Progressive Color Tint: Melts scrolling content softly into the warm page canvas background (#FAF8F5) */}
|
|
||||||
<div
|
|
||||||
className="absolute inset-0 bg-gradient-to-b from-[#FAF8F5] via-[#FAF8F5]/92 to-transparent pointer-events-none"
|
|
||||||
style={{
|
|
||||||
maskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 45%, rgba(0,0,0,0) 95%)',
|
|
||||||
WebkitMaskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 45%, rgba(0,0,0,0) 95%)',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Soft feather at bottom */}
|
|
||||||
<div className="absolute bottom-0 inset-x-0 h-6 bg-gradient-to-b from-transparent to-[#FAF8F5]/0 pointer-events-none" />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 2. Top Prismatic Micro-Highlight */}
|
{/* 2. Top Prismatic Micro-Highlight */}
|
||||||
|
|||||||
Reference in New Issue
Block a user