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

◆ maximizeBrightness()

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

398 {
399 u8 max = red;
400 if( green > max) max = green;
401 if( blue > max) max = blue;
402
403 // stop div/0 when color is black
404 if(max > 0) {
405 u16 factor = ((u16)(limit) * 256) / max;
406 red = (red * factor) / 256;
407 green = (green * factor) / 256;
408 blue = (blue * factor) / 256;
409 }
410 }
unsigned char u8
Definition stdint.h:131
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Definition math.h:75

References FASTLED_FORCE_INLINE, FL_NOEXCEPT, fl::max(), and maximizeBrightness().

Referenced by maximizeBrightness().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: