1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-12-25 01:39:23 +01:00

expose the viewport of a camera

This commit is contained in:
Ell 2021-03-09 02:29:06 +01:00
parent 0b39928334
commit b594c271ac

View file

@ -23,7 +23,6 @@ namespace MLEM.Cameras {
get => this.scale;
set => this.scale = MathHelper.Clamp(value, this.MinScale, this.MaxScale);
}
private float scale = 1;
/// <summary>
/// The minimum <see cref="Scale"/> that the camera can have
/// </summary>
@ -79,11 +78,15 @@ namespace MLEM.Cameras {
get => this.Position + this.ScaledViewport / 2;
set => this.Position = value - this.ScaledViewport / 2;
}
private Rectangle Viewport => this.graphicsDevice.Viewport.Bounds;
private Vector2 ScaledViewport => new Vector2(this.Viewport.Width, this.Viewport.Height) / this.ActualScale;
/// <summary>
/// The viewport of this camera, based on the game's <see cref="GraphicsDevice.Viewport"/> and this camera's <see cref="ActualScale"/>
/// </summary>
public Vector2 ScaledViewport => new Vector2(this.Viewport.Width, this.Viewport.Height) / this.ActualScale;
private Rectangle Viewport => this.graphicsDevice.Viewport.Bounds;
private readonly bool roundPosition;
private readonly GraphicsDevice graphicsDevice;
private float scale = 1;
/// <summary>
/// Creates a new camera.