# Brush.Companion

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

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOS
- Cmn

  ```
  object Brush.Companion
  ```

*** ** * ** ***

## Summary

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush.Builder` | `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush#builder()()` Returns a new `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush.Builder`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush` | `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush#createWithColorIntArgb(androidx.ink.brush.BrushFamily,kotlin.Int,kotlin.Float,kotlin.Float)( family: https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily, colorIntArgb: @https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, size: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, epsilon: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Returns a new `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush` with the color specified by a `https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt`, which is in the sRGB color space by definition. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush` | `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush#createWithColorLong(androidx.ink.brush.BrushFamily,kotlin.Long,kotlin.Float,kotlin.Float)( family: https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily, colorLong: @https://developer.android.com/reference/kotlin/androidx/annotation/ColorLong https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, size: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, epsilon: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Returns a new `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush` with the color specified by a `https://developer.android.com/reference/kotlin/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. | Cmn |

| ### Extension functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush` | `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush.Companion.https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush.Companion#(androidx.ink.brush.Brush.Companion).createWithComposeColor(androidx.ink.brush.BrushFamily,androidx.compose.ui.graphics.Color,kotlin.Float,kotlin.Float)( family: https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily, color: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color, size: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, epsilon: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Returns a new `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush` with the color specified by an `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` value, 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. | android |
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush` | `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush.Companion.https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush.Companion#(androidx.ink.brush.Brush.Companion).createWithUiColor(androidx.ink.brush.BrushFamily,platform.UIKit.UIColor,kotlin.Float,kotlin.Float)( family: https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily, color: platform.UIKit.UIColor, size: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, epsilon: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Returns a new `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush` with the color specified by a instance. | N |
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush.Companion.https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush.Companion#(androidx.ink.brush.Brush.Companion).createWithAndroidColor(androidx.ink.brush.BrushFamily,android.graphics.Color,kotlin.Float,kotlin.Float)( family: https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily, color: https://developer.android.com/reference/android/graphics/Color.html, size: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, epsilon: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Returns a new `https://developer.android.com/reference/kotlin/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. | android |

## Public functions

### builder

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

```
fun builder(): Brush.Builder
```

Returns a new `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush.Builder`.

### createWithColorIntArgb

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

```
fun createWithColorIntArgb(
    family: BrushFamily,
    colorIntArgb: @ColorInt Int,
    size: Float,
    epsilon: Float
): Brush
```

Returns a new `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush` with the color specified by a `https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt`, which is in the sRGB color space by definition. Note that the `https://developer.android.com/reference/kotlin/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 callers that want to specify a literal `https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt` with alpha \>= 0x80 must call `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/to-int.html` on the literal.

### createWithColorLong

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

```
fun createWithColorLong(
    family: BrushFamily,
    colorLong: @ColorLong Long,
    size: Float,
    epsilon: Float
): Brush
```

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

## Extension functions

### Brush.Companion.createWithComposeColor

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

```
fun Brush.Companion.createWithComposeColor(
    family: BrushFamily,
    color: Color,
    size: Float,
    epsilon: Float
): Brush
```

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

### Brush.Companion.createWithUiColor

N 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.ios.kt+function:createWithUiColor)

```
fun Brush.Companion.createWithUiColor(
    family: BrushFamily,
    color: platform.UIKit.UIColor,
    size: Float,
    epsilon: Float
): Brush
```

Returns a new `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush` with the color specified by a instance. The color is specified as a instance, which can encode several different color spaces, but stores both color-spaces supported by Ink (sRGB and Display P3) colors as extended sRGB, so this always converts to a Display P3 color in Ink. Will raise `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` if the cannot be converted to extended sRGB.

### Brush.Companion.createWithAndroidColor

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

```
@RequiresApi(value = 26)
fun Brush.Companion.createWithAndroidColor(
    family: BrushFamily,
    color: Color,
    size: Float,
    epsilon: Float
): Brush
```

Returns a new `https://developer.android.com/reference/kotlin/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/kotlin/androidx/ink/brush/package-summary#createBrushWithAndroidColor(androidx.ink.brush.BrushFamily,android.graphics.Color,kotlin.Float,kotlin.Float)`).