Sergey Y.
04/03/2024, 11:14 PMSergey Y.
04/03/2024, 11:24 PMjw
04/03/2024, 11:25 PMjw
04/03/2024, 11:26 PMSergey Y.
04/03/2024, 11:26 PMSergey Y.
04/03/2024, 11:28 PMjw
04/03/2024, 11:28 PMStylianos Gakis
04/03/2024, 11:32 PManimateItem()
modifier works would work, but it’s definitely not a trivial one to understand 😄Sergey Y.
04/03/2024, 11:35 PMStylianos Gakis
04/04/2024, 12:06 AMlayer: GraphicsLayer
is 😅
I managed to get something working as I was testing this but I don’t even know if I am doing something wrong 😄Albert Chang
04/04/2024, 5:49 AMwhat the right way to get a hold of aJust useislayer: GraphicsLayer
rememberGraphicsLayer()
.
it's unclear whether it should be called on a non-UI coroutine dispatcher.All suspend functions in public API should be main-safe, meaning that you can call them with any dispatcher, including the main dispatcher. If they are not, you should probably file a bug. So basically you use it like this:
val scope = rememberCoroutineScope()
val graphicsLayer = rememberGraphicsLayer()
ComposableToCapture(
modifier = modifier.layout { measurable, constraints ->
val placeable = measurable.measure(constraints)
layout(placeable.width, placeable.height) {
placeable.placeWithLayer(0, 0, graphicsLayer)
}
}
)
Button(
onClick = {
scope.launch {
val bitmap = graphicsLayer.toImageBitmap()
}
}
)
I tried this and it worked well, except that shadows are not drawn to the bitmap.