0

I am drawing a line in XNA by using a paint picture of one pixel, then fitting that pixel into a rectangle of height 100, with 2, so it appears as a line. This way I can later draw a rectangle.

I also want to rotate the rectangle but the rotation center is always it's upper left corner. How can I change this?

istepaniuk
  • 4,016
  • 2
  • 32
  • 60
OPMagicPotato
  • 215
  • 1
  • 2
  • 7
  • Do you mean to say that you're creating a new Texture2D that you're later drawing? I don't understand what "fitting that pixel into a rectangle" means. What does your current Draw() call look like? – itsme86 Jan 15 '13 at 18:27

2 Answers2

2

Use this overload of the Draw method. You'll probably want to set the origin parameter to a non-zero vector.

Theodoros Chatzigiannakis
  • 28,773
  • 8
  • 68
  • 104
0

Set the Origin parameter in the Draw() method.

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

)

Where:

origin

The sprite origin; the default is (0,0) which represents the upper-left corner.