Skip to content

Instantly share code, notes, and snippets.

@zsoltk
Created January 26, 2020 17:24
Show Gist options
  • Save zsoltk/1086330849f6f1cc062594077d539cfc to your computer and use it in GitHub Desktop.
Save zsoltk/1086330849f6f1cc062594077d539cfc to your computer and use it in GitHub Desktop.
@Composable
fun RotatingPokeball() {
val children: @Composable() () -> Unit = {
Opacity(opacity = 0.75f) {
DrawImage(
image = +imageResource(R.drawable.pokeball),
tint = +colorResource(R.color.poke_red)
)
}
}
Transition(definition = definition, initState = 0, toState = 1) { transitionState ->
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(transitionState[rotation])
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