Dissolve (Seg Line) - AlbertGBarber/PixelSpork GitHub Wiki

See the Documentation Guide for help understanding each page section.

Effect Sample (see here for sample info)
Effect Sample Gif

Description:

Morphs the segment set from one color to the next by setting each segment line at random, one at a time. Colors can be chosen using a palette and pattern, or selected randomly. Includes various options for color selection (see modes below).

The dissolve rate can be accelerated to set more lines at once by adjusting spawnRateInc. By default we start by spawning one segment line at a time, increasing the number every spawnRateInc ms, so the spawning steadily accelerates. This helps keep the overall spawning consistent, since we're picking at random and will eventually repeatedly pick lines we've already set. Once a certain threshold has been met (default of 1/10 of the number of lines in the segment set remaining), all the remaining lines are set. This prevents us from getting stuck looking for the last line.

Note, I know it would be better to remove the chance of picking a line that's already dissolved, but that would require more memory to track the dissolved line's locations (an array of uint16_t's vs an array of bools). Since the current effect seems to work, albeit with a bit of manual tweaking, I see no reason to change it.

You can increase the starting number of lines set at once (maxNumSpawnBase), which will accelerate the dissolve, and may be good on longer segment sets.

Once a morph is finished, the effect can be set to pause for a period using the pauseTime setting.

The effect is adapted to work on segment lines for 2D use. (see lineModes below).

You can use colorModes, but they don't make much sense unless you are shifting the gradient, or using colorModes 5 or 6.

!!Warning, this effect uses dynamic memory allocation to store a bool for each LED in your Segment Set, so be aware of your memory usage.

lineMode's (bool):

You can use lineMode to control how pixels are filled in:

  • true (default): Whole segment lines will be dissolved, rather than each pixel.
  • false: Individual pixels will be dissolved (only really useful when using certain color modes).

lineMode is set using setLineMode().

randMode's (uint8_t):

  • 0: Each dissolve is a solid color following the pattern (not random).
  • 1: Each dissolve is a set of randomly chosen colors (dif color for each pixel).
  • 2: Each dissolve is a set of random colors chosen from the pattern (dif color for each pixel).
  • 3: Each dissolve is a solid color chosen at random.
  • 4: Each dissolve is a solid color chosen randomly from the pattern.

You should be able switch freely between randMode's on the fly (the random modes will set up a random palette/pattern as a fallback).

Example Calls:

uint8_t pattern_arr = {0, 2, 1};
patternPS pattern = {pattern_arr, SIZE(pattern_arr), SIZE(pattern_arr)};

DissolveSL dissolve(mainSegments, pattern, cybPnkPal_PS, 0, 150, 70);
/* Will dissolve colors from the cybPnkPal_PS palette, following the pattern above using randMode 0 (see above) 
   with the number of LEDs set on one cycle increasing every 150ms with the effect updating every 70ms */

DissolveSL dissolve(mainSegments, cybPnkPal_PS, 4, 100, 100);
/* Will dissolve using from the cybPnkPal_PS palette in order, using randMode 4 (see above) 
   with the number of LEDs set on one cycle increasing every 100ms with the effect updating every 100ms */

DissolveSL dissolve(mainSegments, 3, 150, 70);
/* Will dissolve using 3 random colors set according to randMode 3
   (use randMode 2 or 3 with this constructor)
   with the number of LEDs set on one cycle increasing every 150ms with the effect updating every 70ms */

Constructor Definitions:

//constructor for pattern
DissolveSL(SegmentSetPS &SegSet, patternPS &Pattern, palettePS &Palette, uint8_t RandMode, 
           uint16_t SpawnRateInc, uint16_t Rate);

//constructor for palette as pattern
DissolveSL(SegmentSetPS &SegSet, palettePS &Palette, uint8_t RandMode, uint16_t SpawnRateInc, uint16_t Rate);

//constructor for randomly chosen colors (should only use randMode 2 or 3 with this constructor)
DissolveSL(SegmentSetPS &SegSet, uint8_t RandMode, uint16_t SpawnRateInc, uint16_t Rate);

Constructor Inputs:

  • 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 randMode -- The randMode that will be used for the dissolves (see intro above).

  • uint16_t spawnRateInc -- The rate increase at which the total number of lines that are set each cycle (ms). Setting this close-ish (up to double?) to the update rate looks the best.

  • 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 vars rate entry for more.

Other Settings:

  • uint8_t colorMode (default 0) -- The colorMode use for the effect, also see common vars colorMode entry for more details.

  • uint16_t setAllThreshold (defaults to 1/10th of the segment set length) -- The number of segment lines that will be set randomly before any remaining lines are force set at once. This is a fail safe so that you don't get stuck with one line that is never randomly picked, preventing the dissolve from ending.

  • uin16_t pauseTime (default 0ms) -- The length of time the effect will wait between dissolves. If the pause time is active, it is indicated with the paused flag.

  • uint8_t maxNumSpawnBase (default 1) -- The starting value of the number of segment lines set in one cycle. Higher numbers may work better for longer segment set lengths.

  • bool showNow (default true) -- Controls if the effect "draws" during each update cycle by calling FastLED.show(). Common to all effects. See common vars showNow entry for more details.

Class Functions:

  • uint16_t someFunction( uint16_t someArg ); 

    blah

  • void setPaletteAsPattern();

    Sets the effect pattern to match the current effect palette. See Common Functions for more.

  • void resetPixelArray();

    Resets the dissolved state of the segment lines, effectively restarting the current dissolve.

  • void setLineMode( bool newLineMode );

    Sets the lineMode (See lineMode notes in intro), also restarts the dissolve, and sets the setAllThreshold to 1/10 the numLines.

  • void update();

    Updates the effect.

Reference Vars:

  • uint16_t dissolveCount -- The number of dissolves we've done (does not reset automatically).

  • uint16_t numCycles -- How many dissolves we've finished (resets when we've gone through the whole pattern).

  • type lineMode (default true) -- (See lineMode notes in intro) !FOR reference only, set using setLineMode().

Flags:

  • bool paused -- If true, then the effect is paused.
⚠️ **GitHub.com Fallback** ⚠️