PixelScreenSpace ClassDelta Engine Documentation
Converts to and from Pixel space. https://deltaengine.fogbugz.com/default.asp?W101 View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.ScreenSpaces ScreenSpace
    DeltaEngine.ScreenSpaces PixelScreenSpace

Namespace: DeltaEngine.ScreenSpaces
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class PixelScreenSpace : ScreenSpace

The PixelScreenSpace type exposes the following members.

Constructors

  NameDescription
Public methodPixelScreenSpace
Initializes a new instance of the PixelScreenSpace class
Top
Methods

  NameDescription
Public methodDispose (Inherited from ScreenSpace.)
Public methodFromPixelSpace(Rectangle) (Inherited from ScreenSpace.)
Public methodFromPixelSpace(Size) (Overrides ScreenSpace FromPixelSpace(Size).)
Public methodFromPixelSpace(Vector2D) (Overrides ScreenSpace FromPixelSpace(Vector2D).)
Public methodGetInnerPosition (Overrides ScreenSpace GetInnerPosition(Vector2D).)
Protected methodRaiseViewportSizeChanged (Inherited from ScreenSpace.)
Public methodToPixelSpace(Rectangle) (Inherited from ScreenSpace.)
Public methodToPixelSpace(Size) (Overrides ScreenSpace ToPixelSpace(Size).)
Public methodToPixelSpace(Vector2D) (Overrides ScreenSpace ToPixelSpace(Vector2D).)
Public methodToPixelSpaceRounded
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.)
Protected methodUpdate (Overrides ScreenSpace Update(Size).)
Top
Fields

  NameDescription
Protected fieldviewportPixelSize (Inherited from ScreenSpace.)
Top
Properties

  NameDescription
Public propertyAspectRatio (Inherited from ScreenSpace.)
Public propertyBottom (Overrides ScreenSpace Bottom.)
Public propertyBottomRight (Overrides ScreenSpace BottomRight.)
Public propertyLeft (Overrides ScreenSpace Left.)
Public propertyRight (Overrides ScreenSpace Right.)
Public propertyTop (Overrides ScreenSpace Top.)
Public propertyTopLeft (Overrides ScreenSpace TopLeft.)
Public propertyViewport (Inherited from ScreenSpace.)
Top
Events

  NameDescription
Public eventViewportSizeChanged (Inherited from ScreenSpace.)
Top
Remarks

Tests: DeltaEngine.Tests.ScreenSpaces.PixelScreenSpaceTests
Examples

7 unit tests call DeltaEngine.ScreenSpaces.PixelScreenSpace
[Test]
public void SquareWindowWithPixelSpace()
{
    var screen = new PixelScreenSpace(window);
    Assert.AreEqual(Vector2D.Zero, screen.TopLeft);
    Assert.AreEqual(window.ViewportPixelSize, (Size)screen.BottomRight);
    Assert.AreEqual(new Rectangle(Vector2D.Zero, window.TotalPixelSize), screen.Viewport);
    Assert.AreEqual(new Vector2D(100, 100), screen.FromPixelSpace(new Vector2D(100, 100)));
    Assert.AreEqual(new Rectangle(10, 10, 80, 80),
        screen.FromPixelSpace(new Rectangle(10, 10, 80, 80)));
    window.CloseAfterFrame();
}
[Test]
public void GetInnerPoint()
{
    ScreenSpace screen = new PixelScreenSpace(window);
    Assert.AreEqual(screen.TopLeft, screen.GetInnerPosition(Vector2D.Zero));
    Assert.AreEqual(screen.BottomRight, screen.GetInnerPosition(Vector2D.One));
    window.CloseAfterFrame();
}
[Test]
public void ToPixelSpaceAndFromPixelSpace()
{
    var pixelScreen = new PixelScreenSpace(window);
    Assert.AreEqual(pixelScreen.TopLeft, pixelScreen.ToPixelSpace(pixelScreen.TopLeft));
    Assert.AreEqual(pixelScreen.BottomRight, pixelScreen.ToPixelSpace(pixelScreen.BottomRight));
    Assert.AreEqual(Size.Zero, pixelScreen.ToPixelSpace(Size.Zero));
    Assert.AreEqual(Size.One, pixelScreen.ToPixelSpace(Size.One));
    window.CloseAfterFrame();
}
See Also