Gradient Cycle (Seg Line) - AlbertGBarber/PixelSpork GitHub Wiki
See the Documentation Guide for help understanding each page section.
Effect Sample (see here for sample info) |
Moves a set of color gradients along the Segment Set that blend into one another. The gradients can be set to follow a pattern, use a palette, or set randomly. They have a set length, and smoothly transition from one color to the next, wrapping back to the first color at the end. If the total length of the gradients is longer than the segment set, all colors will still be shown, they will just cycle on and off the segment set.
There is a version of this effect that takes less CPU power: Gradient Cycle Fast. It has a few restrictions, but should run faster than this effect.
The effect is adapted to work on segment lines for 2D use, each gradient will be repeated down the segment lines (so each segment line is a single color from the gradient).
uint8_t pattern_arr = {0, 2, 1};
patternPS pattern = {pattern_arr, SIZE(pattern_arr), SIZE(pattern_arr)};
GradientCycleSL gradientCycle(mainSegments, pattern, cybPnkPal_PS, 10, 100);
/* Will do a gradient cycle of the cybPnkPal_PS palette,
following the pattern (color 0 to color 2 to color 1)
with 10 steps to each gradient, and a 100ms update rate */
GradientCycleSL gradientCycle(mainSegments, cybPnkPal_PS, 10, 100);
/* Will do a gradient cycle using the colors in the cybPnkPal_PS palette in order,
with 10 steps to each gradient, and a 100ms update rate */
GradientCycleSL gradientCycle(mainSegments, 3, 15, 80);
/* Will do a gradient cycle using 3 randomly chosen colors,
with 15 steps to each gradient, and an 80ms update rate */
//Constructor for using pattern
GradientCycleSL(SegmentSetPS &SegSet, patternPS &Pattern, palettePS &Palette, uint8_t GradLength, uint16_t Rate);
//Constructor for using the palette as the pattern
GradientCycleSL(SegmentSetPS &SegSet, palettePS &Palette, uint8_t GradLength, uint16_t Rate);
//Constructor for using a random palette as the pattern
GradientCycleSL(SegmentSetPS &SegSet, uint8_t NumColors, uint8_t GradLength, uint16_t Rate);
-
SegmentSetPS* segSet -- The Segment Set the effect will draw on. See common vars
segSet
entry for more details. -
palettePS* palette (optional, see constructors) -- The set of colors the effect will use. See palettes. It is a pointer. See common vars
palette
entry for more details. -
patternPS* pattern (optional, see constructors) -- The color pattern the effect will use. See patterns. It is a pointer. See common vars
pattern
entry for more details. -
uint8_t numColors (optional, see constructors) -- The number of randomly chosen colors for the effect. The colors will be placed into the effect's local palette,
paletteTemp
for use. -
uint8_t gradLength -- How many steps for each gradient.
-
uint16_t* rate -- Update rate (ms). Is a pointer, allowing you to bind it to an external variable. By default it's bound the effect's local variable,
rateOrig
. See common varsrate
entry for more.
- bool showNow (default true) -- Controls if the effect "draws" during each update cycle by calling
FastLED.show()
. Common to all effects. See common varsshowNow
entry for more details.
-
void setPaletteAsPattern();
Sets the effect pattern to match the current effect palette. See Common Functions for more.
-
void update();
Updates the effect.
-
uint16_t cycleNum -- Tracks how many patterns we've gone through, resets every
totalCycleLength
cycles. -
uint16_t totalCycleLength -- Total length of all the gradients combined, ie
pattern->length * gradLength
.