开发者

Rotating two seprate objects(paths) in Canvas

I have two arrows drawn on my canvas us开发者_JAVA百科ing the canvas.DrawPath(). I'm using canvas.rotate() to rotate, but it is obviously rotating both arrows by the same amount.

Id like to be able to rotate one arrow one way, and rotate the other arrow in a different direction.

Is this possible?


When you use canvas.rotate() you are altering the transformation matrix associated to the canvas, so all what you paint after that will be affected by the current state of the matrix, you have to do the following:

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜