I saw this post :
https://www.reddit.com/r/androiddev/s/bNFqQ3TqOC

I thought I'd share this new Compose API with you.

In compose 1.12.0 introduce new GradientPainter you can implement complex gradients very easily.
It is called MeshGradientPainter.
You can define the count of column and row.

For example rows = 1 and columns = 1.

The screen is divided into 4 sections and points.

This points show two things:
1.postion. Where is it? For example : 0,0 — top left.
2.color. What color is it? for example this section color is Red

And then these colors are spread very smoothly on the screen.

✅ Example:

@Composable fun MeshGradientBackground() { val meshPainter = remember { MeshGradientPainter( rows = 1, columns = 1, hasBicubicColor = true ) { setVertex(0, 0, Offset(0f, 0f), Color.Red) setVertex(0, 1, Offset(1f, 0f), Color.Blue) setVertex(1, 0, Offset(0f, 1f), Color.Green) setVertex(1, 1, Offset(1f, 1f), Color.Yellow) } } Box( modifier = Modifier .fillMaxSize() .paint(meshPainter) ) } 
submitted by /u/Available_Visual_687
[link] [comments]