Example usage for android.graphics PathMeasure PathMeasure

List of usage examples for android.graphics PathMeasure PathMeasure

Introduction

In this page you can find the example usage for android.graphics PathMeasure PathMeasure.

Prototype

public PathMeasure() 

Source Link

Document

Create an empty PathMeasure object.

Usage

From source file:android.support.wear.widget.util.ArcSwipe.java

private float[][] interpolate(float[] start, float[] end, int steps, boolean isClockwise) {
    float startAngle = getAngle(start[0], start[1]);
    float endAngle = getAngle(end[0], end[1]);

    Path path = new Path();
    PathMeasure pathMeasure = new PathMeasure();
    path.moveTo(start[0], start[1]);//from   w  w w .j  a  v  a  2s  .  c om
    path.arcTo(mBounds, startAngle, getSweepAngle(startAngle, endAngle, isClockwise));
    pathMeasure.setPath(path, false);
    float pathLength = pathMeasure.getLength();

    float[][] res = new float[steps][2];
    float[] mPathTangent = new float[2];

    for (int i = 1; i < steps + 1; i++) {
        pathMeasure.getPosTan((pathLength * i) / (steps + 2f), res[i - 1], mPathTangent);
    }

    return res;
}