forked from AerysBat/XNALara
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBackgroundImage.cs
39 lines (33 loc) · 918 Bytes
/
BackgroundImage.cs
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
using Microsoft.Xna.Framework.Graphics;
namespace XNALara
{
public class BackgroundImage
{
private Texture2D texture;
private float scaleX;
private float scaleY;
public BackgroundImage(Texture2D texture) {
this.texture = texture;
}
public Texture2D Texture {
get { return texture; }
}
public float ScaleX {
get { return scaleX; }
}
public float ScaleY {
get { return scaleY; }
}
public void HandleWindowResized(int width, int height) {
float aspect = texture.Width / (float)texture.Height;
float w = width;
float h = w / aspect;
if (h > height) {
h = height;
w = height * aspect;
}
scaleX = w / width;
scaleY = h / height;
}
}
}