ColorSequence
public
final
class
ColorSequence
extends Object
implements
Parcelable
| java.lang.Object | |
| ↳ | android.hardware.lights.ColorSequence |
Models a sequence of colors and their relative timing to create a light effect.
The control points in this object represent specific points in time when the light will be set to the specified color. Control points can be arbitrarily distant in time and the light will be interpolated each frame to smoothly transition between control points.
Control points have three main components:
- color: the target color for the light.
- delay: how long the light takes to transition from color[n-1] to color[n], expressed in milliseconds relative to the last control point (or permanent state if the light is not playing an effect).
- interpolation mode: the interpolation algorithm to use to transition between colors. It is
important to note that the interpolation is done per color channel on every frame (see
Light.getMinUpdatePeriodMillis()).
Summary
Nested classes | |
|---|---|
class |
ColorSequence.Builder
Builder for |
Constants | |
|---|---|
int |
INTERPOLATION_MODE_LINEAR
Linear interpolation between control points. |
int |
INTERPOLATION_MODE_NONE
No interpolation between control points. |
Inherited constants |
|---|
Fields | |
|---|---|
public
static
final
Creator<ColorSequence> |
CREATOR
Implements the Parcelable interface |
Public methods | |
|---|---|
int
|
describeContents()
Implements the Parcelable interface |
int[]
|
getColors()
Returns the sequence of colors defined in this light effect. |
long[]
|
getDelaysMillis()
Returns the sequence of delays configured for the effect. |
long
|
getDurationMillis()
Calculates the estimated duration of a single iteration of the light effect. |
int
|
getInterpolationMode()
Returns the type of interpolation that will be used to ramp the color to the final value. |
String
|
toString()
Returns a string representation of the object. |
void
|
writeToParcel(Parcel dest, int flags)
Implements the Parcelable interface |
Inherited methods | |
|---|---|
Constants
INTERPOLATION_MODE_LINEAR
public static final int INTERPOLATION_MODE_LINEAR
Linear interpolation between control points.
With this interpolation mode, the transition from color[n-1] to color[n]
happens linearly over delayMillis[n] milliseconds, with color updates every frame.
Each color channel is interpolated independently.
Constant Value: 1 (0x00000001)
INTERPOLATION_MODE_NONE
public static final int INTERPOLATION_MODE_NONE
No interpolation between control points.
With this interpolation mode, color[n-1] will be held for the corresponding duration
specified in delayMillis. After that, color[n] will be applied without any
intermediate steps.
Constant Value: 0 (0x00000000)
Fields
Public methods
describeContents
public int describeContents ()
Implements the Parcelable interface
| Returns | |
|---|---|
int |
a bitmask indicating the set of special object types marshaled
by this Parcelable object instance.
Value is either 0 or
|
getColors
public int[] getColors ()
Returns the sequence of colors defined in this light effect.
| Returns | |
|---|---|
int[] |
Array of colors that will be played for this effect.
This value cannot be null. |
getDelaysMillis
public long[] getDelaysMillis ()
Returns the sequence of delays configured for the effect.
Value is a non-negative duration in milliseconds.
| Returns | |
|---|---|
long[] |
Array of delays configured for this effect.
This value cannot be null.
Value is a non-negative duration in milliseconds. |
getDurationMillis
public long getDurationMillis ()
Calculates the estimated duration of a single iteration of the light effect.
Value is a non-negative duration in milliseconds.
| Returns | |
|---|---|
long |
the estimated duration of one iteration of this light effect in number of frames.
Value is a non-negative duration in milliseconds. |
getInterpolationMode
public int getInterpolationMode ()
Returns the type of interpolation that will be used to ramp the color to the final value.
| Returns | |
|---|---|
int |
Interpolation mode to be used in the animation.
Value is one of the following: |
toString
public String toString ()
Returns a string representation of the object.
| Returns | |
|---|---|
String |
a string representation of the object. |
writeToParcel
public void writeToParcel (Parcel dest, int flags)
Implements the Parcelable interface
| Parameters | |
|---|---|
dest |
Parcel: This value cannot be null. |
flags |
int: Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.
Value is either 0 or a combination of the following:
|
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-02-26 UTC.