# Brush.Builder

Artifact: [androidx.ink:ink-brush](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/brush/Brush.kt+class:androidx.ink.brush.Brush.Builder) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

*** ** * ** ***


```
public final class Brush.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/androidx/ink/brush/Brush`.

For Java developers, use `Brush.Builder` to construct a `https://developer.android.com/reference/androidx/ink/brush/Brush` with default values, overriding only as needed. For example: `Brush brush = Brush.builder().setFamily(family).setSize(size).setEpsilon(epsilon).build();`

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/ink/brush/Brush.Builder#Builder()()` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/Brush` | `https://developer.android.com/reference/androidx/ink/brush/Brush.Builder#build()()` Constructs a `https://developer.android.com/reference/androidx/ink/brush/Brush` from this `https://developer.android.com/reference/androidx/ink/brush/Brush.Builder`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/Brush.Builder` | `https://developer.android.com/reference/androidx/ink/brush/Brush.Builder#setColorIntArgb(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/ColorInt int colorIntArgb)` Sets the color using a `https://developer.android.com/reference/androidx/annotation/ColorInt`, which is in the sRGB color space by definition. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/Brush.Builder` | `https://developer.android.com/reference/androidx/ink/brush/Brush.Builder#setColorLong(kotlin.Long)(@https://developer.android.com/reference/androidx/annotation/ColorLong long colorLong)` Sets the color using a `https://developer.android.com/reference/androidx/annotation/ColorLong`, which can encode several different color spaces. sRGB and Display P3 are supported; a color in any other color space will be converted to Display P3. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/Brush.Builder` | `https://developer.android.com/reference/androidx/ink/brush/Brush.Builder#setEpsilon(kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0, fromInclusive = false, to = Infinity, toInclusive = false) float epsilon )` Sets the epsilon of the brush, in stroke units. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/Brush.Builder` | `https://developer.android.com/reference/androidx/ink/brush/Brush.Builder#setFamily(androidx.ink.brush.BrushFamily)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/BrushFamily family)` Sets the `https://developer.android.com/reference/androidx/ink/brush/BrushFamily` for this brush. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/Brush.Builder` | `https://developer.android.com/reference/androidx/ink/brush/Brush.Builder#setSize(kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0, fromInclusive = false, to = Infinity, toInclusive = false) float size )` Sets the size of the brush, in stroke units. |

| ### Extension functions |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/Brush.Builder` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/ink/brush/BrushUtil.https://developer.android.com/reference/androidx/ink/brush/Brush.Builder#(androidx.ink.brush.Brush.Builder).setAndroidColor(android.graphics.Color)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/Brush.Builder receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Color.html color )` Set the color on a `https://developer.android.com/reference/androidx/ink/brush/Brush.Builder` as an `https://developer.android.com/reference/android/graphics/Color.html` instance. sRGB and Display P3 are supported; a color in any other color space will be converted to Display P3. |

## Public constructors

### Builder

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public Builder()
```

## Public methods

### build

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull Brush build()
```

Constructs a `https://developer.android.com/reference/androidx/ink/brush/Brush` from this `https://developer.android.com/reference/androidx/ink/brush/Brush.Builder`.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if `family`, `size`, and/or `epsilon` were never set |

### setColorIntArgb

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull Brush.Builder setColorIntArgb(@ColorInt int colorIntArgb)
```

Sets the color using a `https://developer.android.com/reference/androidx/annotation/ColorInt`, which is in the sRGB color space by definition. Note that the `https://developer.android.com/reference/androidx/annotation/ColorInt` channel order puts alpha first (in the most significant byte).

Kotlin interprets integer literals greater than `0x7fffffff` as `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html`s, so Kotlin callers that want to specify a literal `https://developer.android.com/reference/androidx/annotation/ColorInt` with alpha \>= 0x80 must call `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/to-int.html` on the literal.

### setColorLong

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull Brush.Builder setColorLong(@ColorLong long colorLong)
```

Sets the color using a `https://developer.android.com/reference/androidx/annotation/ColorLong`, which can encode several different color spaces. sRGB and Display P3 are supported; a color in any other color space will be converted to Display P3.

Some libraries (notably Jetpack UI Graphics) use `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-u-long/index.html` for `https://developer.android.com/reference/androidx/annotation/ColorLong`s, so the caller must call `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-u-long/to-long.html` on such a value before passing it to this method.

### setEpsilon

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull Brush.Builder setEpsilon(
    @FloatRange(from = 0.0, fromInclusive = false, to = Infinity, toInclusive = false) float epsilon
)
```

Sets the epsilon of the brush, in stroke units.

### setFamily

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull Brush.Builder setFamily(@NonNull BrushFamily family)
```

Sets the `https://developer.android.com/reference/androidx/ink/brush/BrushFamily` for this brush. See `https://developer.android.com/reference/androidx/ink/brush/StockBrushes` for available `https://developer.android.com/reference/androidx/ink/brush/BrushFamily` values.

### setSize

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull Brush.Builder setSize(
    @FloatRange(from = 0.0, fromInclusive = false, to = Infinity, toInclusive = false) float size
)
```

Sets the size of the brush, in stroke units.

## Extension functions

### BrushUtil.setAndroidColor

Artifact: [androidx.ink:ink-brush](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/brush/BrushExtensions.android.kt+function:setAndroidColor)

```
@RequiresApi(value = 26)
public final @NonNull Brush.Builder BrushUtil.setAndroidColor(
    @NonNull Brush.Builder receiver,
    @NonNull Color color
)
```

Set the color on a `https://developer.android.com/reference/androidx/ink/brush/Brush.Builder` as an `https://developer.android.com/reference/android/graphics/Color.html` instance. sRGB and Display P3 are supported; a color in any other color space will be converted to Display P3.