Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

```
class Builder
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.hardware.lights.ColorSequence.Builder](https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#) |

Builder for `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence` objects.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#Builder()()` <br /> |

| Public methods ||
|---|---|
| [ColorSequence.Builder](https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#) | `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#addControlPoint(kotlin.Long,%20kotlin.Int)(delayMillis: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html, color: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Adds the next control point for the effect. |
| [ColorSequence.Builder](https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#) | `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#addControlPoints(android.hardware.lights.ColorSequence)(sequence: https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence)` Appends the provided ColorSequence to this sequence. |
| [ColorSequence.Builder](https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#) | `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#addControlPoints(kotlin.LongArray,%20kotlin.IntArray)(delaysMillis: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long-array/index.html, colors: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)` Adds multiple control points to the sequence. |
| [ColorSequence](https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence) | `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#build()()` Builds the light effect. |
| [ColorSequence.Builder](https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#) | `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#setInterpolationMode(kotlin.Int)(interpolationMode: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the interpolation mode to use to transition between control point colors. |

## Public constructors

### Builder

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
Builder()
```

## Public methods

### addControlPoint

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun addControlPoint(
    delayMillis: Long, 
    color: Int
): ColorSequence.Builder
```

Adds the next control point for the effect. The transition between control point colors takes `delayMillis` milliseconds. During that time, the light colors will be smoothly interpolated from the start to the end value according to the interpolation algorithm and the light's update interval.

When specifying a delay:

- Any negative value is considered an error and will cause an `IllegalArgumentException`
- Any positive value corresponds to the transition time in milliseconds, relative to the end of the previous control point.
- A value of 0 can only be specified for the very first control point in the sequence as a way to provide an initial state for the effect. It will cause an IllegalArgumentException if found in any other index.
- All delays MUST be whole multiples of the light's update period (frame period) (`https://developer.android.com/reference/kotlin/android/hardware/lights/Light#getMinUpdatePeriodMillis()`). If any specified delay is a fractional number of frames, the system will truncate the delay potentially altering initially expected interpolation values and relative timing with other lights.

Providing an initial state is not required and the effect will take the last known state as the starting point for the interpolation, creating smooth transitions between effects.

| Parameters ||
|---|---|
| `delayMillis` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): transition time for the light to change to the target color. |
| `color` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the target color for the light at the end of the transition time. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#` | a reference to this builder. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if delaysMillis is 0 for a non initial condition, or negative. |

### addControlPoints

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun addControlPoints(sequence: ColorSequence): ColorSequence.Builder
```

Appends the provided ColorSequence to this sequence.

If the two color sequences have different interpolation modes, the interpolation mode of the builder takes precedence over the interpolation mode from the argument.

| Parameters ||
|---|---|
| `sequence` | [ColorSequence](https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence): An existing ColorSequence to append to this builder. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#` | a reference to this builder. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if the sequence would cause the final sequence to be invalid. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#addControlPoint(kotlin.Long,%20kotlin.Int)`

### addControlPoints

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun addControlPoints(
    delaysMillis: LongArray, 
    colors: IntArray
): ColorSequence.Builder
```

Adds multiple control points to the sequence.

Both arrays provided MUST have the same size and be in the order in which they should be inserted.

| Parameters ||
|---|---|
| `delaysMillis` | [LongArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long-array/index.html): array with the delays for the colors in the colors parameter. This value cannot be `null`. |
| `colors` | [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html): array with the control point color targets. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#` | a reference to this builder. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if the arrays have different sizes or the sequence contains invalid values. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#addControlPoint(kotlin.Long,%20kotlin.Int)`

### build

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun build(): ColorSequence
```

Builds the light effect.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence` | the color sequence with the configuration provided. This value cannot be `null`. |

### setInterpolationMode

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setInterpolationMode(interpolationMode: Int): ColorSequence.Builder
```

Sets the interpolation mode to use to transition between control point colors.

By default, the builder configures the sequence with `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence#INTERPOLATION_MODE_LINEAR:kotlin.Int`.

| Parameters ||
|---|---|
| `interpolationMode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): specifying how to ramp the light between control points. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence#INTERPOLATION_MODE_NONE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence#INTERPOLATION_MODE_LINEAR:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence.Builder#` | This value cannot be `null`. |