rotation functioning in rectangle renderer.
This commit is contained in:
@@ -75,22 +75,22 @@ namespace RecrownedAthenaeum.Render
|
||||
/// <param name="height">Height of rectangle.</param>
|
||||
/// <param name="color">Color of all vertices of this rectangle.</param>
|
||||
/// <param name="rotation">Rotation of rectangle. Default is 0 radians.</param>
|
||||
/// <param name="filled">If this rectangle should be filled.</param>
|
||||
public void Draw(int x, int y, int width, int height, Color color, float rotation = 0)
|
||||
{
|
||||
primitiveBatch.primitiveCount = filled ? 3 : 4;
|
||||
Vector2[] corners = new Vector2[4];
|
||||
corners[0] = new Vector2(x, y);
|
||||
corners[1] = new Vector2(x + width, y);
|
||||
corners[2] = new Vector2(x + width, y + height);
|
||||
corners[3] = new Vector2(x, y + height);
|
||||
corners[1] = new Vector2 (width, 0);
|
||||
corners[2] = new Vector2(width, height);
|
||||
corners[3] = new Vector2(0, height);
|
||||
|
||||
if (rotation != 0)
|
||||
{
|
||||
Matrix rotMat = Matrix.CreateRotationZ(rotation);
|
||||
for (int i = 0; i < corners.Length; i++)
|
||||
{
|
||||
Vector2.Transform(corners[i], rotMat);
|
||||
corners[i] = Vector2.Transform(corners[i], rotMat);
|
||||
corners[i].X += x;
|
||||
corners[i].Y += y;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user