Namespace: DeltaEngine.ScreenSpaces
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Tests: DeltaEngine.Tests.ScreenSpaces.Camera2DScreenSpaceTests
3 unit tests call DeltaEngine.ScreenSpaces.Camera2DScreenSpace.ToPixelSpace(DeltaEngine.Datatypes.Vector2D)
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax
Parameters
- quadraticPos
- Type: DeltaEngine.Datatypes Vector2D
Return Value
Type: Vector2DRemarks
Examples
[Test] 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)))); }
[Test] public void ToPixelSpace() { var quadraticSize = new Size(window.ViewportPixelSize.Width); var camera = new Camera2DScreenSpace(window) { LookAt = new Vector2D(-0.5f, 0.6f), Zoom = 2.0f }; Assert.AreEqual(quadraticSize.Width * 1.5f, camera.ToPixelSpace(Vector2D.Zero).X); Assert.IsTrue(camera.ToPixelSpace(Vector2D.Half).IsNearlyEqual(new Vector2D(800, 26))); Assert.IsTrue(camera.ToPixelSpace(Vector2D.One).IsNearlyEqual(new Vector2D(1120, 346))); Assert.AreEqual(quadraticSize, camera.ToPixelSpace(Size.Half)); }
[Test] public void ToPixelSpaceWithRotation() { var quadraticSize = new Size(window.ViewportPixelSize.Width); var camera = new Camera2DScreenSpace(window) { Rotation = 90.0f }; Assert.AreEqual(0.0f, camera.ToPixelSpace(Vector2D.Zero).X); Assert.IsTrue(camera.ToPixelSpace(Vector2D.Half).IsNearlyEqual(new Vector2D(-160.0f, 90.0f))); Assert.IsTrue( camera.ToPixelSpace(Vector2D.One).IsNearlyEqual(new Vector2D(-320.0f, (160.0f + 90.0f)))); Assert.AreEqual(quadraticSize, camera.ToPixelSpace(Size.One)); }
See Also