Bilinear interpolation sample from a 2D CRGB grid.
Definition at line 18 of file sample.cpp.hpp.
18 {
19 int x0 =
static_cast<int>(
x);
20 int y0 =
static_cast<int>(
y);
21 int x1 =
min(x0 + 1,
static_cast<int>(
xyMap.getWidth()) - 1);
22 int y1 =
min(y0 + 1,
static_cast<int>(
xyMap.getHeight()) - 1);
23
24
25 x0 =
max(0,
min(x0,
static_cast<int>(
xyMap.getWidth()) - 1));
26 y0 =
max(0,
min(y0,
static_cast<int>(
xyMap.getHeight()) - 1));
27
30
31
32 CRGB c00 = grid[
xyMap.mapToIndex(x0, y0)];
33 CRGB c10 = grid[
xyMap.mapToIndex(x1, y0)];
34 CRGB c01 = grid[
xyMap.mapToIndex(x0, y1)];
35 CRGB c11 = grid[
xyMap.mapToIndex(x1, y1)];
36
37
41}
constexpr common_type_t< T, U > max(T a, U b) FL_NO_EXCEPT
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NO_EXCEPT
static CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2) FL_NO_EXCEPT
Representation of an 8-bit RGB pixel (Red, Green, Blue)
References fl::CRGB::blend(), FL_NO_EXCEPT, max(), min(), x, xyMap, and y.
Referenced by sample().