Skip to content

Instantly share code, notes, and snippets.

@Kpeved
Last active February 22, 2023 20:49
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/af43608d64310138167a8311e53e76e3 to your computer and use it in GitHub Desktop.
Save Kpeved/af43608d64310138167a8311e53e76e3 to your computer and use it in GitHub Desktop.
var strokeWidth by remember { mutableStateOf(0f) }
Spacer(modifier = Modifier
.fillMaxSize()
// Set strokeWidth based on the size of the viewport
.onGloballyPositioned {
strokeWidth = (it.size.width / 24).toFloat()
}
.drawBehind {
val center = Offset(size.width / 2, size.height / 2)
val endOffset = Offset(size.width / 2, 0f)
// Rotate the line around the pivot point, which is the
// center of the screen. Rotation goes from 0 to 720 degrees
rotate(clockAnimation, pivot = center) {
drawLine(
color = Color.White,
start = center,
end = endOffset,
strokeWidth = strokeWidth,
)
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment