我使用 canvas.DrawPath() 在我的 Canvas 上绘制了两个箭头。我正在使用 canvas.rotate() 进行旋转,但它显然将两个箭头旋转了相同的量。
我希望能够以一种方式旋转一个箭头,并以不同的方向旋转另一个箭头。
这可能吗?
最佳答案
当您使用 canvas.rotate()
时,您正在改变与 Canvas 关联的转换矩阵,因此您之后绘制的所有内容都会受到矩阵当前状态的影响,您必须执行以下操作:
canvas.save(); //Save current canvas matrix state
canvas.rotate(angle);
canvas.DrawPath(); //Draw first arrow
canvas.restore(); //Restore canvas matrix to saved state
canvas.DrawPath(); //Draw second arrow without the rotation
关于android - 在 Canvas 中旋转两个单独的对象(路径),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5086120/