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

◆ loop()

void loop ( )

Definition at line 93 of file Corkscrew.h.

93 {
95 static float pos = 0;
96 pos += speed.value();
97 if (pos > corkscrew.size() - 1) {
98 pos = 0; // Reset to the beginning
99 }
100
101 if (allWhite) {
102 for (size_t i = 0; i < frameBuffer.size(); ++i) {
103 frameBuffer.data()[i] = CRGB(8, 8, 8);
104 }
105 }
106
107 if (splatRendering) {
108 Tile2x2_u8_wrap pos_tile = corkscrew.at_wrap(pos);
109 const CRGB color = CRGB::Blue;
110 // Draw each pixel in the 2x2 tile using the new wrapping API
111 for (int dx = 0; dx < 2; ++dx) {
112 for (int dy = 0; dy < 2; ++dy) {
113 auto data = pos_tile.at(dx, dy);
114 vec2i16 wrapped_pos = data.first; // Already wrapped position
115 uint8_t alpha = data.second; // Alpha value
116
117 if (alpha > 0) { // Only draw if there's some alpha
118 CRGB c = color;
119 c.nscale8(alpha); // Scale the color by the alpha value
120 frameBuffer.at(wrapped_pos.x, wrapped_pos.y) = c;
121 }
122 }
123 }
124 } else {
125 // None splat rendering, looks aweful.
126 vec2f pos_vec2f = corkscrew.at_exact(pos);
127 vec2i16 pos_i16 = vec2i16(round(pos_vec2f.x), round(pos_vec2f.y));
128 // Now map the cork screw position to the cylindrical buffer that we
129 // will draw.
130 frameBuffer.at(pos_i16.x, pos_i16.y) =
131 CRGB::Blue; // Draw a blue pixel at (w, h)
132 }
133 FastLED.show();
134}
uint8_t pos
Definition Blur.ino:11
UICheckbox allWhite("All White", false)
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:62
Data & at(uint16_t x, uint16_t y)
Definition tile2x2.cpp:57
Corkscrew corkscrew(corkscrewInput)
UICheckbox splatRendering("Splat Rendering", true)
fl::Grid< CRGB > frameBuffer
Definition Corkscrew.h:71
uint16_t speed
Definition funky.cpp:82
void clear(CRGB(&arr)[N])
Definition clear.h:13
vec2< float > vec2f
Definition geometry.h:318
vec2< int16_t > vec2i16
Definition geometry.h:320
CRGB & nscale8(uint8_t scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.cpp:88
@ Blue
<div style='background:#0000FF;width:4em;height:4em;'></div>
Definition crgb.h:506
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:55
#define round(x)
Definition util.h:10

References allWhite, fl::Tile2x2_u8_wrap::at(), CRGB::Blue, fl::clear(), corkscrew(), FastLED, frameBuffer, CRGB::nscale8(), pos, round, speed, splatRendering(), fl::vec2< T >::x, and fl::vec2< T >::y.

+ Here is the call graph for this function: