blob: eb0491eeb5b72434a2f2cabc6acb271134be0118 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace MonoGame.Extended.ViewportAdapters
{
public abstract class ViewportAdapter : IDisposable
{
protected ViewportAdapter(GraphicsDevice graphicsDevice)
{
GraphicsDevice = graphicsDevice;
}
public virtual void Dispose()
{
}
public GraphicsDevice GraphicsDevice { get; }
public Viewport Viewport => GraphicsDevice.Viewport;
public abstract int VirtualWidth { get; }
public abstract int VirtualHeight { get; }
public abstract int ViewportWidth { get; }
public abstract int ViewportHeight { get; }
public Rectangle BoundingRectangle => new Rectangle(0, 0, VirtualWidth, VirtualHeight);
public Point Center => BoundingRectangle.Center;
public abstract Matrix GetScaleMatrix();
public Point PointToScreen(Point point)
{
return PointToScreen(point.X, point.Y);
}
public virtual Point PointToScreen(int x, int y)
{
var scaleMatrix = GetScaleMatrix();
var invertedMatrix = Matrix.Invert(scaleMatrix);
return Vector2.Transform(new Vector2(x, y), invertedMatrix).ToPoint();
}
public virtual void Reset()
{
}
}
}
|