I have here my code which just displays a simple color palette:
@Composable
fun ColorPicker(modifier: Modifier = Modifier) {
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
}
That looks pretty good:
But now I want to get the RGB Value if the usere clicks on the color palette. How would I do this? (This is Jetpack Compose Desktop but it should be the same as on Android)