FastLED 3.10.10
Loading...
Searching...
No Matches

◆ polyColClamped()

int fl::gfx::detail::polyColClamped ( fl::i64 v,
int width )
inline

Pixel column floor(v / 65536) of a row-extent bound v = x +/- hw, clamped to [-1, width].

A near-horizontal edge puts v ~2^45 Q16 off the canvas even for a small on-canvas polygon, so the column must be clamped before it is narrowed to int (16-bit on AVR, where the unclamped value wrapped and blanked whole rows). The clamp is lossless for the kernel: every use compares the bound against a column in [0, width).

Definition at line 291 of file primitives.h.

291 {
292 // |x| < 2^45 + kPolyQ16Max and hw < 2^45 (see PolyEdge), so |v| < 2^47
293 // and v >> 16 fits i32 under the vertex clamp.
294 const fl::i32 c = static_cast<fl::i32>(floorDiv16I64(v));
295 if (c < -1) return -1;
296 if (c > width) return width;
297 return static_cast<int>(c); // fl-lint: int-template-ok clamped to [-1, width] first
298}
fl::i64 floorDiv16I64(fl::i64 v) FL_NO_EXCEPT
Same for i64 (line crossings can exceed i32 for steep short edges).
Definition primitives.h:283
u8 width
Definition blur.h:186

References fl::FL_NO_EXCEPT, floorDiv16I64(), polyColClamped(), and fl::width.

Referenced by drawPolygonCore(), and polyColClamped().

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