Last active
August 29, 2015 13:55
-
-
Save fada21/8721867 to your computer and use it in GitHub Desktop.
PathAnimation class for Android
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
package com.coolands.open; | |
import android.graphics.Path; | |
import android.graphics.PathMeasure; | |
import android.view.animation.Animation; | |
import android.view.animation.Transformation; | |
/** | |
* Animation along path | |
* by Ewan Chou (https://github.com/coocood) | |
*/ | |
public class PathAnimation extends Animation { | |
private PathMeasure measure; | |
private float[] pos = new float[2]; | |
public PathAnimation(Path path) { | |
measure = new PathMeasure(path, false); | |
} | |
@Override | |
protected void applyTransformation(float interpolatedTime, Transformation t){ | |
measure.getPosTan(measure.getLength() * interpolatedTime, pos,null); | |
t.getMatrix().setTranslate(pos[0], pos[1]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment