Jan
07/07/2021, 7:13 PMJan
07/07/2021, 7:21 PM@Composable
fun ColorPicker(modifier: Modifier = Modifier, onSelect: (Color) -> Unit) {
BoxWithConstraints {
var selectedColor by remember { mutableStateOf(Color.Red) }
Box(
modifier = modifier
.fillMaxSize()
.background(Brush.horizontalGradient(colors()))
) {
}
}
}
fun colors(n: Int = 359): List<Color> {
val cols = mutableListOf<Color>()
for (i in 0 until n) {
val color = java.awt.Color.getHSBColor(i.toFloat() / n.toFloat(), 0.85f, 1.0f)
cols.add(Color(color.red, color.green, color.blue, color.alpha))
}
return cols
}
Now how would I get the Color if the user clicks on the palette? (Or is there a different way for this?)Jan
07/07/2021, 7:30 PMChris Sinco [G]
07/08/2021, 12:38 AMTobias Suchalla
07/08/2021, 5:41 AM