00001 #region --- License ---
00002
00003
00004
00005 #endregion
00006
00007 using System;
00008 using System.Collections.Generic;
00009 using System.Text;
00010 using System.Runtime.InteropServices;
00011 namespace OpenTK
00012 {
00016 [StructLayout(LayoutKind.Sequential)]
00017 public struct Box2
00018 {
00022 public float Left;
00023
00027 public float Right;
00028
00032 public float Top;
00033
00037 public float Bottom;
00038
00044 public Box2(Vector2 topLeft, Vector2 bottomRight)
00045 {
00046 Left = topLeft.X;
00047 Top = topLeft.Y;
00048 Right = topLeft.X;
00049 Bottom = topLeft.Y;
00050 }
00051
00059 public Box2(float left, float top, float right, float bottom)
00060 {
00061 Left = left;
00062 Top = top;
00063 Right = right;
00064 Bottom = bottom;
00065 }
00066
00075 public static Box2 FromTLRB(float top, float left, float right, float bottom)
00076 {
00077 return new Box2(left, top, right, bottom);
00078 }
00079
00083 public float Width { get { return (float)System.Math.Abs(Right - Left); } }
00084
00088 public float Height { get { return (float)System.Math.Abs(Bottom - Top); } }
00089
00094 public override string ToString()
00095 {
00096 return String.Format("({0},{1})-({2},{3})", Left, Top, Right, Bottom);
00097 }
00098 }
00099 }