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

◆ traverseGridSegment()

template<typename GridVisitor>
void fl::traverseGridSegment ( const vec2f & start,
const vec2f & end,
GridVisitor & visitor )
inline

Traverse a grid segment by selecting the cells that are crossed.

This version will select the fastest integer implementation based on the length of the segment. Most of the time it will call traverseGridSegment16() since segment spans are typically < 256 pixels.

Template Parameters
GridVisitor
Parameters
startstart point
endend point
visitorcalled for each cell visited.

Fully tested.

Definition at line 282 of file traverse_grid.h.

283 {
284 float dx = fl::abs(end.x - start.x);
285 float dy = fl::abs(end.y - start.y);
286 float maxRange = fl::max(dx, dy);
287
288 // if (maxRange < 256.0f) {
289 // // Use Q8.8 (16-bit signed) if within ±127
290 // traverseGridSegment16(start, end, visitor);
291 // }
292 // else if (maxRange < 16777216.0f) {
293 // // Use Q24.8 (32-bit signed) if within ±8 million
294 // traverseGridSegment32(start, end, visitor);
295 // }
296 // else {
297 // // Fall back to floating-point
298 // traverseGridSegment(start, end, visitor);
299 // }
300
301 if (maxRange < 256.0f) {
302 // Use Q8.8 (16-bit signed) if within ±127
303 traverseGridSegment16(start, end, visitor);
304 } else {
305 // Use Q24.8 (32-bit signed) if within ±8 million
306 traverseGridSegment32(start, end, visitor);
307 }
308}
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Definition math.h:75
constexpr T * end(T(&array)[N]) FL_NOEXCEPT
void traverseGridSegment16(const vec2f &start, const vec2f &end, GridVisitor &visitor)
Traverse a grid segment using fixed-point 8.8 arithmetic.
void traverseGridSegment32(const vec2f &start, const vec2f &end, GridVisitor &visitor)
constexpr enable_if< is_fixed_point< T >::value, T >::type abs(T x) FL_NOEXCEPT
value_type y
Definition geometry.h:191
value_type x
Definition geometry.h:190

References abs(), end(), max(), traverseGridSegment16(), traverseGridSegment32(), fl::vec2< T >::x, and fl::vec2< T >::y.

+ Here is the call graph for this function: