# BrushUtil

Added in 1.0.0

*** ** * ** ***


```
public final class BrushUtil
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/Brush` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/ink/brush/BrushUtil#(androidx.ink.brush.Brush).copyWithAndroidColor(android.graphics.Color,androidx.ink.brush.BrushFamily,kotlin.Float,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/Brush receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Color.html color, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/BrushFamily family, float size, float epsilon )` Creates a copy of `this` `https://developer.android.com/reference/androidx/ink/brush/Brush` and allows named properties to be altered while keeping the rest unchanged. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Color.html` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/ink/brush/BrushUtil#(androidx.ink.brush.Brush).createAndroidColor()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/Brush receiver)` The brush color as an `https://developer.android.com/reference/android/graphics/Color.html` instance, which can express colors in several different color spaces. sRGB and Display P3 are supported; a color in any other color space will be converted to Display P3. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/Brush` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/ink/brush/BrushUtil#createWithAndroidColor(androidx.ink.brush.BrushFamily,android.graphics.Color,kotlin.Float,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/BrushFamily family, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Color.html color, float size, float epsilon )` Returns a new `https://developer.android.com/reference/androidx/ink/brush/Brush` with the color specified by an `https://developer.android.com/reference/android/graphics/Color.html` instance, 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. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/Brush` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/ink/brush/BrushUtil#(androidx.ink.brush.Brush.Companion).createWithAndroidColor(androidx.ink.brush.BrushFamily,android.graphics.Color,kotlin.Float,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/Brush.Companion receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/brush/BrushFamily family, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Color.html color, float size, float epsilon )` Returns a new `https://developer.android.com/reference/androidx/ink/brush/Brush` with the color specified by an `https://developer.android.com/reference/android/graphics/Color.html` instance, 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. |
| `static 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#(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 methods

### copyWithAndroidColor

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:copyWithAndroidColor) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
@RequiresApi(value = 26)
public static final @NonNull Brush copyWithAndroidColor(
    @NonNull Brush receiver,
    @NonNull Color color,
    @NonNull BrushFamily family,
    float size,
    float epsilon
)
```

Creates a copy of `this` `https://developer.android.com/reference/androidx/ink/brush/Brush` and allows named properties to be altered while keeping the rest unchanged. The color is specified as an `https://developer.android.com/reference/android/graphics/Color.html` instance, 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.

### createAndroidColor

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:createAndroidColor) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
@RequiresApi(value = 26)
public static final @NonNull Color createAndroidColor(@NonNull Brush receiver)
```

The brush color as an `https://developer.android.com/reference/android/graphics/Color.html` instance, which can express colors in several different color spaces. sRGB and Display P3 are supported; a color in any other color space will be converted to Display P3.

Unless an instance of `https://developer.android.com/reference/android/graphics/Color.html` is actually needed, prefer to use `https://developer.android.com/reference/androidx/ink/brush/Brush#colorLong()` to get the color without causing an allocation, especially in performance-sensitive code. `https://developer.android.com/reference/androidx/ink/brush/Brush#colorLong()` is fully compatible with the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` representation of `https://developer.android.com/reference/android/graphics/Color.html`.

### createWithAndroidColor

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:createBrushWithAndroidColor) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
@RequiresApi(value = 26)
public static final @NonNull Brush createWithAndroidColor(
    @NonNull BrushFamily family,
    @NonNull Color color,
    float size,
    float epsilon
)
```

Returns a new `https://developer.android.com/reference/androidx/ink/brush/Brush` with the color specified by an `https://developer.android.com/reference/android/graphics/Color.html` instance, 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.

Kotlin callers should prefer `https://developer.android.com/reference/androidx/ink/brush/package-summary#(androidx.ink.brush.Brush.Companion).createWithAndroidColor(androidx.ink.brush.BrushFamily,android.graphics.Color,kotlin.Float,kotlin.Float)`.

### createWithAndroidColor

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:createWithAndroidColor) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
@RequiresApi(value = 26)
public static final @NonNull Brush createWithAndroidColor(
    @NonNull Brush.Companion receiver,
    @NonNull BrushFamily family,
    @NonNull Color color,
    float size,
    float epsilon
)
```

Returns a new `https://developer.android.com/reference/androidx/ink/brush/Brush` with the color specified by an `https://developer.android.com/reference/android/graphics/Color.html` instance, 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.

Java callers should prefer `BrushUtil.createWithAndroidColor` (`https://developer.android.com/reference/androidx/ink/brush/package-summary#createBrushWithAndroidColor(androidx.ink.brush.BrushFamily,android.graphics.Color,kotlin.Float,kotlin.Float)`).

### 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) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
@RequiresApi(value = 26)
public static final @NonNull Brush.Builder 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.