BrushUtil

Added in 1.0.0-alpha02

public final class BrushUtil


Summary

Public methods

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

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

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

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.

static final @NonNull 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.

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

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.

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

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.

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

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.

static final @NonNull Brush.Builder
@RequiresApi(value = 26)
toBuilderWithAndroidColor(@NonNull Brush receiver, @NonNull Color color)

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.

Public methods

copyWithAndroidColor

@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 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)
public static final @NonNull Color createAndroidColor(@NonNull Brush receiver)

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.

createBuilderWithAndroidColor

@RequiresApi(value = 26)
public static final @NonNull Brush.Builder createBuilderWithAndroidColor(@NonNull Color color)

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.

createWithAndroidColor

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

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.

createWithAndroidColor

@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 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)
public static final @NonNull Brush.Builder setAndroidColor(@NonNull Brush.Builder receiver, @NonNull Color color)

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)
public static final @NonNull Brush.Builder toBuilderWithAndroidColor(@NonNull Brush receiver, @NonNull Color color)

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.