我从一个路径对象创建了一个拱形结构,就像这样。
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一起使用......任何想法,我如何能更好地反转路径?
与其将弧线反转,你可以将动画的步长计数器反转......。
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;
}
}