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

◆ emitOrbitalDots()

void fl::FlowFieldFP::emitOrbitalDots ( s16x16 t)
private

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

722 {
723 int w = mState.width;
724 int h = mState.height;
725 int minDim = fl::min(w, h);
726 int n = mParams.dot_count;
727 constexpr s16x16 half(0.5f);
728 constexpr s16x16 two_pi(6.2831853f);
729 s16x16 fn = s16x16(n);
730 s16x16 inv_fn = s16x16(1) / fn; // Precompute reciprocal (was dividing per dot)
731 s16x16 ocx = s16x16(w) * half - half;
732 s16x16 ocy = s16x16(h) * half - half;
733 s16x16 orad = s16x16(minDim) * s16x16(0.35f);
734 s16x16 base = t * s16x16(3);
735 constexpr s16x16 dotDiam(1.5f);
736 s16x16 step = two_pi * inv_fn; // Use precomputed reciprocal
737
738 for (int i = 0; i < n; i++) {
739 s16x16 a = base + s16x16(i) * step;
740 s16x16 sin_a, cos_a;
741 s16x16::sincos(a, sin_a, cos_a);
742 s16x16 cx = ocx + cos_a * orad;
743 s16x16 cy = ocy + sin_a * orad;
744 CRGB c = rainbow(t, mColorShift_fp, s16x16(i) * inv_fn);
745 drawDot(cx, cy, dotDiam, c.r, c.g, c.b);
746 }
747}
void rainbow()
Params mParams
Definition flowfield.h:286
FlowFieldFPState mState
Definition flowfield.h:400
s16x16 mColorShift_fp
Definition flowfield.h:405
void drawDot(s16x16 cx, s16x16 cy, s16x16 diam, u8 cr, u8 cg, u8 cb)
static FASTLED_FORCE_INLINE void sincos(s16x16 angle, s16x16 &out_sin, s16x16 &out_cos) FL_NOEXCEPT
Definition s16x16.h:311
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
Definition math.h:71
fl::CRGB CRGB
Definition video.h:15
constexpr enable_if< is_fixed_point< T >::value, T >::type step(T edge, T x) FL_NOEXCEPT

References drawDot(), mColorShift_fp, fl::min(), fl::FlowField::mParams, mState, rainbow(), fl::s16x16::sincos(), fl::step(), and fl::t.

Referenced by drawImpl().

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