Skip to content

Instantly share code, notes, and snippets.

@zsoltk
Created January 25, 2020 19:42
Show Gist options
  • Select an option

  • Save zsoltk/ed4fac81dea2c614dc56a568b2eeff93 to your computer and use it in GitHub Desktop.

Select an option

Save zsoltk/ed4fac81dea2c614dc56a568b2eeff93 to your computer and use it in GitHub Desktop.
@Composable
fun RotateAroundCenter() {
/* remainder omitted */
Draw(children = children) { canvas, parent ->
val halfWidth = parent.width.value / 2
val halfHeight = parent.height.value / 2
canvas.save()
canvas.translate(halfWidth, halfHeight)
canvas.rotate(45f)
canvas.translate(-halfWidth, -halfHeight)
drawChildren()
canvas.restore()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment