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

◆ drawImpl()

void fl::FlowFieldFP::drawImpl ( DrawContext context,
u32 dt_ms,
u32 t_ms )
overrideprotectedvirtual

Subclasses implement rendering given the time delta and total time.

Parameters
dt_msMilliseconds since last draw (capped to prevent huge jumps).
t_msMilliseconds since first draw.

Implements fl::FlowField.

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

983 {
984 syncParams();
985
986 s16x16 dt = s16x16(dt_ms * 0.001f);
987 s16x16 t = s16x16(t_ms * 0.001f);
988
989 i32 dt_raw = dt.raw();
990
991 flowPrepare(t);
992 switch (mParams.emitter_mode) {
993 case 0:
995 break;
996 case 1:
998 break;
999 case 2:
1002 break;
1003 default:
1005 break;
1006 }
1007 flowAdvect(dt_raw);
1008
1009 // Output: convert Q16.16 grids to LED pixels
1010 int w = mState.width;
1011 int h = mState.height;
1012 const i32 *rp = mState.r.data();
1013 const i32 *gp = mState.g.data();
1014 const i32 *bp = mState.b.data();
1015 fl::span<CRGB> out = context.leds;
1016 for (int y = 0; y < h; y++) {
1017 int row_base = y * w;
1018 for (int x = 0; x < w; x++) {
1019 int i = row_base + x;
1020 u16 ledIdx = mXyMap.mapToIndex(static_cast<u16>(x), static_cast<u16>(y));
1021 out[ledIdx].r = q16_to_u8(rp[i]);
1022 out[ledIdx].g = q16_to_u8(gp[i]);
1023 out[ledIdx].b = q16_to_u8(bp[i]);
1024 }
1025 }
1026
1027 if (mParams.show_flow_vectors) {
1028 drawFlowVectors(context.leds);
1029 }
1030}
Params mParams
Definition flowfield.h:286
FlowFieldFPState mState
Definition flowfield.h:400
void flowAdvect(i32 dt_raw)
void flowPrepare(s16x16 t)
static u8 q16_to_u8(i32 v)
void emitLissajousLine(s16x16 t)
void emitOrbitalDots(s16x16 t)
void drawFlowVectors(fl::span< CRGB > leds)
XYMap mXyMap
Definition fx2d.h:30

References drawFlowVectors(), emitLissajousLine(), emitOrbitalDots(), flowAdvect(), flowPrepare(), fl::DrawContext::leds, fl::FlowField::mParams, mState, fl::Fx2d::mXyMap, q16_to_u8(), fl::s16x16::raw(), syncParams(), fl::t, fl::x, and fl::y.

+ Here is the call graph for this function: