0

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

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()。

我知道有一个路径方向类:但我不知道如何将它与 Arc 一起使用……知道如何更好地反转路径吗?

4

1 回答 1

1

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

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;
        }

    }
于 2020-05-06T17:12:32.387 回答