mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 20:15:31 +00:00
Added Box2 class.
This commit is contained in:
parent
11404e3609
commit
020a31bc81
36
Source/OpenTK/Math/Box2.cs
Normal file
36
Source/OpenTK/Math/Box2.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue