Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42448

Rotating an image in XNA

$
0
0
I may solve this before anybody gets a chance to reply, but the way things are going, I may not even get to look for an answer for some time.

The .Draw method for a SpriteBatch has overloads that allow you to set a rotation angle and a center of rotation for an image. That's niiice! However, I want to rotate the texture before applying it to the image.

The texture in question was intended to stretch nicely to a narrow, horizontal, rectangle of any width. Therefore, the image stetches in the X axis without any problem (it's effectively just four lines, so they can stetch to any length). I need to paint this texture into an equally narrow, but vertical, rectangle. This looks horrible, because the texture is just replicated and stetched such that the lines are wide and still horizontal. Therefore, I need to be able to rotate the texture prior to drawing onto the rectangle.

The brute-force option is to create a second texture which is the first texture rotated 90 degrees, then choose the texture I want to use based on the orientation. This is actually an acceptable solution, since I will have this problem with only two textures in the program, but I would expect that there would be a way to map a texture to a rectangle using a 90 degree rotation of the texture.

Viewing all articles
Browse latest Browse all 42448

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>