fixed a bug in the circle torectangle method

This commit is contained in:
Dylan Wilson
2015-10-29 22:31:53 +10:00
parent a723dba69a
commit 9fd580ae96
2 changed files with 4 additions and 5 deletions
@@ -181,7 +181,9 @@ namespace MonoGame.Extended.Tests.Shapes
[Test]
public void Circle_ToRectangleTest()
{
Assert.AreEqual(new Rectangle(150, 250, 100, 100), new Circle(new Vector2(200.0f, 300.0f), 100.0f).ToRectangle());
var actual = new Circle(center: new Vector2(200, 300), radius: 100).ToRectangle();
var expected = new Rectangle(100, 200, 200, 200);
Assert.AreEqual(expected, actual);
}
}
}
+1 -4
View File
@@ -415,10 +415,7 @@ namespace MonoGame.Extended.Shapes
/// <returns><see cref="Rectangle"/> which contains this <see cref="Circle"/></returns>
public Rectangle ToRectangle()
{
return new Rectangle((int)(Center.X - (Radius / 2.0f)),
(int)(Center.Y - (Radius / 2.0f)),
(int)Radius,
(int)Radius);
return new Rectangle((int)(Center.X - Radius), (int)(Center.Y - Radius), (int)Radius * 2, (int)Radius * 2);
}
/*