summaryrefslogtreecommitdiff
path: root/Runtime/Math/Rect.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-17 23:05:01 +0800
committerchai <chaifix@163.com>2021-10-17 23:05:01 +0800
commit7c8c68d79343d04be382334c15a73d079450857c (patch)
tree9aaacc042f0b7eeb4123c07dcc5f49c14fd8026c /Runtime/Math/Rect.h
parent6e73ca6ada8a41692809dae5db89c8db0675ce1e (diff)
*misc
Diffstat (limited to 'Runtime/Math/Rect.h')
-rw-r--r--Runtime/Math/Rect.h38
1 files changed, 19 insertions, 19 deletions
diff --git a/Runtime/Math/Rect.h b/Runtime/Math/Rect.h
index 3b4f16c..dbd147c 100644
--- a/Runtime/Math/Rect.h
+++ b/Runtime/Math/Rect.h
@@ -3,7 +3,7 @@
#include "Vector2.h"
-/// A rectangle.
+// A rectangle.
template <typename T>
class RectT
{
@@ -11,21 +11,21 @@ public:
typedef RectT<T> RectType;
typedef float BaseType;
- T x; ///< Rectangle x coordinate.
- T y; ///< Rectangle y coordinate.
- T width; ///< Rectangle width.
- T height; ///< Rectangle height.
+ T x; //< Rectangle x coordinate.
+ T y; //< Rectangle y coordinate.
+ T width; //< Rectangle width.
+ T height; //< Rectangle height.
inline static const char* GetTypeString();
inline static bool IsAnimationChannel() { return false; }
inline static bool MightContainPPtr() { return false; }
- /// Create a empty rectangle.
+ // Create a empty rectangle.
RectT()
{
Reset();
}
- /// Create a new rectangle.
+ // Create a new rectangle.
RectT(T inX, T inY, T iWidth, T iHeight)
{
x = inX; width = iWidth;
@@ -43,7 +43,7 @@ public:
T GetXMax() const { return x + width; }
T GetYMax() const { return y + height; }
- /// Return true if rectangle is empty.
+ // Return true if rectangle is empty.
inline bool IsEmpty() const { return width <= 0 || height <= 0; }
inline void SetPosition(const Vector2f& position) { x = position.x; y = position.y; }
@@ -51,10 +51,10 @@ public:
inline void SetSize(const Vector2f& size) { width = size.x; height = size.y; }
inline Vector2f GetSize() const { return Vector2f(width, height); }
- /// Resets the rectangle
+ // Resets the rectangle
inline void Reset() { x = y = width = height = 0; }
- /// Sets the rectangle
+ // Sets the rectangle
inline void Set(T inX, T inY, T iWidth, T iHeight)
{
x = inX; width = iWidth;
@@ -63,11 +63,11 @@ public:
inline void Scale(T dx, T dy) { x *= dx; width *= dx; y *= dy; height *= dy; }
- /// Set Center position of rectangle (size stays the same)
+ // Set Center position of rectangle (size stays the same)
void SetCenterPos(T cx, T cy) { x = cx - width / 2; y = cy - height / 2; }
Vector2f GetCenterPos() const { return Vector2f(x + (BaseType)width / 2, y + (BaseType)height / 2); }
- /// Ensure this is inside the rect r.
+ // Ensure this is inside the rect r.
void Clamp(const RectType &r)
{
T x2 = x + width;
@@ -87,19 +87,19 @@ public:
if (height < 0) height = 0;
}
- /// Move rectangle by deltaX, deltaY.
+ // Move rectangle by deltaX, deltaY.
inline void Move(T dX, T dY) { x += dX; y += dY; }
- /// Return the width of rectangle.
+ // Return the width of rectangle.
inline T Width() const { return width; }
- /// Return the height of rectangle.
+ // Return the height of rectangle.
inline T Height() const { return height; }
- /// Return true if a point lies within rectangle bounds.
+ // Return true if a point lies within rectangle bounds.
inline bool Contains(T px, T py) const { return (px >= x) && (px < x + width) && (py >= y) && (py < y + height); }
inline bool Contains(const Vector2f& p) const { return Contains(p.x, p.y); }
- /// Return true if a relative point lies within rectangle bounds.
+ // Return true if a relative point lies within rectangle bounds.
inline bool ContainsRel(T x, T y) const
{
return (x >= 0) && (x < Width()) && (y >= 0) && (y < Height());
@@ -115,7 +115,7 @@ public:
return !disjoint;
}
- /// Normalize a rectangle such that xmin <= xmax and ymin <= ymax.
+ // Normalize a rectangle such that xmin <= xmax and ymin <= ymax.
inline void Normalize()
{
width = std::max<T>(width, 0);
@@ -138,7 +138,7 @@ inline bool CompareApproximately(const Rectf& lhs, const Rectf& rhs)
CompareApproximately(lhs.width, rhs.width) && CompareApproximately(lhs.height, rhs.height);
}
-/// Make a rect with width & height
+// Make a rect with width & height
template<typename T>
inline RectT<T> MinMaxRect(T minx, T miny, T maxx, T maxy) { return RectT<T>(minx, miny, maxx - minx, maxy - miny); }