Added in API level 37

ColorSequence


class ColorSequence : Parcelable
kotlin.Any
   ↳ 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

Builder for ColorSequence objects.

Constants
static Int

Linear interpolation between control points.

static Int

No interpolation between control points.

Inherited constants
Public methods
Int

Implements the Parcelable interface

IntArray

Returns the sequence of colors defined in this light effect.

LongArray

Returns the sequence of delays configured for the effect.

Long

Calculates the estimated duration of a single iteration of the light effect.

Int

Returns the type of interpolation that will be used to ramp the color to the final value.

String

Returns a string representation of the object.

Unit
writeToParcel(dest: Parcel, flags: Int)

Implements the Parcelable interface

Properties
static Parcelable.Creator<ColorSequence!>

Implements the Parcelable interface

Constants

INTERPOLATION_MODE_LINEAR

Added in API level 37
static val INTERPOLATION_MODE_LINEAR: Int

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.

Value: 1

INTERPOLATION_MODE_NONE

Added in API level 37
static val INTERPOLATION_MODE_NONE: Int

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.

Value: 0

Public methods

describeContents

Added in API level 37
fun describeContents(): Int

Implements the Parcelable interface

Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
Value is either 0 or

getColors

Added in API level 37
fun getColors(): IntArray

Returns the sequence of colors defined in this light effect.

Return
IntArray Array of colors that will be played for this effect.
This value cannot be null.

getDelaysMillis

Added in API level 37
fun getDelaysMillis(): LongArray

Returns the sequence of delays configured for the effect.
Value is a non-negative duration in milliseconds.

Return
LongArray Array of delays configured for this effect.
This value cannot be null.
Value is a non-negative duration in milliseconds.

getDurationMillis

Added in API level 37
fun getDurationMillis(): Long

Calculates the estimated duration of a single iteration of the light effect.
Value is a non-negative duration in milliseconds.

Return
Long the estimated duration of one iteration of this light effect in number of frames.
Value is a non-negative duration in milliseconds.

getInterpolationMode

Added in API level 37
fun getInterpolationMode(): Int

Returns the type of interpolation that will be used to ramp the color to the final value.

Return
Int Interpolation mode to be used in the animation.
Value is one of the following:

toString

Added in API level 37
fun toString(): String

Returns a string representation of the object.

Return
String a string representation of the object.

writeToParcel

Added in API level 37
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit

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_WRITE_RETURN_VALUE.
Value is either 0 or a combination of the following:

Properties

CREATOR

Added in API level 37
static val CREATOR: Parcelable.Creator<ColorSequence!>

Implements the Parcelable interface