Draw Pattern (Seg Line or Seg) - AlbertGBarber/PixelSpork GitHub Wiki
See the Documentation Guide for help understanding each page section.
Effect Sample (see here for sample info) |
The Effect Draws a Static Pattern
|
Draws a fixed color pattern at a set refresh rate. Useful for backgrounds, or maybe combining with a palette utility to change colors. Features multiple constructors for different pattern and palette combinations. Allows you to add blank spaces to your pattern (any 255 entries in the pattern will be drawn as background) and set the lengths of the pattern's color bands.
The patterns can be drawn in 1D, or in 2D, using segment lines, or whole segments by changing the segMode
.
- 0: The pattern will be drawn using segment lines (each line will be a single color).
- 1: The pattern will be drawn using whole segment (each segment will be a single color).
- 2: The pattern will be drawn linearly along the segment set (1D).
Supports color modes for both the main and background colors.
Note that using 255 in your patterns will draw the background color.
You can freely change any of the effect's variables during runtime.
Note that while each entry in the pattern is a uint8_t, if you have a lot of colors, with long streamers, your patterns may be quite large so watch your memory usage. Likewise, if you re-size the waves, the pattern may also be dynamically re-sized. See here for more on memory management.
Also, remember that the pattern length is limited to 65,025 (uint16_t max), so make sure your (colorLength + spacing) * is less than the limit.
uint8_t pattern_arr = {0, 255, 255, 255, 1, 1, 255, 255};
patternPS pattern = {pattern_arr, SIZE(pattern_arr), SIZE(pattern_arr)};
DrawPatternSLSeg drawPat(mainSegments, pattern, cybPnkPal_PS, 0, 2, 80);
/* Will draw a pattern using the first two colors in the cybPnkPal_PS palette (based on the pattern above)
The drawn pattern will begin with 1 pixel of color 0, with three spaces after,
followed by 2 pixels of color 1, followed by 2 spaces.
The background is black (0).
The effect uses segMode 2, so the pattern will be drawn linearly (1D) on the segment set.
The pattern will be re-drawn every 80ms. */
uint8_t pattern_arr = {0, 2, 1};
patternPS pattern = {pattern_arr, SIZE(pattern_arr), SIZE(pattern_arr)};
DrawPatternSLSeg drawPat(mainSegments, pattern, cybPnkPal_PS, 3, 4, 0, 0, 120);
/* Will draw a pattern using the first three colors of the cybPnkPal_PS palette (using the pattern above)
The pattern will have color bands of length 3, followed by 4 spaces, background is black (0).
The pattern will be drawn on segment lines (segMode is 0).
The pattern will be re-drawn every 120ms. */
DrawPatternSLSeg drawPat(mainSegments, cybPnkPal_PS, 3, 4, CRGB::Red, 1, 40);
/* Will draw a pattern using all the colors in cybPnkPal_PS palette,
The pattern will have color bands of length 3, with 4 spaces in between.
The background is red.
The pattern will be drawn on whole segments (segMode is 1).
The pattern will be re-drawn every 40ms. */
DrawPatternSLSeg drawPat(mainSegments, CRGB::Blue, 2, 2, CRGB::Red, 2, 140);
/* Will do a pattern with blue color bands of length 2 and 2 spaces in between.
The background is red.
The effect uses segMode 2, so the pattern will be drawn linearly (1D) on the segment set.
The effect updates at a rate of 140ms. */
//Constructor for using the passed in pattern and palette
DrawPatternSLSeg(SegmentSetPS &SegSet, patternPS &Pattern, palettePS &Palette, CRGB BgColor,
uint8_t SegMode, uint16_t Rate);
//Constructor for building the pattern from the passed in pattern and the palette,
//using the passed in colorLength and spacing
DrawPatternSLSeg(SegmentSetPS &SegSet, patternPS &Pattern, palettePS &Palette, uint16_t ColorLength,
uint16_t Spacing, CRGB BgColor, uint8_t SegMode, uint16_t Rate);
//Constructor for building the pattern using all the colors in the passed in palette,
//using the colorLength and spacing for each color
DrawPatternSLSeg(SegmentSetPS &SegSet, palettePS &Palette, uint16_t ColorLength, uint16_t Spacing,
CRGB BgColor, uint8_t SegMode, uint16_t Rate);
//Constructor for doing a single colored pattern, using colorLength and spacing
DrawPatternSLSeg(SegmentSetPS &SegSet, CRGB Color, uint16_t ColorLength, uint16_t Spacing, CRGB BgColor,
uint8_t SegMode, 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. -
CRGB color (optional, see constructors) -- Used for making a single color pattern. The color will be placed in the effect's local palette,
paletteTemp
. The local pattern,patternTemp
, will be set to match the palette (ie a single entry for the single color). -
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 varsbgColor
entry for more details. -
uint16_t colorLength (optional, see constructors) -- The length of each color band. Used for automated pattern creation.
-
uint16_t spacing (optional, see constructors) -- The number of pixels between each color band (will be set to
bgColor
). Used for automated pattern creation. -
uint8_t segMode -- Sets if the pattern will be drawn along segment lines, whole segments, or in 1D (see intro
segMode
notes). -
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.
-
uint8_t colorMode (default 0) -- The colorMode use for the effect, also see common vars
colorMode
entry for more details. -
uint8_t bgColorMode (default 0) -- The colorMode used for the background pixels, also see common vars
colorMode
entry for more details. -
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 setPatternAsPattern(patternPS &inputPattern, uint16_t colorLength, uint16_t spacing);
Takes an input pattern and creates a color pattern with streamers of
colorLength
andspacing
background spaces in-between. A short-hand for turning a short pattern into a full pattern for the effect. See Common Functions for more. -
void setPaletteAsPattern(uint16_t colorLength, uint16_t spacing);
Sets the effect pattern to match the current effect palette, with streamers of
colorLength
andspacing
background spaces in-between for each color in the palette. See Common Functions for more. -
void update();
Updates the effect.