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

An effect where palette colors are drawn as a gradient across segment lines that shifts based on the output of the FastLED Perlin noise function. The brightness is randomly set in blobs across the segment lines. The length of the color gradient can be set to shift in quick bursts over time, which lets the effect stay calm for a while, and then quickly shift to a new look.

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

The noise colors 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.

Inputs guide:

Overall the effect has two components:

  1. A gradient of palette colors that shifts along the segment set in random jumps.
  2. Spots of brightness that grow and change with time.

Both these factors have their own independent settings, so you can tune the effect to your liking.

Gradient Blending Settings:

  • blendStepsBase -- The minimum number of gradient steps between palette colors. To make the effect more interesting, the number of gradient steps (blendSteps) can be set to shift over time, which changes how fast palette colors blend. The total number of blendSteps is calculated as blendSteps = blendStepBase + random(blendStepsRange), so blendStepBase sets the smallest number of steps the gradients can have. I recommend keeping the total possible steps to be less than 20. At higher values the shifting becomes quite slow. This may depend on your segments though.

  • blendStepsRange -- The maximum amount added to blendStepBase. Sets the upper limit for the number of gradient steps. If you set blendStepsRange to 0 then there will be no shifting.

  • blendRate -- How often (in ms) the blendSteps are shifted. Constantly shifting the blendSteps looks choppy, so instead we only shift it every blendRate time. The overall result is that the effect has moments of calm before jumping to a new look. Note that blendRate is a pointer, so you can bind it externally (just like rate). The blendRate you pass in is stored in blendRateOrig. See common vars rate en

  • phaseScale -- The gradient is constantly offset by a noise value. phaseScale sets the speed of the noise changes, ie, how "wobbly" the gradient is. Lower values => faster changing, min value of 1. Recommend between 5 and 20.

  • freqScale -- How quickly the gradient moves across the segments. Lower value => faster. Min value of 1. Recommend between 5 and 20.

Warning, do NOT set the blendSteps directly if your blendStepsRange is greater than 0. Doing so may cause the blendSteps to increase/decrease infinitely.

Brightness Spots settings:

The brightness patches are generated with noise, similar to the Lava effect, so they shift and grow/shrink over time. They are controlled with the following settings:

  • briScale -- Sets how "zoomed-in" the noise is, ie, how large the brightness patches are. Higher value => smaller patches. Recommend between 10 and 50.
  • briFreq -- Defaulted to 5. Sets how quickly the brightness changes. Smaller value => faster change. Min value of 1.
  • doBrightness -- Default true. Turns the brightness spots on/off.

Example Calls:

/*  For this example, I'm showing you how to set the blendStepsRange so that one complete palette gradient 
    fits into the segment set. This tends to look good because you always have all the colors showing, and they'll
    either spread out into one full wave, or make multiple smaller waves as the blendSteps shifts.
    For this, you want your "max blend steps" * "number of palette colors" to equal the number of segment lines.
    uint8_t numColors = 3;
    uint8_t minSteps = 3;
    uint8_t stepsRange = ( mainSegments.numLines / numColors ) - minSteps;
    In my instance the mainSegments have a maximum length of 24, so stepsRange is 5. */

NoiseGradSL noiseGrad(mainSegments, numColors, 0, minSteps, stepsRange, 10, 20, 30, 5000, 80);
/*  Will produce an effect using a palette of 3 random colors
    The background is blank.
    There are a minimum of 3 blendSteps and range of 5 for a maximum blendSteps of 8 (as calculated above)
    The phaseScale is 10, the freqScale is 20, and the briScale is 30.
    The blendSteps will be shifted every 5000ms (5 sec).
    The effect updates at 80ms. */

NoiseGradSL noiseGrad(mainSegments, cybPnkPal_PS, 0, 8, 16, 5, 20, 10, 3000, 80);
NoiseGradSL.bgColorMode = 6; //put in Arduino Setup()
/*  Will produce an effect using colors from cybPnkPal_PS
    The background is blank (but using bgColorMode of 6, ie a shifting rainbow)
    There are a minimum of 8 blendSteps and range of 16 for a maximum blendSteps of 24
    The phaseScale is 5, the freqScale is 20, and the briScale is 10.
    The blendSteps will be shifted every 3000ms (3 sec).
    The effect updates at 80ms. */

Constructor Definitions:

//Constructor with palette
NoiseGradSL(SegmentSetPS &SegSet, palettePS &Palette, CRGB BgColor, uint16_t BlendStepsBase, uint16_t BlendStepsRange, 
            uint8_t PhaseScale, uint8_t FreqScale, uint8_t BriScale, uint16_t BlendRate, uint16_t Rate);

//Constructor with randomly generated palette
NoiseGradSL(SegmentSetPS &SegSet, uint8_t numColors, CRGB BgColor, uint16_t BlendStepsBase, uint16_t BlendStepsRange, 
            uint8_t PhaseScale, uint8_t FreqScale, uint8_t BriScale, uint16_t BlendRate, 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 blendStepsBase -- The minimum number of gradient steps between palette colors. (See Inputs Guide above)

  • uint16_t blendStepsRange -- The maximum amount added to blendStepBase for shifting. (See Inputs Guide above)

  • uint8_t phaseScale -- Sets how must the gradient "wobbles". 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)

  • uint8_t briScale -- Sets how "zoomed-in" the brightness noise is. (See Inputs Guide above)

  • uint16_t blendRate -- How often we shift to new blendStepsvalues (ms). (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 briFreq (default 5) -- Sets how quickly the brightness changes. Smaller value => faster change. Min value of 1. (See Inputs Guide above)

  • uint8_t blendSteps -- How many steps are taken to blend between palette colors. Set to blendStepBase during effect creation. Changes over time if blendStepsRange is greater than 0.

  • type doBrightness (default true) -- Turns the brightness spots on/off.

  • 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** ⚠️