Brush.Companion



Summary

Public functions

Brush.Builder

Returns a new Brush.Builder.

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

Returns a new Brush with the color specified by a ColorInt, which is in the sRGB color space by definition.

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

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

android

Extension functions

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

Public functions

builder

fun builder(): Brush.Builder

Returns a new Brush.Builder.

createWithColorIntArgb

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

Returns a new Brush with the color specified by a ColorInt, which is in the sRGB color space by definition. Note that the ColorInt channel order puts alpha first (in the most significant byte).

Kotlin interprets integer literals greater than 0x7fffffff as Longs, so callers that want to specify a literal ColorInt with alpha >= 0x80 must call Long.toInt on the literal.

createWithColorLong

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

Returns a new Brush with the color specified by a 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 ULong for ColorLongs, so the caller must call ULong.toLong on such a value before passing it to this method.

Extension functions

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