A MeshGradient is a 2D grid of patches defined by vertices.
MeshGradientModifierSample
@Composable
fun MeshGradientModifierSample() {
val rows = 1
val columns = 1
Box(
Modifier.size(300.dp).meshGradient(rows, columns) {
// (row, column, position, color)
setVertex(
0,
0,
Offset(0f, 0f),
Color.Red,
rightControlPoint = Offset(0.5f, 0.5f),
) // Top-Left
setVertex(0, 1, Offset(1f, 0f), Color.Blue) // Top-Right
setVertex(1, 0, Offset(0f, 1f), Color.Green) // Bottom-Left
setVertex(1, 1, Offset(1f, 1f), Color.Yellow) // Bottom-Right
}
)
}