Function

linearGradient

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

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free

linearGradient

Android
public fun RemoteBrush.Companion.linearGradient(
    colors: List<RemoteColor>,
    start: RemoteOffset? = null,
    end: RemoteOffset? = null,
    tileMode: ComposeTileMode = ComposeTileMode.Clamp,
): RemoteBrush

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

 Brush.linearGradient(    listOf(Color.Red.rc, Color.Blue.rc),    start = Offset(0.rf, 50.rf)    end = Offset(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 ComposeTileMode.Clamp to repeat the edge pixels