Noise Waves (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:

Uses FastLED Perlin noise to produce varying colors with waves of brightness that both move and grow/shrink across segment lines with time. There are various setting to control waves and colors, explained in the Inputs guide below. The effect requires a palette for colors, or can generate one randomly for you.

The noise waves will be blended towards a background color. Changing the background color will "tint" the overall output, because all the colors are blended towards the background color as part of the effect. Supports color modes for the background color only.

You can change effect settings freely, although this may result in jumps in the effect.

The effect is adapted to work on segment lines for 2D use.

Inputs guide:

Overall the effect has two components:

  1. Waves of varying brightness that shift randomly across the segment lines while growing and shrinking with time.

  2. Spots of palette colors that grow and change with time.

Brightness Wave settings:

The brightness wave is generated using a cos() where the frequency and phase are set based on noise functions.

The scale settings determine how fast the waves move and how large they are:

  • phaseScale -- Changes how fast the waves move. Must be greater than 0. Recommend between 3 - 15. Note that because the waves are noise based, their speed varies over time. phaseScale sets a cap on how fast they move: Higher is slower. The effect has diminishing returns at higher values.

  • freqScale -- Sets how long the waves are. Must be greater than 0. Recommend between 3 - 10. The waves will vary in size over time, but this sets a minimum they will reach. Higher means longer waves.

Color change settings:

  • blendScale-- Sets how "zoomed-in" the color noise is, controlling how large the patches of color will be. Recommend values 10 - 60+. Higher values produce smaller patches.

  • blendSpeed -- How fast the colors blend with time. Must be greater than 0. This is not a constructor setting, and is defaulted to 10. Lower values will make faster blends.

  • blendSteps -- How many steps there are between colors. Defaulted to 30. This is not a constructor setting because the change to the effect isn't very noticeable unless below a certain value, which causes the colors to become coarse.

Cycling Colors:

For FastLED noise, most of the noise output falls in the center of its range. This means that for a given palette, you tend to only see the colors in the middle of the palette. To counteract this, the noise center can be offset over time, cycling colors into view. The end result is more pretty than without imo.

The offset cycling is controlled by the settings below. Note that the cycling is on by default:

  • hue -- Offsets the center of the FastLED noise, allowing you to shift the "center" color of the palette. By default it is incremented during every update cycle, but can also be set to a fixed value with cycling turned off.

  • hueCycle (default true) -- Controls the hue offset cycling. When off (false) the hue offset will be fixed to its current value.

Example Calls:

NoiseWavesSL noiseWaves(mainSegments, 3, 0, 30, 8, 3, 80);
/*  Will produce an effect using 3 random colors
    The background is blank
    The blend scale is 30, while the phaseScale is 8 and the freqScale is 3
    The produces small waves that shift more slowly, with larger color patches.
    (even at the slowest the waves still move pretty quick)
    The effect updates at 80ms */
    
NoiseWavesSL noiseWaves(mainSegments, cybPnkPal_PS, 0, 10, 2, 9, 80);
/*  Will produce an effect using colors from cybPnkPal_PS
    The background is blank
    The blend scale is 10, while the phaseScale is 2 and the freqScale is 9
    The produces large waves that shift quickly
    The effect updates at 40ms */

Constructor Definitions:

//Constructor with palette
NoiseWavesSL(SegmentSetPS &SegSet, palettePS &Palette, CRGB BgColor, uint16_t BlendScale, 
             uint8_t PhaseScale, uint8_t FreqScale, uint16_t Rate);

//Constructor with randomly generated palette
NoiseWavesSL(SegmentSetPS &SegSet, uint8_t numColors, CRGB BgColor, uint16_t BlendScale, 
             uint8_t PhaseScale, uint8_t FreqScale, 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.

  • 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.

  • CRGB* bgColor -- The color used for background pixels. Is a pointer, allowing you to bind it to an external color. By default it's bound the effect's local, bgColorOrig color. See common vars bgColor entry for more details.

  • uint16_t blendScale -- Sets how "zoomed-in" the noise is. (See Inputs Guide above).

  • uint8_t phaseScale -- Changes how fast the waves move. Must be greater than 0. (See Inputs Guide above).

  • uint8_t freqScale -- Sets how long the waves are. Must be greater than 0. (See Inputs Guide above).

  • 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 bgColorMode (default 0) -- The colorMode used for the background pixels, also see common vars colorMode entry for more details.

  • uint8_t hue (default 0) -- Offsets the center of the FastLED noise, allowing you to shift the "center" color of the palette. (See Inputs Guide above).

  • bool hueCycle (default true) -- Controls the hue offset cycling. (See Inputs Guide above).

  • uint8_t blendSpeed (default 10) -- How fast the colors blend with time. Must be greater than 0. Lower => faster.

  • uint16_t blendSteps (default 30) -- How many steps there are between colors. Doesn't really change anything in the effect unless you make it very small.

  • 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:

  • void update();
    Updates the effect.
⚠️ **GitHub.com Fallback** ⚠️