Skip to content

Instantly share code, notes, and snippets.

@minhngoc826
Created May 10, 2024 10:53
Show Gist options
  • Save minhngoc826/0ba2954674ae8cd4f3e0cc797f13d7f3 to your computer and use it in GitHub Desktop.
Save minhngoc826/0ba2954674ae8cd4f3e0cc797f13d7f3 to your computer and use it in GitHub Desktop.
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