Skip to content

Instantly share code, notes, and snippets.

@Krishan14sharma
Last active December 12, 2017 14:43
Show Gist options
  • Save Krishan14sharma/1d5271c0f71054d46d733d5a5b53acef to your computer and use it in GitHub Desktop.
Save Krishan14sharma/1d5271c0f71054d46d733d5a5b53acef to your computer and use it in GitHub Desktop.
private fun animateWin() {
val valueAnimator = ValueAnimator.ofFloat(1f, 0f)
valueAnimator.duration = 600
valueAnimator.addUpdateListener(this)
valueAnimator.start()
}
override fun onAnimationUpdate(animation: ValueAnimator) {
val measure = PathMeasure(path, false)
val offset = (measure.length * (animation.animatedValue as Float))
paint.pathEffect = createPathEffect(measure.length, offset)
invalidate()
}
private fun createPathEffect(pathLength: Float, offset: Float): PathEffect {
return DashPathEffect(floatArrayOf(pathLength, pathLength),
offset)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment