FastLED 3.9.15
Loading...
Searching...
No Matches
Linear Interpolation

Detailed Description

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.

+ Collaboration diagram for Linear Interpolation:

Functions

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 int16_t lerp15by8 (int16_t a, int16_t b, fract8 frac)
 Linear interpolation between two signed 15-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 uint8_t lerp8by8 (uint8_t a, uint8_t b, fract8 frac)
 Linear interpolation between two unsigned 8-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.