FastLED 3.9.15
Loading...
Searching...
No Matches

◆ smoothLerpCRGB()

CRGB NoiseVariantManager::smoothLerpCRGB ( const CRGB & a,
const CRGB & b,
float t )
inlineprivate

Definition at line 525 of file FxNoiseRing.h.

525 {
526 // Apply smooth curve to transition
527 float smooth_t = t * t * (3.0f - 2.0f * t); // Smoothstep function
528
529 // Preserve brightness during transition to avoid flickering
530 float brightness_a = (a.r + a.g + a.b) / 765.0f;
531 float brightness_b = (b.r + b.g + b.b) / 765.0f;
532 float target_brightness = brightness_a + (brightness_b - brightness_a) * smooth_t;
533
534 CRGB result = CRGB(
535 a.r + (int)((b.r - a.r) * smooth_t),
536 a.g + (int)((b.g - a.g) * smooth_t),
537 a.b + (int)((b.b - a.b) * smooth_t)
538 );
539
540 // Brightness compensation
541 float current_brightness = (result.r + result.g + result.b) / 765.0f;
542 if (current_brightness > 0.01f) {
543 float compensation = target_brightness / current_brightness;
544 compensation = min(compensation, 2.0f); // Limit boost
545 result.r = min(255, (int)(result.r * compensation));
546 result.g = min(255, (int)(result.g * compensation));
547 result.b = min(255, (int)(result.b * compensation));
548 }
549
550 return result;
551 }
float current_brightness
static uint32_t t
Definition Luminova.h:54

References current_brightness, and t.

Referenced by renderPixel().

+ Here is the caller graph for this function: