18 int x0 =
static_cast<int>(
x);
19 int y0 =
static_cast<int>(
y);
20 int x1 =
min(x0 + 1,
static_cast<int>(
xyMap.getWidth()) - 1);
21 int y1 =
min(y0 + 1,
static_cast<int>(
xyMap.getHeight()) - 1);
24 x0 =
max(0,
min(x0,
static_cast<int>(
xyMap.getWidth()) - 1));
25 y0 =
max(0,
min(y0,
static_cast<int>(
xyMap.getHeight()) - 1));
31 CRGB c00 = grid[
xyMap.mapToIndex(x0, y0)];
32 CRGB c10 = grid[
xyMap.mapToIndex(x1, y0)];
33 CRGB c01 = grid[
xyMap.mapToIndex(x0, y1)];
34 CRGB c11 = grid[
xyMap.mapToIndex(x1, y1)];
43 int xi =
static_cast<int>(
x + 0.5f);
44 int yi =
static_cast<int>(
y + 0.5f);
45 xi =
max(0,
min(xi,
static_cast<int>(
xyMap.getWidth()) - 1));
46 yi =
max(0,
min(yi,
static_cast<int>(
xyMap.getHeight()) - 1));
47 return grid[
xyMap.mapToIndex(xi, yi)];
Defines the 8-bit red, green, and blue (RGB) pixel type in the fl namespace.
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
CRGB sampleNearest(const CRGB *grid, const XYMap &xyMap, float x, float y)
Nearest-neighbor sample from a 2D CRGB grid.
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
CRGB sample(const CRGB *grid, const XYMap &xyMap, float x, float y, SampleMode mode)
Sample a pixel from a 2D CRGB grid at floating-point coordinates.
SampleMode
Interpolation mode for sampling a 2D grid.
@ SAMPLE_BILINEAR
Bilinear interpolation (smooth)
CRGB sampleBilinear(const CRGB *grid, const XYMap &xyMap, float x, float y)
Bilinear interpolation sample from a 2D CRGB grid.
Base definition for an LED controller.
2D grid sampling with bilinear and nearest-neighbor interpolation
static CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2) FL_NOEXCEPT
Representation of an 8-bit RGB pixel (Red, Green, Blue)