Added Box2 class.

This commit is contained in:
the_fiddler 2007-11-06 13:32:17 +00:00
parent 11404e3609
commit 020a31bc81

View file

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace OpenTK.Math
{
/// <summary>
/// Defines a rectangle.
/// </summary>
[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);
}
}
}