FastLED 3.9.3
|
Fast linear interpolation functions, such as could be used for Perlin noise, etc.
A note on the structure of the lerp functions: The cases for b>a and b<=a are handled separately for speed. Without knowing the relative order of a and b, the value (a-b) might be overflow the width of a or b, and have to be promoted to a wider, slower type. To avoid that, we separate the two cases, and are able to do all the math in the same width as the arguments, which is much faster and smaller on AVR.
Functions | |
LIB8STATIC uint8_t | lerp8by8 (uint8_t a, uint8_t b, fract8 frac) |
Linear interpolation between two unsigned 8-bit values, with 8-bit fraction. | |
LIB8STATIC uint16_t | lerp16by16 (uint16_t a, uint16_t b, fract16 frac) |
Linear interpolation between two unsigned 16-bit values, with 16-bit fraction. | |
LIB8STATIC uint16_t | lerp16by8 (uint16_t a, uint16_t b, fract8 frac) |
Linear interpolation between two unsigned 16-bit values, with 8-bit fraction. | |
LIB8STATIC int16_t | lerp15by8 (int16_t a, int16_t b, fract8 frac) |
Linear interpolation between two signed 15-bit values, with 8-bit fraction. | |
LIB8STATIC int16_t | lerp15by16 (int16_t a, int16_t b, fract16 frac) |
Linear interpolation between two signed 15-bit values, with 8-bit fraction. | |
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. | |
LIB8STATIC int16_t lerp15by16 | ( | int16_t | a, |
int16_t | b, | ||
fract16 | frac ) |
Linear interpolation between two signed 15-bit values, with 8-bit fraction.
Definition at line 523 of file lib8tion.h.
LIB8STATIC int16_t lerp15by8 | ( | int16_t | a, |
int16_t | b, | ||
fract8 | frac ) |
Linear interpolation between two signed 15-bit values, with 8-bit fraction.
Definition at line 506 of file lib8tion.h.
LIB8STATIC uint16_t lerp16by16 | ( | uint16_t | a, |
uint16_t | b, | ||
fract16 | frac ) |
Linear interpolation between two unsigned 16-bit values, with 16-bit fraction.
Definition at line 472 of file lib8tion.h.
LIB8STATIC uint16_t lerp16by8 | ( | uint16_t | a, |
uint16_t | b, | ||
fract8 | frac ) |
Linear interpolation between two unsigned 16-bit values, with 8-bit fraction.
Definition at line 489 of file lib8tion.h.
LIB8STATIC uint8_t lerp8by8 | ( | uint8_t | a, |
uint8_t | b, | ||
fract8 | frac ) |
Linear interpolation between two unsigned 8-bit values, with 8-bit fraction.
Definition at line 455 of file lib8tion.h.
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
Combines nicely with the waveform functions (like sin8(), etc) to produce continuous hue gradients back and forth:
Mathematically simiar to lerp8by8(), but arguments are more like Arduino's "map"; this function is similar to
but faster and specifically designed for 8-bit values.
Definition at line 559 of file lib8tion.h.