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 387 of file crgb.h.

387 {
388 uint8_t max = red;
389 if( green > max) max = green;
390 if( blue > max) max = blue;
391
392 // stop div/0 when color is black
393 if(max > 0) {
394 uint16_t factor = ((uint16_t)(limit) * 256) / max;
395 red = (red * factor) / 256;
396 green = (green * factor) / 256;
397 blue = (blue * factor) / 256;
398 }
399 }

References FASTLED_FORCE_INLINE.