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

◆ map8()

LIB8STATIC uint8_t map8 ( uint8_t in,
uint8_t rangeStart,
uint8_t rangeEnd )

Map from one full-range 8-bit value into a narrower range of 8-bit values, possibly a range of hues.

E.g. map myValue into a hue in the range blue..purple..pink..red

hue = map8( myValue, HUE_BLUE, HUE_RED);
LIB8STATIC uint8_t map8(uint8_t in, uint8_t rangeStart, uint8_t rangeEnd)
Map from one full-range 8-bit value into a narrower range of 8-bit values, possibly a range of hues.
Definition lib8tion.h:559
@ HUE_BLUE
Blue (225°)
Definition chsv.h:103
@ HUE_RED
Red (0°)
Definition chsv.h:98

Combines nicely with the waveform functions (like sin8(), etc) to produce continuous hue gradients back and forth:

hue = map8( sin8( myValue), HUE_BLUE, HUE_RED);
#define sin8
Platform-independent alias of the fast sin implementation.
Definition trig8.h:216

Mathematically simiar to lerp8by8(), but arguments are more like Arduino's "map"; this function is similar to

map( in, 0, 255, rangeStart, rangeEnd)

but faster and specifically designed for 8-bit values.

Definition at line 559 of file lib8tion.h.

560{
561 uint8_t rangeWidth = rangeEnd - rangeStart;
562 uint8_t out = scale8( in, rangeWidth);
563 out += rangeStart;
564 return out;
565}
LIB8STATIC_ALWAYS_INLINE uint8_t scale8(uint8_t i, fract8 scale)
Scale one byte by a second one, which is treated as the numerator of a fraction whose denominator is ...
Definition scale8.h:34

References LIB8STATIC, and scale8().

Referenced by ColorFromPalette(), ColorFromPalette(), ColorFromPalette(), ColorFromPalette(), ColorFromPalette(), and ColorFromPalette().

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