In the view World we can just use View.draw(canvas) to draw view on our Canvas (which might be connected to bitmap). But here in compose how can we achieve the same.
We have a draw modifier but it has no method draw(canvas)
Update
What I need?
I wanted to blur a composable function by wrapping it inside a Blur Composable. Suppose xyz() is any random composabel function.
@Composable
fun xyz(){
// compose logic.
}
I want to create another fun called Blur().
@Composable
fun Blur(content: @Composable() -> Unit){
//Blur logic.
}
The Blur composable takes any composable function (say xyz()) as input and Blurs it.
How I am going to implement it?
I thought I would take the same approach which the BlurView (A view blur library) takes.
- The Blur View is a frame layout.
- it blurs its content.
- The BlurView first creates the bitmap of the content; blurs it; then draws it.
- The function used to create teh bitmap of the content is
view.draw(canvas: Canvas)
Why I need this?
I thought of creating my version of BlurView in compose. I know in compose there is a Modifier.blur; but since this is only supported in api 31( I guess) so I can't use it in my project.