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

◆ sampleNearest()

CRGB fl::sampleNearest ( const CRGB * grid,
const XYMap & xyMap,
float x,
float y )

Nearest-neighbor sample from a 2D CRGB grid.

Definition at line 42 of file sample.cpp.hpp.

42 {
43 int xi = static_cast<int>(x + 0.5f); // Round to nearest
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)];
48}
fl::XYMap xyMap
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
Definition math.h:71
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Definition math.h:75

References max(), min(), x, xyMap, and y.

Referenced by sample().

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