forked from AtomicGameEngine/AtomicGameEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntRect.cs
More file actions
54 lines (40 loc) · 1.2 KB
/
IntRect.cs
File metadata and controls
54 lines (40 loc) · 1.2 KB
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
47
48
49
50
51
52
53
54
using System.Runtime.InteropServices;
namespace AtomicEngine
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct IntRect
{
public IntRect(int left, int top, int right, int bottom)
{
this.Left = left;
this.Top = top;
this.Right = right;
this.Bottom = bottom;
}
public int Width { get { return Right - Left; } }
public int Height { get { return Bottom - Top; } }
public void Inflate(int horizontalAmount, int verticalAmount)
{
Left -= horizontalAmount;
Right += horizontalAmount;
Top -= verticalAmount;
Bottom += verticalAmount;
}
public bool Contains(Vector2 vector)
{
int x = (int)vector.X;
int y = (int)vector.Y;
if (x < Left || y < Top || x >= Right || y >= Bottom)
return false;
return true;
}
/// Left coordinate.
public int Left;
/// Top coordinate.
public int Top;
/// Right coordinate.
public int Right;
/// Bottom coordinate.
public int Bottom;
}
}