MCPcopy Create free account
hub / github.com/FastLED/FastLED / sampleNearest

Function sampleNearest

src/fl/gfx/sample.cpp.hpp:42–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42CRGB sampleNearest(const CRGB *grid, const XYMap &xyMap, float x, float y) {
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}
49
50} // namespace fl

Callers 1

sampleFunction · 0.85

Calls 4

maxFunction · 0.85
getWidthMethod · 0.45
getHeightMethod · 0.45
mapToIndexMethod · 0.45

Tested by

no test coverage detected