Created
May 10, 2024 10:53
-
-
Save minhngoc826/0ba2954674ae8cd4f3e0cc797f13d7f3 to your computer and use it in GitHub Desktop.
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
iconDrawable.let { drawable -> | |
val scaleX = lerp(0f, 1f, scaleIconFraction) | |
val scaleY = scaleX | |
val pivotX = width / 2f | |
val pivotY = height / 2f | |
canvas.withScale(scaleX, scaleY, pivotX, pivotY) { | |
// rotate the icon if it appears | |
if (scaleIconFraction > 0) { | |
invalidate() | |
} | |
rotate(iconDegree, pivotX, pivotY) | |
// Anticlockwise direction | |
val iconSpeed = 6 | |
iconDegree = (iconDegree - iconSpeed) % 360 | |
drawable.draw(canvas) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment