Search in sources :

Example 21 with PathMeasure

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()));
    }
}
Also used : Path(android.graphics.Path) PathMeasure(android.graphics.PathMeasure) ParseException(java.text.ParseException) Paint(android.graphics.Paint) Paint(android.graphics.Paint)

Example 22 with PathMeasure

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;
}
Also used : PathMeasure(android.graphics.PathMeasure)

Example 23 with PathMeasure

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;
}
Also used : Path(android.graphics.Path) PathMeasure(android.graphics.PathMeasure)

Example 24 with PathMeasure

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;
}
Also used : PathMeasure(android.graphics.PathMeasure)

Example 25 with PathMeasure

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;
}
Also used : PathMeasure(android.graphics.PathMeasure) Paint(android.graphics.Paint)

Aggregations

PathMeasure (android.graphics.PathMeasure)33 Path (android.graphics.Path)11 Paint (android.graphics.Paint)7 RectF (android.graphics.RectF)4 Point (android.graphics.Point)3 ParseException (java.text.ParseException)3 Animator (android.animation.Animator)1 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 PropertyValuesHolder (android.animation.PropertyValuesHolder)1 ValueAnimator (android.animation.ValueAnimator)1 SuppressLint (android.annotation.SuppressLint)1 TargetApi (android.annotation.TargetApi)1 Matrix (android.graphics.Matrix)1 PointF (android.graphics.PointF)1 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)1 ConstrainedSvgPathParser (com.github.jorgecastillo.svg.ConstrainedSvgPathParser)1 SvgPathParser (com.github.jorgecastillo.svg.SvgPathParser)1