ColorContainer

open class ColorContainer(val colors: MutableList<Int> = mutableListOf()) : ColorContainerInterface

A class for storing colors that can be used in animations. This can store a variable number of colors (stored as 24-bit Ints).

Behavior when Ints outside the range 0..0xFFFFFF are added is undefined.

Constructors

Link copied to clipboard
constructor(vararg c: Int)

Create a ColorContainer from 0 or more Ints

constructor(rgb: <Error class: unknown class><Int, Int, Int>)

Create a new ColorContainer with one color, passed as a Triple containing r, g, and b.

constructor(vararg ccs: ColorContainer)

Copy constructor

constructor(colors: MutableList<Int> = mutableListOf())

Properties

Link copied to clipboard
open override val color: Int

A helper property that tries to return the first color in colors

Link copied to clipboard
override val colors: MutableList<Int>

The List of colors in this container

Link copied to clipboard
val size: Int

Functions

Link copied to clipboard
operator fun contains(c: Int): Boolean

Checks if the specified color is in colors

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Compares this ColorContainer against another ColorContainer or an Int. If other is a ColorContainer, the colors parameters are compared. If other is a PreparedColorContainer, the colors parameter is compared to the originalColors parameter. If other is an Int, the color parameter is compared to the Int.

Link copied to clipboard
operator fun get(index: Int): Int

Get the color in colors at the specified index. Checks if index is a valid index of colors and if so, returns the color stored there, if not, returns 0 (black).

operator fun get(vararg indices: Int): List<Int>

Get multiple colors from colors. Accepts a variable number of arguments (a single argument will be caught by the get() operator above). If no indices are provided, this will return an empty list. If an index is not a valid index in colors, 0 is added to the list. The returned list contains the colors in the order specified.

operator fun get(indices: IntRange): List<Int>

Get multiple colors from colors. If an index in the range is not a valid index in colors, 0 is added to the list.

Link copied to clipboard

Replaces all colors in ColorContainer.colors with a grayscaled version of themselves.

Replaces the colors at the indices in the specified ranges with a grayscaled version of themselves.

Replaces the colors at the specified indices with a grayscaled version of themselves.

Link copied to clipboard

Returns a new ColorContainer with the same colors as this instance, but grayscaled.

Returns a new ColorContainer with the same colors as this instance, grayscaled, but only including the ranges of indices specified.

Returns a new ColorContainer with the same colors as this instance, grayscaled, but only including the indices specified.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Returns a new ColorContainer with the same colors as this instance, but inverted.

Returns a new ColorContainer with the same colors as this instance, inverted, but only including the ranges of indices specified.

Returns a new ColorContainer with the same colors as this instance, inverted, but only including the indices specified.

Link copied to clipboard

Replaces all colors in ColorContainer.colors with their inverse.

Replaces the colors at the indices in the specified ranges with their inverse

fun ColorContainer.invert(vararg indices: Int): ColorContainer

Replaces the colors at the specified indices with their inverse.

Link copied to clipboard

Report whether colors is empty

Link copied to clipboard

Report whether colors is not empty

Link copied to clipboard
operator fun iterator(): MutableIterator<Int>
Link copied to clipboard
operator fun plusAssign(c: Int)

Adds a color at the end of colors.

Link copied to clipboard
open override fun prepare(numLEDs: Int): PreparedColorContainer

Prepare these colors for use with a LED strip by creating a collection of colors that blend between multiple colors along the 'strip'.

Link copied to clipboard
operator fun set(vararg indices: Int, c: Int)

Set some indices of colors to c. If an index is not a valid index in colors, this will add it to the end of colors, though not necessarily at the index specified.

operator fun set(indices: IntRange, c: Int)

Set a range of indices of colors to c. If an index is not a valid in colors, this will add the color to the end of colors, though not necessarily at the index specified.

Link copied to clipboard
fun ColorContainerInterface.shuffledWithIndices(): List<<Error class: unknown class><Int, Int>>
Link copied to clipboard
open override fun toColorContainer(): ColorContainer
Link copied to clipboard
fun toInt(): Int
Link copied to clipboard
fun toRGB(): <Error class: unknown class><Int, Int, Int>
Link copied to clipboard
open override fun toString(): String

Create a string representation of this ColorContainer. The hexadecimal representation of each color in colors is listed in comma delimited format, between brackets [&].

Link copied to clipboard
fun toTriple(): <Error class: unknown class><Int, Int, Int>

Calls toRGB()

Link copied to clipboard

Operator overload that returns a new ColorContainer containing the inverse of the colors in this ColorContainer.