2using System.Collections.Generic;
3using System.Globalization;
13 private float m_Width;
14 private float m_Height;
58 return new Vector2(m_XMin, m_YMin);
74 return new Vector2(
x + m_Width / 2f,
y + m_Height / 2f);
78 m_XMin = value.x - m_Width / 2f;
79 m_YMin = value.y - m_Height / 2f;
152 return new Vector2(m_Width, m_Height);
174 m_Width =
xMax - m_XMin;
191 m_Height =
yMax - m_YMin;
202 return m_Width + m_XMin;
206 m_Width = value - m_XMin;
217 return m_Height + m_YMin;
221 m_Height = value - m_YMin;
259 m_XMin = source.m_XMin;
260 m_YMin = source.m_YMin;
261 m_Width = source.m_Width;
262 m_Height = source.m_Height;
277 return new Rect(xmin, ymin, xmax - xmin, ymax - ymin);
347 private static Rect OrderMinMax(
Rect rect)
384 rect = OrderMinMax(rect);
385 other = OrderMinMax(other);
412 return !(lhs == rhs);
422 return x.GetHashCode() ^ (
width.GetHashCode() << 2) ^ (
y.GetHashCode() >> 2) ^ (
height.GetHashCode() >> 1);
425 public override bool Equals(
object other)
427 if (!(other is
Rect))
445 return String.Format(
"(x:{0:F2}, y:{1:F2}, width:{2:F2}, height:{3:F2})",
x,
y,
width,
height);
454 return String.Format(
"(x:{0}, y:{1}, width:{2}, height:{3})",
x.ToString(format, CultureInfo.InvariantCulture.NumberFormat),
y.ToString(format, CultureInfo.InvariantCulture.NumberFormat),
width.ToString(format, CultureInfo.InvariantCulture.NumberFormat),
height.ToString(format, CultureInfo.InvariantCulture.NumberFormat));
static float Lerp(float a, float b, float t)
static float InverseLerp(float a, float b, float value)
bool Overlaps(Rect other, bool allowInverse)
Rect(Vector2 position, Vector2 size)
bool Contains(Vector3 point)
bool Overlaps(Rect other)
bool Contains(Vector3 point, bool allowInverse)
static bool operator==(Rect lhs, Rect rhs)
static bool operator!=(Rect lhs, Rect rhs)
static Vector2 NormalizedToPoint(Rect rectangle, Vector2 normalizedRectCoordinates)
Rect(float x, float y, float width, float height)
override string ToString()
static Rect MinMaxRect(float xmin, float ymin, float xmax, float ymax)
override int GetHashCode()
override bool Equals(object other)
bool Contains(Vector2 point)
string ToString(string format)
void Set(float x, float y, float width, float height)
static Vector2 PointToNormalized(Rect rectangle, Vector2 point)