Rotate a Texture2D with the Draw method in XNA?

I have a problem with rotating. I know that I can rotate a Texture2D object with the draw method.

My goal is to rotate a texture by 180°. For example, if I make a picture of a human with the camera where the head is at the bottom, I want to be able to rotate it so that the head is at the top again.

Here is the code or the rotation:

spriteBatch.Draw(Texture, Position, null, Color.White, MathHelper.Pi, new Vector2(), 1.0f, SpriteEffects.None, 0f);

The rotation works fine, but I have another problem:

If I add the texture to position 0,0 after rotating it, it's not visible anymore.

How do I rotate or maybe reflect the object, so that the red point will be at the top-left corner again?


public void Draw (
     Texture2D texture,
     Vector2 position,
     Nullable<Rectangle> sourceRectangle,
     Color color,
     float rotation,
     Vector2 origin,
     Vector2 scale,
     SpriteEffects effects,
     float layerDepth)

var origin = new Vector2()
    X = texture.Width / 2,
    Y = texture.Height/ 2

spriteBatch.Draw(texture, Vector2.Zero, null, Color.White, MathHelper.Pi, origin, 1f, SpriteEffects.None, 0f)`

Need Your Help

How to persist C objects in memory in a Ruby extension between calls?

c ruby memory indexing

I am developing a web app in Rails that needs to perform computationally intensive data lookup and processing when responding to a request.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.