Issue With Canvas.rotate() In Android .how Does It Exactly Work?
Please find the code of my onDraw method below(.I'm trying to rotate the canvas(//Rotate call -b) by 25 degrees after drawing the arc .But i find that the arc is still drawn from 0
Solution 1:
The Canvas
maintains a Matrix
that is responsible for all transformations on it. Even for rotation. As you can see in the documentation, the rotate
method says:
Preconcat the current matrix with the specified rotation.
All transformations are done on the Canvas
Matrix
,hence, on the Canvas
. The arc you draw isn't rotated. You first rotate the Canvas
and then draw on it.
Hence, in your code, call -a
works, not call -b
.
EDIT:
For issues like postrotate and prerotate check the Matrix class(postRotate
and preRotate
methods).
Post a Comment for "Issue With Canvas.rotate() In Android .how Does It Exactly Work?"