42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
'use client';
|
|
|
|
import React from 'react';
|
|
|
|
interface NeuralGrainOverlayProps {
|
|
intensity?: number;
|
|
active?: boolean;
|
|
className?: string;
|
|
}
|
|
|
|
/**
|
|
* NeuralGrainOverlay - Thermally safe static grain texture.
|
|
*
|
|
* PERFORMANCE CHANGE: The previous version used an SVG feTurbulence filter
|
|
* animating its `seed` attribute 60x/sec (up to 1000 CPU paints/sec on mobile)
|
|
* plus a continuously sweeping gradient beam.
|
|
*
|
|
* Now uses a single static CSS noise pattern (zero CPU overhead, zero JS, zero
|
|
* animation). The grain visual is preserved via a lightweight data-URI PNG tile.
|
|
*/
|
|
export function NeuralGrainOverlay({
|
|
intensity = 0.22,
|
|
active = true,
|
|
className = '',
|
|
}: NeuralGrainOverlayProps) {
|
|
if (!active) return null;
|
|
|
|
return (
|
|
<div
|
|
aria-hidden="true"
|
|
className={`pointer-events-none absolute inset-0 z-10 overflow-hidden mix-blend-overlay ${className}`}
|
|
style={{
|
|
opacity: intensity,
|
|
// Static SVG fractal noise — rendered once by browser, cached, zero CPU animation
|
|
backgroundImage: `url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>")`,
|
|
backgroundSize: '200px 200px',
|
|
backgroundRepeat: 'repeat',
|
|
}}
|
|
/>
|
|
);
|
|
}
|