androidx.ink.brush


Classes

Brush

Defines how stroke inputs are interpreted to create the visual representation of a stroke.

android
Brush.Builder

Builder for Brush.

android
BrushFamily

A BrushFamily describes a family of brushes (e.g. “highlighter” or “pressure pen”), irrespective of their size or color.

android
InputToolType

The type of input tool used in producing androidx.ink.strokes.StrokeInput, used by BrushBehavior to define when a behavior is applicable.

android

Objects

Brush.Companion
android
StockBrushes

Provides a fixed set of stock BrushFamily objects that any app can use.

android

Annotations

ExperimentalInkCustomBrushApi

Marks declarations that are are part of the experimental Ink brush customization API.

android

Top-level functions summary

Brush.Builder

Returns a new, blank Brush.Builder with the color specified by an android.graphics.Color 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
Brush
@RequiresApi(value = 26)
createBrushWithAndroidColor(
    family: BrushFamily,
    color: Color,
    size: Float,
    epsilon: Float
)

Returns a new Brush with the color specified by an android.graphics.Color 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

Extension functions summary

Brush
@RequiresApi(value = 26)
Brush.copyWithAndroidColor(
    color: Color,
    family: BrushFamily,
    size: Float,
    epsilon: Float
)

Creates a copy of this Brush and allows named properties to be altered while keeping the rest unchanged.

android
Color

The brush color as an android.graphics.Color 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.

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

Returns a new Brush with the color specified by an android.graphics.Color 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
Brush.Builder

Set the color on a Brush.Builder as an android.graphics.Color instance. sRGB and Display P3 are supported; a color in any other color space will be converted to Display P3.

android
Brush.Builder

Returns a Brush.Builder with values set equivalent to the Brush and the color specified by an android.graphics.Color 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

Top-level functions

createBrushBuilderWithAndroidColor

@RequiresApi(value = 26)
fun createBrushBuilderWithAndroidColor(color: Color): Brush.Builder

Returns a new, blank Brush.Builder with the color specified by an android.graphics.Color 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.

In Kotlin, calling this is equivalent to calling Brush.builder followed by Brush.Builder.setAndroidColor. For Java callers, this function allows more fluent call chaining.

createBrushWithAndroidColor

@RequiresApi(value = 26)
fun createBrushWithAndroidColor(
    family: BrushFamily,
    color: Color,
    size: Float,
    epsilon: Float
): Brush

Returns a new Brush with the color specified by an android.graphics.Color 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 Brush.Companion.createWithAndroidColor.

Extension functions

copyWithAndroidColor

@RequiresApi(value = 26)
fun Brush.copyWithAndroidColor(
    color: Color,
    family: BrushFamily = this.family,
    size: Float = this.size,
    epsilon: Float = this.epsilon
): Brush

Creates a copy of this Brush and allows named properties to be altered while keeping the rest unchanged. The color is specified as an android.graphics.Color 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

@RequiresApi(value = 26)
fun Brush.createAndroidColor(): Color

The brush color as an android.graphics.Color 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 android.graphics.Color is actually needed, prefer to use Brush.colorLong to get the color without causing an allocation, especially in performance-sensitive code. Brush.colorLong is fully compatible with the Long representation of android.graphics.Color.

createWithAndroidColor

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

Returns a new Brush with the color specified by an android.graphics.Color 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 (createBrushWithAndroidColor).

setAndroidColor

@RequiresApi(value = 26)
fun Brush.Builder.setAndroidColor(color: Color): Brush.Builder

Set the color on a Brush.Builder as an android.graphics.Color instance. sRGB and Display P3 are supported; a color in any other color space will be converted to Display P3.

Java callers should prefer toBuilderWithAndroidColor or createBrushBuilderWithAndroidColor as a more fluent API.

toBuilderWithAndroidColor

@RequiresApi(value = 26)
fun Brush.toBuilderWithAndroidColor(color: Color): Brush.Builder

Returns a Brush.Builder with values set equivalent to the Brush and the color specified by an android.graphics.Color 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 developers, use the returned builder to build a copy of a Brush. Kotlin developers, see copyWithAndroidColor method.

In Kotlin, calling this is equivalent to calling Brush.toBuilder followed by Brush.Builder.setAndroidColor. For Java callers, this function allows more fluent call chaining.