FastLED 3.9.15
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 163 of file flowfield.cpp.hpp.

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

References fl::ceilf(), clampf(), 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: