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

◆ maximizeBrightness()

FASTLED_FORCE_INLINE void CRGB::maximizeBrightness ( uint8_t limit = 255)
inline

Maximize the brightness of this CRGB object.

This makes the individual color channels as bright as possible while keeping the same value differences between channels.

Note
This does not keep the same ratios between channels, just the same difference in absolute values.

Definition at line 392 of file crgb.h.

392 {
393 uint8_t max = red;
394 if( green > max) max = green;
395 if( blue > max) max = blue;
396
397 // stop div/0 when color is black
398 if(max > 0) {
399 uint16_t factor = ((uint16_t)(limit) * 256) / max;
400 red = (red * factor) / 256;
401 green = (green * factor) / 256;
402 blue = (blue * factor) / 256;
403 }
404 }

References FASTLED_FORCE_INLINE.