use of android.graphics.PathMeasure in project muzei by romannurik.
the class AnimatedMuzeiLogoView method rebuildGlyphData.
private void rebuildGlyphData() {
SvgPathParser parser = new SvgPathParser() {
@Override
protected float transformX(float x) {
return x * mWidth / VIEWPORT.x;
}
@Override
protected float transformY(float y) {
return y * mHeight / VIEWPORT.y;
}
};
mGlyphData = new GlyphData[LogoPaths.GLYPHS.length];
for (int i = 0; i < LogoPaths.GLYPHS.length; i++) {
mGlyphData[i] = new GlyphData();
try {
mGlyphData[i].path = parser.parsePath(LogoPaths.GLYPHS[i]);
} catch (ParseException e) {
mGlyphData[i].path = new Path();
Log.e(TAG, "Couldn't parse path", e);
}
PathMeasure pm = new PathMeasure(mGlyphData[i].path, true);
while (true) {
mGlyphData[i].length = Math.max(mGlyphData[i].length, pm.getLength());
if (!pm.nextContour()) {
break;
}
}
mGlyphData[i].paint = new Paint();
mGlyphData[i].paint.setStyle(Paint.Style.STROKE);
mGlyphData[i].paint.setAntiAlias(true);
mGlyphData[i].paint.setColor(Color.WHITE);
mGlyphData[i].paint.setStrokeWidth(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
}
}
use of android.graphics.PathMeasure in project Transitions-Everywhere by andkulikov.
the class PathAnimatorCompat method ofPointF.
public static <T> PathAnimatorCompat ofPointF(T target, PointFProperty<T> property, Path path) {
PathAnimatorCompat animator = null;
if (target != null && property != null && path != null) {
animator = new PathAnimatorCompat(target, property);
animator.mPathMeasure = new PathMeasure(path, false);
animator.mPathLength = animator.mPathMeasure.getLength();
}
return animator;
}
use of android.graphics.PathMeasure in project lottie-android by airbnb.
the class PathKeyframeAnimation method getValue.
@Override
public PointF getValue(Keyframe<PointF> keyframe, float keyframeProgress) {
PathKeyframe pathKeyframe = (PathKeyframe) keyframe;
Path path = pathKeyframe.getPath();
if (path == null) {
return keyframe.startValue;
}
if (pathMeasureKeyframe != pathKeyframe) {
pathMeasure = new PathMeasure(path, false);
pathMeasureKeyframe = pathKeyframe;
}
pathMeasure.getPosTan(keyframeProgress * pathMeasure.getLength(), pos, null);
point.set(pos[0], pos[1]);
return point;
}
use of android.graphics.PathMeasure in project FloatingView by UFreedom.
the class FloatingPath method create.
public static FloatingPath create(Path path, boolean forceClose) {
FloatingPath floatingPath = new FloatingPath(path);
floatingPath.mPathMeasure = new PathMeasure(path, forceClose);
return floatingPath;
}
use of android.graphics.PathMeasure in project MaterialCalendar by Haoxiqiang.
the class WeatherTemplateView method getPoints.
protected PathPoints[] getPoints(Path path, int size) {
//Size of 100 indicates that, 100 points
// would be extracted from the path
PathPoints[] pointArray = new PathPoints[size];
PathMeasure pm = new PathMeasure(path, false);
float length = pm.getLength();
float distance = 0f;
float speed = length / size;
int counter = 0;
float[] aCoordinates = new float[2];
while ((distance < length) && (counter < size)) {
pm.getPosTan(distance, aCoordinates, null);
pointArray[counter] = new PathPoints(aCoordinates[0], aCoordinates[1]);
counter++;
distance = distance + speed;
}
return pointArray;
}
Aggregations