# ColorBuilders.SweepGradient.Builder

# ColorBuilders.SweepGradient.Builder

Artifact:[androidx.wear.protolayout:protolayout](https://developer.android.com/jetpack/androidx/releases/wear-protolayout)  
[View Source](https://cs.android.com/search?q=file:androidx/wear/protolayout/ColorBuilders.java+class:androidx.wear.protolayout.ColorBuilders.SweepGradient.Builder)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder "View this page in Java")

<br />

```
class ColorBuilders.SweepGradient.Builder
```

<br />

*** ** * ** ***

Builder for[SweepGradient](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.SweepGradient).

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                  ### Public constructors                                                                                                                                                                                                                                                                                                                                                                                                   |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 300)` `@`[SafeVarargs](https://developer.android.com/reference/java/lang/SafeVarargs.html) [Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder#Builder(androidx.wear.protolayout.ColorBuilders.ColorStop...))`(colorStops: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[ColorBuilders.ColorStop](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.ColorStop)`!>)` Creates an instance of[Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder). |
| `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 300)` `@`[SafeVarargs](https://developer.android.com/reference/java/lang/SafeVarargs.html) [Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder#Builder(androidx.wear.protolayout.ColorBuilders.ColorProp...))`(colors: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[ColorBuilders.ColorProp](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.ColorProp)`!>)` Creates an instance of[Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder).     |

|                                                                ### Public functions                                                                 |
|-----------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ColorBuilders.SweepGradient](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.SweepGradient)                 | [build](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder#build())`()` Builds an instance from accumulated values.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [ColorBuilders.SweepGradient.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder) | `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 300)` [setEndAngle](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder#setEndAngle(androidx.wear.protolayout.DimensionBuilders.DegreesProp))`(endAngle: `[DimensionBuilders.DegreesProp](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DimensionBuilders.DegreesProp)`)` Sets the end angle of the gradient, relative to the element's base angle.        |
| [ColorBuilders.SweepGradient.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder) | `@`[RequiresSchemaVersion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/RequiresSchemaVersion)`(major = 1, minor = 300)` [setStartAngle](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder#setStartAngle(androidx.wear.protolayout.DimensionBuilders.DegreesProp))`(startAngle: `[DimensionBuilders.DegreesProp](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DimensionBuilders.DegreesProp)`)` Sets the start angle of the gradient relative to the element's base angle. |

## Public constructors

### Builder

```
@RequiresSchemaVersion(major = 1, minor = 300)
@SafeVarargs
Builder(colorStops: Array<ColorBuilders.ColorStop!>)
```

Creates an instance of[Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder).  

|                                                                                                           Parameters                                                                                                            |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `colorStops: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[ColorBuilders.ColorStop](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.ColorStop)`!>` | The color stops defining how the colors are distributed around the gradient center. A color stop is composed of a color and its offset in the gradient. The offset is the relative position of the color, beginning with 0 from the start angle and ending with 1.0 at the end angle, spanning clockwise. |

|                                                        Throws                                                         |
|-----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| [java.lang.IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | if the number of colors is less than 2 or larger than 10. |

### Builder

```
@RequiresSchemaVersion(major = 1, minor = 300)
@SafeVarargs
Builder(colors: Array<ColorBuilders.ColorProp!>)
```

Creates an instance of[Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder).

The colors are evenly distributed in the gradient.  

|                                                                                                         Parameters                                                                                                          |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| `colors: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[ColorBuilders.ColorProp](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.ColorProp)`!>` | The color sequence to be distributed around the gradient center. The color sequence is distributed between the gradient's start and end angles. |

|                                                        Throws                                                         |
|-----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| [java.lang.IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | if the number of colors is less than 2 or larger than 10. |

## Public functions

### build

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.1.0)  

```
fun build(): ColorBuilders.SweepGradient
```

Builds an instance from accumulated values.  

|                                                     Throws                                                      |
|-----------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | if size of colorStops is less than 2 or greater than 10. |

### setEndAngle

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.1.0)  

```
@RequiresSchemaVersion(major = 1, minor = 300)
fun setEndAngle(endAngle: DimensionBuilders.DegreesProp): ColorBuilders.SweepGradient.Builder
```

Sets the end angle of the gradient, relative to the element's base angle. If not set, defaults to 360 degrees.

For[androidx.wear.protolayout.LayoutElementBuilders.ArcLine](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.ArcLine), the base angle is the angle where the line starts. The value represents a relative position in the line's length span. Values greater than 360 degrees correspond to upper layers of the arc line as it wraps over itself.  

### setStartAngle

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.1.0)  

```
@RequiresSchemaVersion(major = 1, minor = 300)
fun setStartAngle(startAngle: DimensionBuilders.DegreesProp): ColorBuilders.SweepGradient.Builder
```

Sets the start angle of the gradient relative to the element's base angle. If not set, defaults to zero.

For[androidx.wear.protolayout.LayoutElementBuilders.ArcLine](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.ArcLine), the base angle is the angle where the line starts. The value represents a relative position in the line's length span. Values greater than 360 degrees correspond to upper layers of the arc line as it wraps over itself.