tags:

views:

142

answers:

1

I have some objects which I draw onto a Canvas as part of a SurfaceView. I want to be able to rotate these programmatically, e.g. myParticle.setRotation(90); Here's my (simplified) code to draw the Particle at the moment:

public class Particle {

  public void draw(Canvas canvas){
    image.setBounds((int)(xPos), (int)(yPos), (int)(xPos+radius), (int)(yPos+radius));
    image.draw(canvas);
  }

}
+1  A: 

You just have to call canvas.rotate(90) :)

Romain Guy
And canvas.rotate(0) afterwards!
fredley
canvas.save() and canvas.restore() is more efficient.
methodin