This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val rotation = FloatPropKey() | |
private fun createDefinition(duration: Int) = transitionDefinition { | |
state(0) { this[rotation] = 0f } | |
state(1) { this[rotation] = 360f } | |
transition { | |
rotation using repeatable { | |
animation = tween { | |
easing = LinearEasing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
animation = tween { | |
duration = 1000 | |
easing = LinearEasing | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val rotation = FloatPropKey() | |
private val definition = transitionDefinition { | |
state(0) { this[rotation] = 0f } | |
state(1) { this[rotation] = 360f } | |
transition { | |
rotation using repeatable { | |
animation = tween { duration = 1000 } | |
iterations = Infinite |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun RotatingPokeball() { | |
val children: @Composable() () -> Unit = { | |
Opacity(opacity = 0.75f) { | |
DrawImage( | |
image = +imageResource(R.drawable.pokeball), | |
tint = +colorResource(R.color.poke_red) | |
) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val rotation = FloatPropKey() | |
private val definition = transitionDefinition { | |
state(0) { this[rotation] = 0f } | |
state(1) { this[rotation] = 360f } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I/System.out: Transition: 20.0 | |
I/System.out: Transition: 68.80052 | |
I/System.out: Transition: 153.58815 | |
I/System.out: Transition: 234.93356 | |
I/System.out: Transition: 292.17978 | |
I/System.out: Transition: 331.75845 | |
I/System.out: Transition: 359.05087 | |
I/System.out: Transition: 375.11713 | |
I/System.out: Transition: 385.07782 | |
I/System.out: Transition: 391.43237 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val myFloatKey = FloatPropKey() | |
enum class MyState { | |
STATE_A, STATE_B | |
} | |
val definition = transitionDefinition { | |
state(STATE_A) { | |
this[myFloatKey] = 20f | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun VisualDebug() { | |
// Wrapping it here for a visual clue | |
Surface(color = Color.LightGray) { | |
// From here on it's the same | |
Container(width = 200.dp, height = 200.dp) { | |
/* remainder omitted */ | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun Pokeball() { | |
Container(width = 200.dp, height = 200.dp) { | |
val children: @Composable() () -> Unit = { | |
Opacity(opacity = 0.75f) { | |
DrawImage( | |
image = +imageResource(R.drawable.pokeball), | |
tint = +colorResource(R.color.poke_red) | |
) | |
} |