Search code examples
c#xna2dxna-4.0

Drawing image with an angle


Edit: the images below aren't supposed to have whitespace. I am just trying to show you that i am trying to create a rectangle from a 1x64 image, positioned as shown in the second picture

I know how to rotate an image like that in XNA

2

But how is it possible to draw a sprite in this angle this way ?

2

I can't seem to be able to find an answer on that and i'm sort on ideas


Solution

  • Matrix CreateSkewY(float angle)
    {
        Matrix skew = Matrix.Identity;
        skew.M21 = (float)Math.Tan((double)angle);
        return skew;
    }
    
    spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null,
    CreateSkewX((float)Math.PI / 6));