Namespace: DeltaEngine.ScreenSpaces
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Tests: DeltaEngine.Tests.ScreenSpaces.QuadraticScreenSpaceTests
3 unit tests call DeltaEngine.ScreenSpaces.QuadraticScreenSpace.TopLeft
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax
Property Value
Type: Vector2DRemarks
Examples
[Test] public void SquareWindowWithQuadraticSpace() { ScreenSpace.Current = new QuadraticScreenSpace(window); window.ViewportPixelSize = new Size(100, 100); Assert.AreEqual(Vector2D.Zero, ScreenSpace.Current.TopLeft); Assert.AreEqual(Vector2D.One, ScreenSpace.Current.BottomRight); Assert.AreEqual(Rectangle.One, ScreenSpace.Current.Viewport); Assert.AreEqual(Vector2D.One, ScreenSpace.Current.FromPixelSpace(new Vector2D(100, 100))); Assert.AreEqual(Vector2D.Half, ScreenSpace.Current.FromPixelSpace(new Vector2D(50, 50))); Assert.IsTrue( ScreenSpace.Current.FromPixelSpace(new Rectangle(10, 10, 80, 80)).IsNearlyEqual( new Rectangle(0.1f, 0.1f, 0.8f, 0.8f))); }
[Test] public void ToQuadraticWithUnevenSize() { window.ViewportPixelSize = new Size(99, 199); var screen = new QuadraticScreenSpace(window); Assert.AreEqual(new Vector2D(0.2512563f, 0), screen.TopLeft); Assert.AreEqual(new Vector2D(0.7487437f, 1), screen.BottomRight); Assert.AreEqual(screen.BottomRight, screen.FromPixelSpace(new Vector2D(99, 199))); }
[Test] public void ToQuadraticWithPortraitWindow() { window.ViewportPixelSize = new Size(75, 100); var screen = new QuadraticScreenSpace(window); Assert.AreEqual(new Vector2D(0.125f, 0), screen.TopLeft); Assert.AreEqual(new Vector2D(0.875f, 1), screen.BottomRight); Assert.AreEqual(new Rectangle(0.125f, 0, 0.75f, 1), screen.Viewport); Assert.AreEqual(new Vector2D(0.875f, 1f), screen.FromPixelSpace(new Vector2D(75, 100))); Assert.AreEqual(Vector2D.Half, screen.FromPixelSpace(new Vector2D(37.5f, 50))); Assert.IsTrue(screen.FromPixelSpace(new Size(10, 10)).IsNearlyEqual(new Size(0.1f, 0.1f))); }
See Also