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

◆ drawDot()

void fl::FlowFieldFloat::drawDot ( float cx,
float cy,
float diam,
u8 cr,
u8 cg,
u8 cb )
private

Definition at line 164 of file flowfield.cpp.hpp.

165 {
166 int w = (int)getWidth();
167 int h = (int)getHeight();
168 float rad = diam * 0.5f;
169 int x0 = fl::max(0, (int)floorf(cx - rad - 1.0f));
170 int x1 = fl::min(w - 1, (int)ceilf(cx + rad + 1.0f));
171 int y0 = fl::max(0, (int)floorf(cy - rad - 1.0f));
172 int y1 = fl::min(h - 1, (int)ceilf(cy + rad + 1.0f));
173 for (int y = y0; y <= y1; y++) {
174 for (int x = x0; x <= x1; x++) {
175 float dx = (x + 0.5f) - cx;
176 float dy = (y + 0.5f) - cy;
177 float dist = sqrtf(dx * dx + dy * dy);
178 float cov = clampf(rad + 0.5f - dist, 0.0f, 1.0f);
179 if (cov <= 0.0f)
180 continue;
181 float inv = 1.0f - cov;
182 int i = idx(y, x);
183 mR[i] = mR[i] * inv + cr * cov;
184 mG[i] = mG[i] * inv + cg * cov;
185 mB[i] = mB[i] * inv + cb * cov;
186 }
187 }
188}
fl::vector< float > mB
Definition flowfield.h:346
fl::vector< float > mG
Definition flowfield.h:346
static float clampf(float v, float lo, float hi) FL_NO_EXCEPT
int idx(int y, int x) const FL_NO_EXCEPT
Definition flowfield.h:323
fl::vector< float > mR
Definition flowfield.h:346
u16 getWidth() const FL_NO_EXCEPT
Definition fx2d.h:25
u16 getHeight() const FL_NO_EXCEPT
Definition fx2d.h:24
constexpr common_type_t< T, U > max(T a, U b) FL_NO_EXCEPT
Definition math.h:75
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NO_EXCEPT
Definition math.h:71
float sqrtf(float value) FL_NO_EXCEPT
Definition math.h:461
float floorf(float value) FL_NO_EXCEPT
Definition math.h:312
float ceilf(float value) FL_NO_EXCEPT
Definition math.h:318

References fl::ceilf(), clampf(), fl::FL_NO_EXCEPT, fl::floorf(), fl::Fx2d::getHeight(), fl::Fx2d::getWidth(), idx(), fl::max(), mB, mG, fl::min(), mR, fl::sqrtf(), fl::x, and fl::y.

Referenced by emitLissajousLine(), and emitOrbitalDots().

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