public fun drawToBitmap( bitmap: Bitmap, density: Density, size: Size, onDraw: DrawScope.() -> Unit ) { val androidCanvas = AndroidCanvas(bitmap) val composeCanvas = ComposeCanvas(androidCanvas) val canvasDrawScope = CanvasDrawScope() canvasDrawScope.draw(density, LayoutDirection.Ltr, composeCanvas, size) { onDraw() } }
Render an element normally drawn within a Compose Canvas into a Bitmap. This allows shared elements between the app and tiles.