Converts to and from quadratic space. https://deltaengine.net/Learn/ScreenSpace
View code on GitHub
Inheritance Hierarchy
DeltaEngine.ScreenSpaces ScreenSpace
DeltaEngine.ScreenSpaces QuadraticScreenSpace
DeltaEngine.Editor.UIEditor SceneScreenSpace
DeltaEngine.ScreenSpaces Camera2DScreenSpace
Namespace: DeltaEngine.ScreenSpaces
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The QuadraticScreenSpace type exposes the following members.
Constructors
Name | Description | |
---|---|---|
QuadraticScreenSpace | Initializes a new instance of the QuadraticScreenSpace class |
Methods
Name | Description | |
---|---|---|
Dispose | (Inherited from ScreenSpace.) | |
FromPixelSpace(Rectangle) | (Inherited from ScreenSpace.) | |
FromPixelSpace(Size) | (Overrides ScreenSpace FromPixelSpace(Size).) | |
FromPixelSpace(Vector2D) | (Overrides ScreenSpace FromPixelSpace(Vector2D).) | |
GetInnerPosition | (Overrides ScreenSpace GetInnerPosition(Vector2D).) | |
RaiseViewportSizeChanged | (Inherited from ScreenSpace.) | |
ToPixelSpace(Rectangle) | (Inherited from ScreenSpace.) | |
ToPixelSpace(Size) | (Overrides ScreenSpace ToPixelSpace(Size).) | |
ToPixelSpace(Vector2D) | (Overrides ScreenSpace ToPixelSpace(Vector2D).) | |
ToPixelSpaceRounded |
The rounded version of ToPixelSpace is used for lines, boxes and fonts where it matters to
actually render at exact pixel positions to get sharp lines, boxes or font rendering.
View code on GitHub (Inherited from ScreenSpace.) | |
Update | (Overrides ScreenSpace Update(Size).) |
Fields
Name | Description | |
---|---|---|
viewportPixelSize | (Inherited from ScreenSpace.) |
Properties
Name | Description | |
---|---|---|
AspectRatio | (Inherited from ScreenSpace.) | |
Bottom | (Overrides ScreenSpace Bottom.) | |
BottomRight | (Overrides ScreenSpace BottomRight.) | |
Left | (Overrides ScreenSpace Left.) | |
Right | (Overrides ScreenSpace Right.) | |
Top | (Overrides ScreenSpace Top.) | |
TopLeft | (Overrides ScreenSpace TopLeft.) | |
Viewport | (Inherited from ScreenSpace.) |
Events
Name | Description | |
---|---|---|
ViewportSizeChanged | (Inherited from ScreenSpace.) |
Remarks
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 ToQuadraticWithNonSquareWindow() { window.ViewportPixelSize = new Size(100, 75); var screen = new QuadraticScreenSpace(window); Assert.AreEqual(0, screen.Left); Assert.AreEqual(0.125f, screen.Top); Assert.AreEqual(1, screen.Right); Assert.AreEqual(0.875f, screen.Bottom); Assert.AreEqual(new Rectangle(0, 0.125f, 1, 0.75f), screen.Viewport); Assert.AreEqual(new Vector2D(1f, 0.875f), screen.FromPixelSpace(new Vector2D(100, 75))); Assert.AreEqual(Vector2D.Half, screen.FromPixelSpace(new Vector2D(50, 37.5f))); Assert.IsTrue(screen.FromPixelSpace(new Size(10, 10)).IsNearlyEqual(new Size(0.1f, 0.1f))); }
See Also