Start native apps faster with the Composables CLI ->
Composable Function

RemoteCanvas

A Composable that provides a RemoteDrawScope for drawing operations in RemoteCompose.

RemoteCanvasSample

@Sampled
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun RemoteCanvasSample() {
    RemoteCanvas(modifier = RemoteModifier.size(100.rdp)) {
        val paint = RemotePaint().apply { color = Color.Red.rc }
        drawCircle(paint = paint, radius = 50.rf)
    }
}

RemoteCanvasAnimationSample

@Sampled
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun RemoteCanvasAnimationSample() {
    // This sample uses ContinuousSec which might be restricted in some contexts,
    // but demonstrates how to create time-based animations on the remote canvas.
    RemoteCanvas(modifier = RemoteModifier.size(100.rdp)) {
        val paint = RemotePaint().apply { color = Color.Blue.rc }

        val time = remote.time.ContinuousSec()

        // Oscillate radius between 10 and 40
        val sineValue = sin(time)
        val normalizedSine = (sineValue + 1f.rf) / 2f.rf
        val radius = 10f.rf + 30f.rf * normalizedSine

        drawCircle(paint = paint, radius = radius)
    }
}