public void ToPixelWithPortraitWindow()
 {
     window.TotalPixelSize = new Size(75, 100);
     var screen = new QuadraticScreenSpace(window);
     Assert.AreEqual(new Point(75, 100), screen.ToPixelSpace(new Point(0.875f, 1f)));
     Assert.AreEqual(Point.Zero, screen.ToPixelSpace(new Point(0.125f, 0)));
     Assert.AreEqual(new Point(37.5f, 50), screen.ToPixelSpace(Point.Half));
     Assert.AreEqual(new Size(10, 20), screen.ToPixelSpace(new Size(0.1f, 0.2f)));
 }
        public void ToPixelWithSquareWindow()
        {
            window.ViewportPixelSize = new Size(100, 100);
            var screen = new QuadraticScreenSpace(window);

            Assert.AreEqual(new Vector2D(100, 100), screen.ToPixelSpace(Vector2D.One));
            Assert.AreEqual(Vector2D.Zero, screen.ToPixelSpace(Vector2D.Zero));
            Assert.AreEqual(new Vector2D(50, 50), screen.ToPixelSpace(Vector2D.Half));
        }
        public void ToPixelWithPortraitWindow()
        {
            window.ViewportPixelSize = new Size(75, 100);
            var screen = new QuadraticScreenSpace(window);

            Assert.AreEqual(new Vector2D(75, 100), screen.ToPixelSpace(new Vector2D(0.875f, 1f)));
            Assert.AreEqual(Vector2D.Zero, screen.ToPixelSpace(new Vector2D(0.125f, 0)));
            Assert.AreEqual(new Vector2D(37.5f, 50), screen.ToPixelSpace(Vector2D.Half));
            Assert.AreEqual(new Size(10, 20), screen.ToPixelSpace(new Size(0.1f, 0.2f)));
        }
 public void ToPixelWithNonSquareWindow()
 {
     window.TotalPixelSize = new Size(100, 75);
     var screen = new QuadraticScreenSpace(window);
     Assert.AreEqual(new Point(100, 75), screen.ToPixelSpace(new Point(1f, 0.875f)));
     Assert.AreEqual(Point.Zero, screen.ToPixelSpace(new Point(0, 0.125f)));
     Assert.AreEqual(new Point(50, 37.5f), screen.ToPixelSpace(Point.Half));
     Assert.AreEqual(new Size(10, 20), screen.ToPixelSpace(new Size(0.1f, 0.2f)));
     Assert.AreEqual(new Rectangle(20, 7.5f, 60, 60),
         screen.ToPixelSpace(new Rectangle(0.2f, 0.2f, 0.6f, 0.6f)));
 }
        public void ToPixelWithUnevenSizeFromQuadraticSpace()
        {
            window.ViewportPixelSize = new Size(99, 199);
            var screen = new QuadraticScreenSpace(window);

            Assert.AreEqual(new Vector2D(149, 199), screen.ToPixelSpace(Vector2D.One));
            Assert.AreEqual(new Vector2D(-50, 0), screen.ToPixelSpace(Vector2D.Zero));
            Assert.AreEqual(new Vector2D(49.5f, 99.5f), screen.ToPixelSpace(Vector2D.Half));
            Assert.AreEqual(new Vector2D(50, 100), screen.ToPixelSpaceRounded(Vector2D.Half));
            Assert.AreEqual(new Vector2D(199, 199),
                            screen.ToPixelSpaceRounded(Vector2D.One) - screen.ToPixelSpaceRounded(Vector2D.Zero));
        }
Esempio n. 6
0
        public void IfCameraNotAdjustedItBehavesIdenticallyToQuadraticScreenSpace()
        {
            var q = new QuadraticScreenSpace(window);
            var c = new Camera2DScreenSpace(window);

            Assert.IsTrue(
                c.FromPixelSpace(new Vector2D(1, 2)).IsNearlyEqual(q.FromPixelSpace(new Vector2D(1, 2))));
            Assert.IsTrue(
                c.FromPixelSpace(new Size(-3, 4)).IsNearlyEqual(q.FromPixelSpace(new Size(-3, 4))));
            Assert.IsTrue(
                c.ToPixelSpace(new Vector2D(2, 6)).IsNearlyEqual(q.ToPixelSpace(new Vector2D(2, 6))));
            Assert.IsTrue(c.ToPixelSpace(new Size(-2, 0)).IsNearlyEqual(q.ToPixelSpace(new Size(-2, 0))));
        }
        public void ToPixelWithNonSquareWindow()
        {
            window.ViewportPixelSize = new Size(100, 75);
            var screen = new QuadraticScreenSpace(window);

            Assert.AreEqual(new Vector2D(100, 75), screen.ToPixelSpace(new Vector2D(1f, 0.875f)));
            Assert.AreEqual(Vector2D.Zero, screen.ToPixelSpace(new Vector2D(0, 0.125f)));
            Assert.AreEqual(new Vector2D(50, 37.5f), screen.ToPixelSpace(Vector2D.Half));
            Assert.AreEqual(new Size(10, 20), screen.ToPixelSpace(new Size(0.1f, 0.2f)));
            Assert.IsTrue(
                screen.ToPixelSpace(new Rectangle(0.2f, 0.2f, 0.6f, 0.6f)).IsNearlyEqual(new Rectangle(20,
                                                                                                       7.5f, 60, 60)));
        }
 public void ToPixelWithSquareWindow()
 {
     window.TotalPixelSize = new Size(100, 100);
     var screen = new QuadraticScreenSpace(window);
     Assert.AreEqual(new Point(100, 100), screen.ToPixelSpace(Point.One));
     Assert.AreEqual(Point.Zero, screen.ToPixelSpace(Point.Zero));
     Assert.AreEqual(new Point(50, 50), screen.ToPixelSpace(Point.Half));
 }
        public void ToPixelInFullHdResolution()
        {
            window.ViewportPixelSize = new Size(1920, 1080);
            var screen = new QuadraticScreenSpace(window);

            Assert.AreEqual(new Vector2D(1680, 1500), screen.ToPixelSpace(new Vector2D(0.875f, 1f)));
            var somePoint        = screen.FromPixelSpace(new Vector2D(324, 483));
            var somePointPlusOne = screen.FromPixelSpace(new Vector2D(325, 483));

            Assert.IsFalse(somePoint.X.IsNearlyEqual(somePointPlusOne.X),
                           somePoint + " should not be nearly equal to " + somePointPlusOne);
            Assert.AreEqual(new Vector2D(324, 483), screen.ToPixelSpaceRounded(somePoint));
            Assert.AreEqual(new Vector2D(325, 483), screen.ToPixelSpaceRounded(somePointPlusOne));
        }
 public void ToPixelWithUnevenSizeFromQuadraticSpace()
 {
     window.TotalPixelSize = new Size(99, 199);
     var screen = new QuadraticScreenSpace(window);
     Assert.AreEqual(new Point(149, 199), screen.ToPixelSpace(Point.One));
     Assert.AreEqual(new Point(-50, 0), screen.ToPixelSpace(Point.Zero));
     Assert.AreEqual(new Point(49.5f, 99.5f), screen.ToPixelSpace(Point.Half));
     Assert.AreEqual(new Point(50, 100), screen.ToPixelSpaceRounded(Point.Half));
     Assert.AreEqual(new Point(199, 199),
         screen.ToPixelSpaceRounded(Point.One) - screen.ToPixelSpaceRounded(Point.Zero));
 }