androidx.compose.ui.graphics
Brush
Sealed class · from org.jetbrains.compose.ui:ui-graphics:1.12.2
No hand-written docs yet.
sealed class Brush
Kinds of Brush
Anywhere a Brush is expected, you can pass any of these.
ShaderBrushui-graphicsLinearGradientui-graphicsRadialGradientui-graphicsSweepGradientui-graphics
SolidColorui-graphics
How to get one
Ready-made values and functions that return it
Used by
Parameters that take a Brush.
background(brush)BasicSecureTextField(cursorBrush)BasicTextField(cursorBrush)border(brush)BorderStroke.copy(brush)Brush.composite(dstBrush, srcBrush)DrawScope.drawArc(brush)DrawScope.drawCircle(brush)DrawScope.drawLine(brush)DrawScope.drawOval(brush)DrawScope.drawPath(brush)DrawScope.drawPoints(brush)DrawScope.drawRect(brush)DrawScope.drawRoundRect(brush)TextStyle.copy(brush)
Properties
intrinsicSize
val intrinsicSize: Size
Return the intrinsic size of the Brush. If the there is no intrinsic size (i.e. filling bounds with an arbitrary color) return Size.Unspecified. If there is no intrinsic size in a single dimension, return Size with Float.NaN in the desired dimension.
Functions
applyTo
fun applyTo(
size: Size,
p: Paint,
alpha: Float,
)
linearGradient
fun linearGradient(
vararg colorStops: Pair<Float, Color>,
start: Offset = Offset.Zero,
end: Offset = Offset.Infinite,
tileMode: TileMode = TileMode.Clamp,
): Brush
Creates a linear gradient with the provided colors along the given start and end coordinates. The colors are dispersed at the provided offset defined in the colorstop pair.
fun linearGradient(
colors: List<Color>,
start: Offset = Offset.Zero,
end: Offset = Offset.Infinite,
tileMode: TileMode = TileMode.Clamp,
): Brush
Creates a linear gradient with the provided colors along the given start and end coordinates. The colors are
horizontalGradient
fun horizontalGradient(
colors: List<Color>,
startX: Float = 0.0f,
endX: Float = Float.POSITIVE_INFINITY,
tileMode: TileMode = TileMode.Clamp,
): Brush
Creates a horizontal gradient with the given colors evenly dispersed within the gradient
fun horizontalGradient(
vararg colorStops: Pair<Float, Color>,
startX: Float = 0.0f,
endX: Float = Float.POSITIVE_INFINITY,
tileMode: TileMode = TileMode.Clamp,
): Brush
Creates a horizontal gradient with the given colors dispersed at the provided offset defined in the colorstop pair.
verticalGradient
fun verticalGradient(
colors: List<Color>,
startY: Float = 0.0f,
endY: Float = Float.POSITIVE_INFINITY,
tileMode: TileMode = TileMode.Clamp,
): Brush
Creates a vertical gradient with the given colors evenly dispersed within the gradient Ex: Brush.verticalGradient( listOf(Color.Red, Color.Green, Color.Blue), startY = 0.0f, endY = 100.0f )
fun verticalGradient(
vararg colorStops: Pair<Float, Color>,
startY: Float = 0f,
endY: Float = Float.POSITIVE_INFINITY,
tileMode: TileMode = TileMode.Clamp,
): Brush
Creates a vertical gradient with the given colors at the provided offset defined in the [Pair<Float, Color>]
radialGradient
fun radialGradient(
vararg colorStops: Pair<Float, Color>,
center: Offset = Offset.Unspecified,
radius: Float = Float.POSITIVE_INFINITY,
tileMode: TileMode = TileMode.Clamp,
): Brush
Creates a radial gradient with the given colors at the provided offset defined in the colorstop pair.
fun radialGradient(
colors: List<Color>,
center: Offset = Offset.Unspecified,
radius: Float = Float.POSITIVE_INFINITY,
tileMode: TileMode = TileMode.Clamp,
): Brush
Creates a radial gradient with the given colors evenly dispersed within the gradient
sweepGradient
fun sweepGradient(
vararg colorStops: Pair<Float, Color>,
center: Offset = Offset.Unspecified,
): Brush
Creates a sweep gradient with the given colors dispersed around the center with offsets defined in each colorstop pair. The sweep begins relative to 3 o'clock and continues clockwise until it reaches the starting position again.
fun sweepGradient(
colors: List<Color>,
center: Offset = Offset.Unspecified,
): Brush
Creates a sweep gradient with the given colors dispersed evenly around the center. The sweep begins relative to 3 o'clock and continues clockwise until it reaches the starting position again.
composite
fun composite(
dstBrush: Brush,
srcBrush: Brush,
blendMode: BlendMode,
): Brush
Creates a composited result between 2 Brush instances and the specified BlendMode. The specified destination and source Brush inputs will be consumed as the source and destination images for the corresponding blending algorithm.