public Sprite(Texture texture) { Texture = texture; Color = Color.White; Position = Vector2.Zero; Scale = new Vector2(1.0f, 1.0f); Rotation = new Radian(0.0f); SourceRect = new Rectangle(0, 0, Texture.Width, Texture.Height); }
public void Rectangle_Constructor_Test() { var rect = new Rectangle(0, 1, 2, 3); Assert.AreEqual(0, rect.Left); Assert.AreEqual(1, rect.Top); Assert.AreEqual(2, rect.Width); Assert.AreEqual(3, rect.Height); Assert.AreEqual(new Vector2(0, 1), rect.Location); Assert.AreEqual(new Size(2, 3), rect.Size); Assert.AreEqual(rect.Left + rect.Width, rect.Right); Assert.AreEqual(rect.Top + rect.Height, rect.Bottom); }
public void Element_DefaultValues_Test() { var parent = new TestHelpers.RootElement(); var element = new ElementMock(parent, AssetManager) { Name = "ElementMock" }; Assert.AreEqual("ElementMock", element.Name); Assert.AreEqual(new Rectangle(0.0f, 0.0f, 1.0f, 1.0f), element.DestRect); var expectedAbsRect = new Rectangle(parent.AbsRect.Left + parent.AbsRect.Width * element.DestRect.Left, parent.AbsRect.Top + parent.AbsRect.Height * element.DestRect.Top, parent.AbsRect.Width * element.DestRect.Width, parent.AbsRect.Height * element.DestRect.Height); Assert.AreEqual(expectedAbsRect, element.AbsRect); Assert.IsTrue(element.IsLogical); }
public void Image_SomePropertiesChangeIfTextureChanged_Test() { var destRect = new Rectangle(0.1f, 0.2f, 0.4f, 0.5f); var sourceRect = new Rectangle(1, 2, 100, 100); var parent = new TestHelpers.RootElement(); var img = new Image(parent, AssetManager) { DestRect = destRect, SourceRect = sourceRect }; img.Texture = AssetManager.Load(@"Test\Default_color.dds") as Texture; Assert.AreEqual(destRect, img.DestRect); Assert.AreEqual(sourceRect, img.SourceRect); }
public void Rectangle_ToString_Test() { var rect = new Rectangle(1.0f, 2.2f, 3.33f, 4.444f); Assert.AreEqual("Rectangle(1, 2.2, 3.33, 4.444)", rect.ToString()); }
public void Rectangle_Parse_Test() { var expected = new Rectangle(1.0f, 2.2f, 3.33f, 4.444f); var actual = Rectangle.Parse(expected.ToString()); Assert.AreEqual(expected, actual); }
public void Element_ParentChangesPositionAndSize_Test() { var parent = new TestHelpers.RootElement(); var element = new ElementMock(parent, AssetManager) { Name = "ElementMock" }; parent.AbsRect = new Rectangle(10.0f, 20.0f, 110.0f, 120.0f); var expectedAbsRect = new Rectangle(parent.AbsRect.Left + parent.AbsRect.Width * element.DestRect.Left, parent.AbsRect.Top + parent.AbsRect.Height * element.DestRect.Top, parent.AbsRect.Width * element.DestRect.Width, parent.AbsRect.Height * element.DestRect.Height); Assert.AreEqual(expectedAbsRect, element.AbsRect); }