zt
05/30/2024, 4:00 AMdetectTapGestures { tapPosition ->
val newColor = colorForPosition(tapPosition, radius, color.hsvValue)
if (newColor.isSpecified) {
offsetX = tapPosition.x
offsetY = tapPosition.y
onColorChange(newColor)
}
}
I have this:
var offsetX by rememberSaveable(color) {
mutableStateOf(positionForColor(color))
}
var offsetY by rememberSaveable(color) {
mutableStateOf(positionForColor(color))
}
But then whenever my code calls onColorChange with the new color, it calculates the position again, even though the offset variables are already correct. What can I do to optimize this?