Search in sources :

Example 46 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)

Example 47 with PathMeasure

use of android.graphics.PathMeasure in project YhLibraryForAndroid by android-coco.

the class LineChartView method setAnim.

// 设置动画
private void setAnim(Canvas canvas) {
    PathMeasure measure = new PathMeasure(mPath, false);
    float pathLength = measure.getLength();
    PathEffect effect = new DashPathEffect(new float[] { pathLength, pathLength }, pathLength - pathLength * mProgress);
    mPaintLine.setPathEffect(effect);
    canvas.drawPath(mPath, mPaintLine);
}
Also used : PathMeasure(android.graphics.PathMeasure) DashPathEffect(android.graphics.DashPathEffect) PathEffect(android.graphics.PathEffect) DashPathEffect(android.graphics.DashPathEffect)

Aggregations

PathMeasure (android.graphics.PathMeasure)47 Path (android.graphics.Path)18 Paint (android.graphics.Paint)11 RectF (android.graphics.RectF)5 Point (android.graphics.Point)3 ParseException (java.text.ParseException)3 Animator (android.animation.Animator)2 AnimatorSet (android.animation.AnimatorSet)2 ObjectAnimator (android.animation.ObjectAnimator)2 PropertyValuesHolder (android.animation.PropertyValuesHolder)2 ValueAnimator (android.animation.ValueAnimator)2 SuppressLint (android.annotation.SuppressLint)2 TargetApi (android.annotation.TargetApi)2 Matrix (android.graphics.Matrix)2 PointF (android.graphics.PointF)2 Rect (android.graphics.Rect)2 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)2 DashPathEffect (android.graphics.DashPathEffect)1 PathEffect (android.graphics.PathEffect)1 Nullable (android.support.annotation.Nullable)1