So I have the following CSS gradient example
background: var(--Gradient, linear-gradient(96deg, #FAF354 -11.84%, #00CA69 71.35%));
For Jetpack Compose I have only added colors, but I have no idea how to add such angle (96deg
) and color stops (-11.84%
, 71.35%
):
BoxWithConstraints(modifier = Modifier.size(100.dp)) {
val size = with(LocalDensity.current) { maxHeight.toPx() }
Box(
Modifier
.fillMaxSize()
.background(
brush = Brush.linearGradient(
colors = listOf(
Color(0xFFFAF354),
Color(0xFF00CA69)
),
start = Offset(...,...)
end = Offset(...,...)
),
)
)
}
Update:
Found solution for color stops:
colorStops = arrayOf(
Pair(-0.1184f /*-11.84f*/, Color(0xFFFAF354)),
Pair(0.7135f /*71.35f*/, Color(0xFF00CA69))
),