MCPcopy Create free account
hub / github.com/FastLED/FastLED / draw

Method draw

src/fl/fx/1d/pride2015.h:32–70  ·  view source on GitHub ↗

This function draws rainbows with an ever-changing, widely-varying set of parameters.

Source from the content-addressed store, hash-verified

30// This function draws rainbows with an ever-changing,
31// widely-varying set of parameters.
32void Pride2015::draw(Fx::DrawContext ctx) {
33 if (ctx.leds.empty() || mNumLeds == 0) {
34 return;
35 }
36
37 u8 sat8 = beatsin88(87, 220, 250);
38 u8 brightdepth = beatsin88(341, 96, 224);
39 u16 brightnessthetainc16 = beatsin88(203, (25 * 256), (40 * 256));
40 u8 msmultiplier = beatsin88(147, 23, 60);
41
42 u16 hue16 = mHue16;
43 u16 hueinc16 = beatsin88(113, 1, 3000);
44
45 u16 ms = fl::millis();
46 u16 deltams = ms - mLastMillis;
47 mLastMillis = ms;
48 mPseudotime += deltams * msmultiplier;
49 mHue16 += deltams * beatsin88(400, 5, 9);
50 u16 brightnesstheta16 = mPseudotime;
51
52 // set master brightness control
53 for (u16 i = 0; i < mNumLeds; i++) {
54 hue16 += hueinc16;
55 u8 hue8 = hue16 / 256;
56
57 brightnesstheta16 += brightnessthetainc16;
58 u16 b16 = sin16(brightnesstheta16) + 32768;
59
60 u16 bri16 = (fl::u32)((fl::u32)b16 * (fl::u32)b16) / 65536;
61 u8 bri8 = (fl::u32)(((fl::u32)bri16) * brightdepth) / 65536;
62 bri8 += (255 - brightdepth);
63
64 CRGB newcolor = CHSV(hue8, sat8, bri8);
65
66 u16 pixelnumber = (mNumLeds - 1) - i;
67
68 nblend(ctx.leds[pixelnumber], newcolor, 64);
69 }
70}
71
72} // namespace fl

Callers

nothing calls this directly

Calls 4

millisFunction · 0.50
sin16Function · 0.50
nblendFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected