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

◆ maximizeBrightness()

FASTLED_FORCE_INLINE void CRGB::maximizeBrightness ( fl::u8 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 455 of file crgb.h.

455 {
456 fl::u8 max = red;
457 if( green > max) max = green;
458 if( blue > max) max = blue;
459
460 // stop div/0 when color is black
461 if(max > 0) {
462 fl::u16 factor = ((fl::u16)(limit) * 256) / max;
463 red = (red * factor) / 256;
464 green = (green * factor) / 256;
465 blue = (blue * factor) / 256;
466 }
467 }
unsigned char u8
Definition int.h:17

References FASTLED_FORCE_INLINE.