diff --git a/client/src/components/Screensaver.tsx b/client/src/components/Screensaver.tsx index 1e73eb8..f88f1dd 100644 --- a/client/src/components/Screensaver.tsx +++ b/client/src/components/Screensaver.tsx @@ -39,7 +39,7 @@ function isNightTime(): boolean { return hour >= 0 && hour < 6; } -// Get fade opacity based on time (0 = full fade, 1 = no fade) +// Get fade opacity based on time (0 = completely off, 1 = full brightness) function getNightFadeOpacity(): number { if (!isNightTime()) return 1; @@ -47,18 +47,23 @@ function getNightFadeOpacity(): number { const minute = new Date().getMinutes(); // Calculate fade based on how far into the night we are - // Start fading at midnight (0), reach max fade at 3am, then fade back until 6am + // 15-minute fade out starting at midnight, 15-minute fade in starting at 5:45am const totalMinutes = hour * 60 + minute; - const maxFadeAt = 3 * 60; // 3am in minutes + const fadeOutEnd = 15; // 12:15am + const fadeInStart = 5 * 60 + 45; // 5:45am + const fadeInEnd = 6 * 60; // 6:00am - if (totalMinutes <= maxFadeAt) { - // Fading in: 0 to 3am - return Math.max(0.1, 1 - (totalMinutes / maxFadeAt) * 0.9); + if (totalMinutes <= fadeOutEnd) { + // Fading out: midnight to 12:15am (15 minutes) + const fadeProgress = totalMinutes / fadeOutEnd; + return 1 - fadeProgress; // 1 to 0 + } else if (totalMinutes >= fadeInStart) { + // Fading in: 5:45am to 6:00am (15 minutes) + const fadeProgress = (totalMinutes - fadeInStart) / (fadeInEnd - fadeInStart); + return fadeProgress; // 0 to 1 } else { - // Fading out: 3am to 6am - const fadeOutMinutes = totalMinutes - maxFadeAt; - const fadeOutDuration = 3 * 60; // 3 hours - return Math.max(0.1, 0.1 + (fadeOutMinutes / fadeOutDuration) * 0.9); + // Completely off: 12:15am to 5:45am + return 0; } }