Last active
December 12, 2017 14:43
-
-
Save Krishan14sharma/1d5271c0f71054d46d733d5a5b53acef to your computer and use it in GitHub Desktop.
This file contains 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 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