Class LEDAnimationFrame
java.lang.Object
org.chsrobotics.lib.hardware.ledStrip.LEDAnimationFrame
Wraps around an array of RGBColors (or individual pixel color values), intended for combination
into full animations.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor for an empty LEDAnimationFrame.LEDAnimationFrame
(List<RGBColor> pixelColors) Constructs an LEDAnimationFrame. -
Method Summary
Modifier and TypeMethodDescriptionadd
(LEDAnimationFrame other) Returns a new LEDAnimationFrame of another frame appended to this frame.static LEDAnimationFrame
alternating
(int numberColorA, int numberColorB, RGBColor colorA, RGBColor colorB) Statically constructs and returns a new LEDAnimationFrame of alternating colors.boolean
getPixel
(int index) Gets the pixel color value at an index.int
hashCode()
int
Returns the number of pixels currently in the animation frame.offset
(int step) Returns a new LEDAnimationFrame with each color offset (raised or lowered) in index by a given step.toNewSize
(int newSize) Returns a new LEDAnimationFrame based off of this frame, but at a different size.
-
Constructor Details
-
LEDAnimationFrame
Constructs an LEDAnimationFrame.- Parameters:
pixelColors
- Individual pixel colors to form the frame.
-
LEDAnimationFrame
public LEDAnimationFrame()Constructor for an empty LEDAnimationFrame.
-
-
Method Details
-
numberOfPixels
public int numberOfPixels()Returns the number of pixels currently in the animation frame.- Returns:
- The number of individual colors.
-
getPixel
Gets the pixel color value at an index.- Parameters:
index
- The index to sample.- Returns:
- The color at that index. If not a valid index, returns
RGBColor.BLACK
.
-
toNewSize
Returns a new LEDAnimationFrame based off of this frame, but at a different size.- Parameters:
newSize
- The desired size. If less than or equal to 0, returns this frame unchanged.- Returns:
- A new frame. If the new size is larger than this size, repeats the existing pattern until the desired size is reached. If the new size is smaller, truncates this frame to the new size.
-
offset
Returns a new LEDAnimationFrame with each color offset (raised or lowered) in index by a given step.- Parameters:
step
- The step to offset by.- Returns:
- A new LEDAnimationFrame.
-
add
Returns a new LEDAnimationFrame of another frame appended to this frame.- Parameters:
other
- The frame to append to this.- Returns:
- A new LEDAnimationFrame.
-
alternating
public static LEDAnimationFrame alternating(int numberColorA, int numberColorB, RGBColor colorA, RGBColor colorB) Statically constructs and returns a new LEDAnimationFrame of alternating colors. To extend to a desired length, usetoNewSize()
.- Parameters:
numberColorA
- How many of color A should be put before switching to color B. If less than or equal to zero, returns an empty frame.numberColorB
- How many of color B to put. If less than or equal to zero, returns and empty frame.colorA
- The first RGBColor to put.colorB
- The second RGBColor to put.- Returns:
- A new LEDAnimationFrame.
-
equals
-
hashCode
public int hashCode()
-