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

◆ at_subpixel()

Tile2x2_u8 fl::XYPathRenderer::at_subpixel ( float alpha)

Definition at line 31 of file xypath_renderer.cpp.

31 {
32 // 1) continuous point, in “pixel‐centers” coordinates [0.5 … W–0.5]
33 if (!mDrawBoundsSet) {
34 FASTLED_WARN("XYPathRenderer::at_subpixel: draw bounds not set");
35 return Tile2x2_u8();
36 }
37 vec2f xy = at(alpha);
38
39 // 2) shift back so whole‐pixels go 0…W–1, 0…H–1
40 float x = xy.x - 0.5f;
41 float y = xy.y - 0.5f;
42
43 // 3) integer cell indices
44 int cx = static_cast<int>(floorf(x));
45 int cy = static_cast<int>(floorf(y));
46
47 // 4) fractional offsets in [0..1)
48 float fx = x - cx;
49 float fy = y - cy;
50
51 // 5) bilinear weights
52 float w_ll = (1 - fx) * (1 - fy); // lower‑left
53 float w_lr = fx * (1 - fy); // lower‑right
54 float w_ul = (1 - fx) * fy; // upper‑left
55 float w_ur = fx * fy; // upper‑right
56
57 // 6) build Tile2x2_u8 anchored at (cx,cy)
58 Tile2x2_u8 out(vec2<int>(cx, cy));
59 out.lower_left() = to_uint8(w_ll);
60 out.lower_right() = to_uint8(w_lr);
61 out.upper_left() = to_uint8(w_ul);
62 out.upper_right() = to_uint8(w_ur);
63
64 return out;
65}
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:82
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:83
unsigned int xy(unsigned int x, unsigned int y)
vec2f at(float alpha)
Definition xypath.cpp:123
vec2< float > vec2f
Definition geometry.h:151
#define FASTLED_WARN
Definition warn.h:7

References at(), FASTLED_WARN, fl::Tile2x2_u8::lower_left(), fl::Tile2x2_u8::lower_right(), mDrawBoundsSet, fl::Tile2x2_u8::upper_left(), fl::Tile2x2_u8::upper_right(), x, xy(), and y.

Referenced by rasterize().

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