FastLED 3.10.8
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 43 of file sample.cpp.hpp.

43 {
44 int xi = static_cast<int>(x + 0.5f); // Round to nearest
45 int yi = static_cast<int>(y + 0.5f);
46 xi = max(0, min(xi, static_cast<int>(xyMap.getWidth()) - 1));
47 yi = max(0, min(yi, static_cast<int>(xyMap.getHeight()) - 1));
48 return grid[xyMap.mapToIndex(xi, yi)];
49}
fl::XYMap xyMap
constexpr common_type_t< T, U > max(T a, U b) FL_NO_EXCEPT
Definition math.h:75
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NO_EXCEPT
Definition math.h:71

References FL_NO_EXCEPT, 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: