Function

linearGradient

Creates a linear gradient with the provided colors along the given start and end coordinates.

linearGradient

Source set: JvmAndAndroid
public fun RemoteBrush.Companion.linearGradient(
    vararg colorStops: Pair<RemoteFloat, RemoteColor>,
    start: RemoteOffset? = null,
    end: RemoteOffset? = null,
    tileMode: RemoteTileMode = RemoteTileMode.Clamp,
): RemoteShaderBrush

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.

RemoteBrush.linearGradient(
0.0f.rf to Color.Red.rc,
0.3f.rf to Color.Green.rc,
1.0f.rf to Color.Blue.rc,
start = RemoteOffset(0.0f.rf, 50.0f.rf),
end = RemoteOffset(0.0f.rf, 100.0f.rf)
)

Parameters

colorStops Colors and their offset in the gradient area
start Starting position of the linear gradient. This can be set to RemoteOffset.Zero to position at the far left and top of the drawing area
end Ending position of the linear gradient. This can be set to RemoteOffset.Infinite to position at the far right and bottom of the drawing area
tileMode Determines the behavior for how the shader is to fill a region outside its bounds. Defaults to RemoteTileMode.Clamp to repeat the edge pixels

Return

a RemoteShaderBrush that draws a linear gradient with the given colorStops

linearGradient

Source set: JvmAndAndroid
public fun RemoteBrush.Companion.linearGradient(
    colors: List<RemoteColor>,
    start: RemoteOffset? = null,
    end: RemoteOffset? = null,
    tileMode: RemoteTileMode = RemoteTileMode.Clamp,
): RemoteShaderBrush

Creates a linear gradient with the provided colors along the given start and end coordinates.

RemoteBrush.linearGradient(
listOf(Color.Red.rc, Color.Blue.rc),
start = RemoteOffset(0.rf, 50.rf)
end = RemoteOffset(0.rf, 100.rf)
)

Parameters

colors Colors to be rendered as part of the gradient
start Starting position of the linear gradient. This can be set to RemoteOffset.Zero to position at the far left and top of the drawing area
end Ending position of the linear gradient. This can be set to RemoteOffset.Infinite to position at the far right and bottom of the drawing area
tileMode Determines the behavior for how the shader is to fill a region outside its bounds. Defaults to RemoteTileMode.Clamp to repeat the edge pixels

Return

a RemoteShaderBrush that draws a linear gradient across the given colors

Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: