Skip to content

Instantly share code, notes, and snippets.

@Kpeved
Created February 22, 2023 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kpeved/9728a0d29e29b1ad2a2cd3db75ca0e7e to your computer and use it in GitHub Desktop.
Save Kpeved/9728a0d29e29b1ad2a2cd3db75ca0e7e to your computer and use it in GitHub Desktop.
//Function which calculates the length of the clock hand
private fun calculateClockHandLength(maxHeight: Float, currentHour: Int): Float {
val stepHeight = maxHeight / 12
// Height decreases first 360 deg, then increases again
return stepHeight * if (currentHour < 12) {
12 - 1 - currentHour
} else {
currentHour - 12
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment