2019-02-01 17:19:20 +00:00
|
|
|
|
namespace RobloxFiles.DataTypes
|
2019-01-26 00:39:37 +00:00
|
|
|
|
{
|
2019-02-01 18:40:39 +00:00
|
|
|
|
public class Rect
|
2019-01-26 00:39:37 +00:00
|
|
|
|
{
|
|
|
|
|
public readonly Vector2 Min;
|
|
|
|
|
public readonly Vector2 Max;
|
|
|
|
|
|
|
|
|
|
public float Width => (Max - Min).X;
|
|
|
|
|
public float Height => (Max - Min).Y;
|
|
|
|
|
|
2019-11-01 02:40:31 +00:00
|
|
|
|
public override string ToString() => $"{Min}, {Max}";
|
|
|
|
|
|
2019-02-01 18:40:39 +00:00
|
|
|
|
public Rect(Vector2 min = null, Vector2 max = null)
|
2019-01-26 00:39:37 +00:00
|
|
|
|
{
|
2022-04-15 01:52:05 +00:00
|
|
|
|
Min = min ?? Vector2.zero;
|
|
|
|
|
Max = max ?? Vector2.zero;
|
2019-01-26 00:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Rect(float minX, float minY, float maxX, float maxY)
|
|
|
|
|
{
|
|
|
|
|
Min = new Vector2(minX, minY);
|
|
|
|
|
Max = new Vector2(maxX, maxY);
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-13 01:16:19 +00:00
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
int hash = Min.GetHashCode()
|
|
|
|
|
^ Max.GetHashCode();
|
|
|
|
|
|
|
|
|
|
return hash;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
2021-02-18 19:15:08 +00:00
|
|
|
|
if (!(obj is Rect other))
|
2020-09-13 01:16:19 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!Min.Equals(other.Min))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!Max.Equals(other.Max))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-01-26 00:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|