FastLED 3.10.8
Loading...
Searching...
No Matches

◆ plotSoftDot()

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

Definition at line 74 of file luminova.cpp.hpp.

74 {
75 // Map s (decays from ~3) to a pixel radius 1..3
76 float r = fl::clamp<float>(s * 0.5f, 1.0f, 3.0f);
77 int R = static_cast<int>(fl::ceil(r));
78 // Avoid roundf() to prevent AVR macro conflicts; do manual symmetric rounding
79 int cx = static_cast<int>(fx + (fx >= 0.0f ? 0.5f : -0.5f));
80 int cy = static_cast<int>(fy + (fy >= 0.0f ? 0.5f : -0.5f));
81 float r2 = r * r;
82 for (int dy = -R; dy <= R; ++dy) {
83 for (int dx = -R; dx <= R; ++dx) {
84 float d2 = static_cast<float>(dx * dx + dy * dy);
85 if (d2 <= r2) {
86 float fall = 1.0f - (d2 / (r2 + 0.0001f));
87 float vf = 255.0f * fall;
88 if (vf < 0.0f) vf = 0.0f;
89 if (vf > 255.0f) vf = 255.0f;
90 u8 v = static_cast<u8>(vf);
91 plotDot(leds, cx + dx, cy + dy, v);
92 }
93 }
94 }
95}
CRGB leds[1]
void plotDot(fl::span< CRGB > leds, int x, int y, u8 v) const FL_NO_EXCEPT
unsigned char u8
Definition stdint.h:131
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NO_EXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type ceil(T x) FL_NO_EXCEPT

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

+ Here is the call graph for this function: