diff options
author | Mark Kriegsman <kriegsman@tr.org> | 2014-11-13 05:57:23 +0300 |
---|---|---|
committer | Mark Kriegsman <kriegsman@tr.org> | 2014-11-13 05:57:23 +0300 |
commit | 8dd7cc36c914df293ca30dd338354255067c877d (patch) | |
tree | 5e1f303f03b00864ab8d2aa09984c11226ed179d /colorutils.h | |
parent | 2f21f1f9f0175a096e33d61cd9072fb0bbe66e94 (diff) |
Added blur1d, blur2d, and fadeUsingColor
Diffstat (limited to 'colorutils.h')
-rw-r--r-- | colorutils.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/colorutils.h b/colorutils.h index 9034c1ee..76542acf 100644 --- a/colorutils.h +++ b/colorutils.h @@ -219,6 +219,19 @@ void fade_raw( CRGB* leds, uint16_t num_leds, uint8_t fadeBy); // way down to black even if 'scale' is not zero. void nscale8( CRGB* leds, uint16_t num_leds, uint8_t scale); +// fadeUsingColor - scale down the brightness of an array of pixels, +// as though it were seen through a transparent +// filter with the specified color. +// For example, if the colormask is +// CRGB( 200, 100, 50) +// then the pixels' red will be faded to 200/256ths, +// their green to 100/256ths, and their blue to 50/256ths. +// This particular example give a 'hot fade' look, +// with white fading to yellow, then red, then black. +// You can also use colormasks like CRGB::Blue to +// zero out the red and green elements, leaving blue +// (largely) the same. +void fadeUsingColor( CRGB* leds, uint16_t numLeds, const CRGB& colormask); // Pixel blending @@ -256,6 +269,27 @@ void nblend( CHSV* existing, CHSV* overlay, uint16_t count, fract8 amountOfOver TGradientDirectionCode directionCode = SHORTEST_HUES); +// blur1d: one-dimensional blur filter. Spreads light to 2 line neighbors. +// blur2d: two-dimensional blur filter. Spreads light to 8 XY neighbors. +// +// 0 = no spread at all +// 64 = moderate spreading +// 172 = maximum smooth, even spreading +// +// 173..255 = wider spreading, but increasing flicker +// +// Total light is NOT entirely conserved, so many repeated +// calls to 'blur' will also result in the light fading, +// eventually all the way to black; this is by design so that +// it can be used to (slowly) clear the LEDs to black. +void blur1d( CRGB* leds, uint16_t numLeds, fract8 blur_amount); +void blur2d( CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount); + +// blurRows: perform a blur1d on every row of a rectangular matrix +void blurRows( CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount); +// blurColumns: perform a blur1d on each column of a rectangular matrix +void blurColumns(CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount); + // CRGB HeatColor( uint8_t temperature) // |