drawToBuffer

fun drawToBuffer(artboardHandle: ArtboardHandle, stateMachineHandle: StateMachineHandle, surface: RiveSurface, buffer: ByteArray, width: Int, height: Int, fit: Fit = Fit.Contain(), clearColor: Int = Color.TRANSPARENT)

Renders the current state of an artboard/state machine pair into an off-screen buffer that can be used for snapshot comparisons.

⚠️ Unlike other CommandQueue methods, this method is synchronous and blocks the calling thread.

Parameters

artboardHandle

The handle of the artboard to draw.

stateMachineHandle

The handle of the state machine to advance/draw.

surface

The surface to draw to, likely created from createImageSurface.

buffer

The byte array buffer to render into. Must be at least width * height * 4 bytes in size.

width

The width of the buffer to render.

height

The height of the buffer to render.

fit

Fit to use when drawing.

clearColor

Clear color used prior to drawing, defaults to transparent.

Throws

If the buffer could not be drawn to for any reason. Further details can be found in the exception message.

If the CommandQueue has been released or surface is closed.