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

◆ emitLissajousLine()

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

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

678 {
679 int w = mState.width;
680 int h = mState.height;
681 constexpr s16x16 half(0.5f);
682 s16x16 cx = s16x16(w - 1) * half;
683 s16x16 cy = s16x16(h - 1) * half;
684
685 // Pre-multiply t * s once (was computed 4 times)
686 s16x16 ts = t * mEndpointSpeed_fp;
687
688 // Pre-multiply center * radius constants (was computing cx*k and cy*k each time)
689 constexpr s16x16 k_0742(0.742f);
690 constexpr s16x16 k_0677(0.677f);
691 constexpr s16x16 k_0774(0.774f);
692 constexpr s16x16 k_0710(0.710f);
693 s16x16 cx_r1 = cx * k_0742;
694 s16x16 cy_r1 = cy * k_0677;
695 s16x16 cx_r2 = cx * k_0774;
696 s16x16 cy_r2 = cy * k_0710;
697
698 // Pre-multiply ts * frequency constants (was computing ts*k each time)
699 constexpr s16x16 k_113(1.13f);
700 constexpr s16x16 k_171(1.71f);
701 constexpr s16x16 k_189(1.89f);
702 constexpr s16x16 k_137(1.37f);
703 constexpr s16x16 k_020(0.20f);
704 constexpr s16x16 k_130(1.30f);
705 constexpr s16x16 k_220(2.20f);
706 constexpr s16x16 k_070(0.70f);
707
708 s16x16 x1 = cx + cx_r1 * s16x16::sin(ts * k_113 + k_020);
709 s16x16 y1 = cy + cy_r1 * s16x16::sin(ts * k_171 + k_130);
710 s16x16 x2 = cx + cx_r2 * s16x16::sin(ts * k_189 + k_220);
711 s16x16 y2 = cy + cy_r2 * s16x16::sin(ts * k_137 + k_070);
712
713 drawAALine(x1, y1, x2, y2, t, mColorShift_fp);
714
715 CRGB endA = rainbow(t, mColorShift_fp, s16x16());
716 CRGB endB = rainbow(t, mColorShift_fp, half);
717 constexpr s16x16 discDiam(1.7f);
718 drawDot(x1, y1, discDiam, endA.r, endA.g, endA.b);
719 drawDot(x2, y2, discDiam, endB.r, endB.g, endB.b);
720}
void rainbow()
FlowFieldFPState mState
Definition flowfield.h:400
void drawAALine(s16x16 x0, s16x16 y0, s16x16 x1, s16x16 y1, s16x16 t, s16x16 colorShift)
s16x16 mColorShift_fp
Definition flowfield.h:405
void drawDot(s16x16 cx, s16x16 cy, s16x16 diam, u8 cr, u8 cg, u8 cb)
s16x16 mEndpointSpeed_fp
Definition flowfield.h:407
FASTLED_FORCE_INLINE s16x16 sin() const FL_NOEXCEPT
Definition s16x16.h:271
fl::CRGB CRGB
Definition video.h:15

References drawAALine(), drawDot(), mColorShift_fp, mEndpointSpeed_fp, mState, rainbow(), fl::s16x16::sin(), and fl::t.

Referenced by drawImpl().

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