如何反转 Path 对象?

How to reverse a Path object?

我从这样的路径对象创建了一个拱门:

path.addArc(rect, 0f, -180f) //and this draws my path CCW. 

//and if i wanted it drawn CW:
path.addArc(rect, -180f, 180f)//reverse

但我希望我不必这样做。我希望有这样的功能: path.reverse()。

我注意到有一个 path directions class:但我不知道如何将它与 Arc 一起使用....知道如何更好地反转路径吗?

您可以反转动画的计步器,而不是还原弧线...

pathMeasure = new PathMeasure(yourArcPath, false);

  Matrix mxTransform = new Matrix();
    float eachStepLen = pathMeasure.getLength() / 200; //200 animation steps
    if (currentStep <= 110 && !reverseActive) {

        currentStep ++; // --- Going forward...

        pathMeasure.getMatrix(
                eachStepLen * currentStep,
                mxTransform,
                PathMeasure.POSITION_MATRIX_FLAG);

        canvas.drawBitmap(image, mxTransform, null);


    } else {
        reverseActive = true;

        pathMeasure.getMatrix(
                eachStepLen * currentStep,
                mxTransform,
                PathMeasure.POSITION_MATRIX_FLAG);

        canvas.drawBitmap(image, mxTransform, null);

        currentStep --; // --- Going backwards...

        if (currentStep == 0){
            reverseActive = !reverseActive;
        }

    }