Esempio n. 1
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))));
        }
Esempio n. 2
0
        public void FromPixelSpace()
        {
            var camera = new Camera2DScreenSpace(window)
            {
                LookAt = new Vector2D(-0.5f, 0.6f),
                Zoom   = 2.0f
            };

            Assert.IsTrue(
                camera.FromPixelSpace(Vector2D.Zero).IsNearlyEqual(new Vector2D(-0.75f, 0.459375f)));
            Assert.IsTrue(
                camera.FromPixelSpace((Vector2D)window.ViewportPixelSize).IsNearlyEqual(new Vector2D(
                                                                                            -0.25f, 0.740625f)));
            Assert.AreEqual(camera.LookAt, camera.FromPixelSpace((Vector2D)window.ViewportPixelSize / 2));
        }
Esempio n. 3
0
        public void LoopingToAndFromPixelSpaceLeavesAPointUnchanged()
        {
            var camera = new Camera2DScreenSpace(window)
            {
                LookAt = new Vector2D(-0.5f, 0.6f),
                Zoom   = 3.0f
            };

            Assert.IsTrue(
                camera.ToPixelSpace(camera.FromPixelSpace(new Vector2D(1.2f, 3.4f))).IsNearlyEqual(
                    new Vector2D(1.2f, 3.4f)));
            Assert.IsTrue(
                camera.FromPixelSpace(camera.ToPixelSpace(new Vector2D(1.2f, 3.4f))).IsNearlyEqual(
                    new Vector2D(1.2f, 3.4f)));
        }