# 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)

*** ** * ** ***


```
public final class ColorBuilders.SweepGradient.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.SweepGradient`.

## Summary

| ### Public constructors |
|---|
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 300) @https://developer.android.com/reference/java/lang/SafeVarargs.html https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder#Builder(androidx.wear.protolayout.ColorBuilders.ColorStop...)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html ColorBuilders.ColorStop[] colorStops)` Creates an instance of `https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder`. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 300) @https://developer.android.com/reference/java/lang/SafeVarargs.html https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder#Builder(androidx.wear.protolayout.ColorBuilders.ColorProp...)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html ColorBuilders.ColorProp[] colors)` Creates an instance of `https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder`. |

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

## Public constructors

### Builder

```
@RequiresSchemaVersion(major = 1, minor = 300)
@SafeVarargs
public Builder(@NonNull ColorBuilders.ColorStop[] colorStops)
```

Creates an instance of `https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html ColorBuilders.ColorStop[] colorStops` | 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 |
|---|---|
| `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
public Builder(@NonNull ColorBuilders.ColorProp[] colors)
```

Creates an instance of `https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder`.

The colors are evenly distributed in the gradient.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html ColorBuilders.ColorProp[] colors` | The color sequence to be distributed around the gradient center. The color sequence is distributed between the gradient's start and end angles. |

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

## Public methods

### build

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

```
public @NonNull ColorBuilders.SweepGradient build()
```

Builds an instance from accumulated values.

| Throws |
|---|---|
| `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)
public @NonNull ColorBuilders.SweepGradient.Builder setEndAngle(@NonNull DimensionBuilders.DegreesProp endAngle)
```

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

For `https://developer.android.com/reference/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)
public @NonNull ColorBuilders.SweepGradient.Builder setStartAngle(@NonNull DimensionBuilders.DegreesProp startAngle)
```

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

For `https://developer.android.com/reference/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.