diff --git a/Source/OpenTK/Math/Box2.cs b/Source/OpenTK/Math/Box2.cs new file mode 100644 index 00000000..af6fc702 --- /dev/null +++ b/Source/OpenTK/Math/Box2.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; + +namespace OpenTK.Math +{ + /// + /// Defines a rectangle. + /// + [StructLayout(LayoutKind.Sequential)] + public struct Box2 + { + public Box2(Vector2 topLeft, Vector2 bottomRight) + { + Left = topLeft.X; + Top = topLeft.Y; + Right = topLeft.X; + Bottom = topLeft.Y; + } + public Box2(float left, float top, float right, float bottom) + { + Left = left; + Top = top; + Right = right; + Bottom = bottom; + } + public float Left, Right, Top, Bottom; + public float Width { get { return (float)System.Math.Abs(Right - Left); } } + public float Height { get { return (float)System.Math.Abs(Bottom - Top); } } + public static Box2 FromTLRB(float top, float left, float right, float bottom) + { + return new Box2(left, top, right, bottom); + } + } +}