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

◆ plotSoftDot()

void plotSoftDot ( float fx,
float fy,
float s )

Definition at line 85 of file Luminova.h.

85 {
86 // map s (decays from 5) to a pixel radius 1..3
87 float r = constrain(s * 0.5f, 1.0f, 3.0f);
88 int R = (int)fl::ceilf(r);
89 int cx = (int)fl::roundf(fx);
90 int cy = (int)fl::roundf(fy);
91 float r2 = r * r;
92 for (int dy = -R; dy <= R; ++dy) {
93 for (int dx = -R; dx <= R; ++dx) {
94 float d2 = dx * dx + dy * dy;
95 if (d2 <= r2) {
96 // falloff toward edge
97 float fall = 1.0f - (d2 / (r2 + 0.0001f));
98 uint8_t v = (uint8_t)constrain(255.0f * fall, 0.0f, 255.0f);
99 plotDot(cx + dx, cy + dy, v);
100 }
101 }
102 }
103}
void plotDot(int x, int y, uint8_t v)
Definition Luminova.h:77
float roundf(float value) FL_NOEXCEPT
Definition math.h:316
float ceilf(float value) FL_NOEXCEPT
Definition math.h:310
unsigned char uint8_t
Definition s16x16x4.h:209

References fl::ceilf(), plotDot(), and fl::roundf().

Referenced by loop().

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