Three sliders are defined in Jetpack Compose and the thumb positions of these three sliders are needed to connect them using a Path in a Canvas behind them. How to get the position PointF(x,y) of the thumb in each Slider to draw the Path or any other way to achieve this? Below is sample code snippet and image of sample implementation to achieve.
@Composable
fun MySliderDemo() {
var sliderPosition1 = remember { mutableStateOf(0f) }
var sliderPosition2 = remember { mutableStateOf(0f) }
var sliderPosition3 = remember { mutableStateOf(0f) }
Slider(value = sliderPosition1.value, onValueChange = { sliderPosition1.value = it })
Slider(value = sliderPosition2.value, onValueChange = { sliderPosition2.value = it })
Slider(value = sliderPosition3.value, onValueChange = { sliderPosition3.value = it })
}



var pos1 by remember { mutableStateOf(0f) } var pos2 by remember { mutableStateOf(0f) } var pos3 by remember { mutableStateOf(0f) }
with every Slider's
onValueChangeFinished, you get each of their values. You can also get theLayoutCoordinatesof the Slider (I assume you only need to get it from one of them since they're all the same size, but if not, you can just keep track of all 3) fromModifier.onGloballyPositioned. From there, you should be able to calculate the position of each slider based on the Slider value and the layout coordinates (which give you position, size, etc.)