Rive

fun Rive(file: RiveFile, modifier: Modifier = Modifier, playing: Boolean = true, artboard: Artboard? = null, stateMachine: StateMachine? = null, viewModelInstance: ViewModelInstance? = null, fit: Fit = RenderingDefaults.defaultFit(), backgroundColor: Int = RenderingDefaults.CLEAR_COLOR, pointerInputMode: RivePointerInputMode = Consume, frameRate: RiveFrameRate = RiveFrameRate.Unbounded, onBitmapAvailable: (GetBitmapFun) -> Unit? = null)

The main composable for rendering a Rive file's artboard and state machine.

Internally, Rive uses a TextureView to create and manage a android.view.Surface for rendering.

The composable will advance the state machine and draw the artboard on every frame while the Lifecycle is in the Lifecycle.State.RESUMED state. It will also handle pointer input events to influence the state machine, such as pointer down, move, and up events.

A Rive composable can enter a settled state, where it stops advancing the state machine. It will be restarted when influenced by other events, such as pointer input or view model instance changes.

Parameters

file

The RiveFile that created the artboard and state machine.

modifier

The Modifier to apply to the composable.

playing

Whether the state machine should advance. When true (default), the state machine will advance on each frame. When false, the advancement loop will not activate.

artboard

The Artboard to render. If null, the default artboard will be used.

stateMachine

The StateMachine to use. If null, the default state machine will be created.

viewModelInstance

The ViewModelInstance to bind to the state machine. If null, no view model instance will be bound.

fit

The Fit to use for the artboard. Defaults to Fit.Contain.

backgroundColor

The color to clear the surface with before drawing. Defaults to transparent.

pointerInputMode

Controls how pointer events are handled and consumed by Rive. See RivePointerInputMode. Default is RivePointerInputMode.Consume.

frameRate

Controls how often Rive advances and draws while playing is true. Defaults to RiveFrameRate.Unbounded, which renders on every platform frame callback. On supported Android versions, capped rates are also used as an advisory view frame-rate hint.

onBitmapAvailable

Optional callback that is invoked when the first bitmap frame is available. The callback provides a function to get the current Bitmap from the underlying TextureView. This can be used for snapshot testing or storing rendered output. The bitmap getter is only valid while the surface is active.