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

◆ plotSoftDot()

void fl::Luminova::plotSoftDot ( CRGB * leds,
float fx,
float fy,
float s ) const
private

Definition at line 63 of file luminova.cpp.

63 {
64 // Map s (decays from ~3) to a pixel radius 1..3
65 float r = fl::clamp<float>(s * 0.5f, 1.0f, 3.0f);
66 int R = static_cast<int>(fl::ceil(r));
67 // Avoid roundf() to prevent AVR macro conflicts; do manual symmetric rounding
68 int cx = static_cast<int>(fx + (fx >= 0.0f ? 0.5f : -0.5f));
69 int cy = static_cast<int>(fy + (fy >= 0.0f ? 0.5f : -0.5f));
70 float r2 = r * r;
71 for (int dy = -R; dy <= R; ++dy) {
72 for (int dx = -R; dx <= R; ++dx) {
73 float d2 = static_cast<float>(dx * dx + dy * dy);
74 if (d2 <= r2) {
75 float fall = 1.0f - (d2 / (r2 + 0.0001f));
76 float vf = 255.0f * fall;
77 if (vf < 0.0f) vf = 0.0f;
78 if (vf > 255.0f) vf = 255.0f;
79 uint8_t v = static_cast<uint8_t>(vf);
80 plotDot(leds, cx + dx, cy + dy, v);
81 }
82 }
83 }
84}
CRGB leds[NUM_LEDS]
void plotDot(CRGB *leds, int x, int y, uint8_t v) const
Definition luminova.cpp:55
FASTLED_FORCE_INLINE T clamp(T value, T min, T max)
Definition clamp.h:10
T ceil(T value)
Definition math.h:39

References fl::ceil(), fl::clamp(), leds, and plotDot().

Referenced by draw().

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