14 #include "../Math/cVecT.h"
21 template<
typename TYPE =
double >
64 return this->right - this->left;
70 return this->bottom - this->top;
75 return cVecT2<TYPE>((this->left + this->right) / 2, (this->top + this->bottom) / 2);
83 return(((
float)w) / ((
float)h));
96 return !IsEqual(
rect);
101 return this->left == 0 && this->right == 0 && this->top == 0 && this->bottom == 0;
106 return (this->right > this->left) && (this->bottom > this->top);
111 return (this->right >= this->left) && (this->bottom >= this->top);
137 this->right = nLeft + nWidth;
138 this->bottom = nTop + nHeight;
143 this->left = this->top = (
TYPE)INT_MAX;
144 this->right = this->bottom = (
TYPE)-INT_MAX;
150 this->right = nRight;
151 this->bottom = nBottom;
163 SetRectAsPt(pt.x, pt.y);
168 this->left = x - nRadius;
169 this->top = y - nRadius;
170 this->right = x + nRadius;
171 this->bottom = y + nRadius;
180 SetRectAsPt(adVals[0], adVals[1]);
184 SetRect4(adVals[0], adVals[1], adVals[2], adVals[3]);
215 if (this->left <= this->right)
237 if (this->top <= this->bottom)
247 if (y < this->bottom)
268 if (IsInRangeX(value))
271 TYPE d1 = value - this->left;
272 TYPE d2 = value - this->right;
285 if (IsInRangeY(value))
288 TYPE d1 = value - this->top;
289 TYPE d2 = value - this->bottom;
304 if (this->left == this->right)
309 if (this->top == this->bottom)
312 this->bottom += iMin;
318 this->left = (
TYPE)(this->left * mx);
319 this->right = (
TYPE)(this->right * mx);
323 this->top = (
TYPE)(this->top * my);
324 this->bottom = (
TYPE)(this->bottom * my);
326 void Scale(
float mx,
float my) noexcept
334 if (this->top != this->bottom)
336 TYPE diff = get_DiffY() / 10;
338 this->bottom += diff;
346 if (this->bottom < this->top)
350 if (this->right < this->left)
357 template<
typename TYPE >
402 return this->right - this->left;
407 return this->right - this->left;
413 return this->bottom - this->top;
418 return this->bottom - this->top;
423 TYPE nDistX = get_Width();
424 TYPE nDistY = get_Height();
431 return !this->isRectNormal();
439 this->OffsetRect(nLeft2 - this->left, nTop2 - this->top);
443 this->right = this->left + cx;
447 this->bottom = this->top + cy;
479 if (
rect.left < this->left)
480 this->left =
rect.left;
481 if (
rect.top < this->top)
482 this->top =
rect.top;
483 if (
rect.right > this->right)
484 this->right =
rect.right;
485 if (
rect.bottom > this->bottom)
486 this->bottom =
rect.bottom;
492 if (
rect.IsRectEmpty())
510 if (
rect.IsRectEmpty())
512 this->SetRectEmptyX();
515 if (
rect.left > this->left)
516 this->left =
rect.left;
517 if (
rect.top > this->top)
518 this->top =
rect.top;
519 if (
rect.right < this->right)
520 this->right =
rect.right;
521 if (
rect.bottom < this->bottom)
522 this->bottom =
rect.bottom;
523 return !IsRectEmpty();
535 if (this->bottom < 0)
538 if (this->right > cx)
540 if (this->bottom > cy)
545 this->NormalizeRect();
550 template <
typename TYPE =
float >
566 this->NormalizeRect();
569 :
cRectNT<
TYPE>(ptCenter.x - nSizeX, ptCenter.y - nSizeY, ptCenter.x + nSizeX, ptCenter.y + nSizeY)
571 this->NormalizeRect();
576 this->NormalizeRect();
582 return x >= this->left && x <= this->right;
587 return(y >= this->top && y <= this->bottom);
592 return IsInsideX(x) && IsInsideY(y);
600 return PtInRect(pt.x, pt.y);
608 if (
rect.left < this->left)
610 if (
rect.top < this->top)
612 if (
rect.right > this->right)
614 if (
rect.bottom > this->bottom)
623 if (
rect.left > this->right)
625 if (
rect.top > this->bottom)
627 if (
rect.right < this->left)
629 if (
rect.bottom < this->top)
639 bool bChange =
false;
641 if (pt.x < this->left)
646 if (pt.x > this->right)
652 if (pt.y < this->top)
657 if (pt.y > this->bottom)
666 void SnapToGrid(
TYPE fSizeXY)
670 this->left &= ~iSizeXY;
671 this->right = (right | iSizeXY) + 1;
672 this->top &= ~iSizeXY;
673 this->bottom = (bottom | iSizeXY) + 1;
688 if (y > this->bottom)
701 (
float)this->bottom);
705 void v_GetRect(
cVariant& vVal)
const;
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define _GT(x)
like _T(x) macro for static text.
Definition: StrConst.h:27
#define TYPE
Definition: StrT.cpp:38
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define _countof(a)
Definition: cKernel.h:35
cRectFT(TYPE nleft=0, TYPE ntop=0, TYPE nright=0, TYPE nbottom=0) noexcept
Definition: cRectT.h:563
bool IsInsideMe(const RECT_t &rect) const
Definition: cRectT.h:603
bool IsOverlapped(const RECT_t &rect) const
Definition: cRectT.h:618
cRectFT(const POINT_t &ptCenter, TYPE nSizeX=0, TYPE nSizeY=0) noexcept
Definition: cRectT.h:568
cRectFT(const SUPER_t &rect) noexcept
Definition: cRectT.h:573
bool PtInRect(TYPE x, TYPE y) const noexcept
Definition: cRectT.h:589
cString get_RectStr(void) const
Definition: cRectT.h:695
bool IsInsideX(TYPE x) const noexcept
Definition: cRectT.h:579
bool ClampPtInRect(OUT POINT_t &pt) const
Definition: cRectT.h:634
bool IsInsideY(TYPE y) const noexcept
Definition: cRectT.h:584
void UnionPoint(TYPE x, TYPE y)
Definition: cRectT.h:677
bool PtInRect(const POINT_t &pt) const noexcept
Definition: cRectT.h:594
void InflateRectBoth(TYPE dx, TYPE dy) noexcept
Definition: cRectT.h:467
void NormalizeRectClamp(TYPE cx=(TYPE) INT_MAX, TYPE cy=(TYPE) INT_MAX) noexcept
Definition: cRectT.h:543
cRectNT(TYPE x1, TYPE y1, TYPE x2, TYPE y2) noexcept
Definition: cRectT.h:372
TYPE get_Radius() const noexcept
Definition: cRectT.h:421
TYPE get_Width() const noexcept
Definition: cRectT.h:399
TYPE Height() const noexcept
Definition: cRectT.h:415
bool IntersectRect(const THIS_t &rect) noexcept
Definition: cRectT.h:502
TYPE get_X() const noexcept
Definition: cRectT.h:382
void UnionRectE(const THIS_t &rect) noexcept
Definition: cRectT.h:488
void SetWidth(TYPE cx) noexcept
Definition: cRectT.h:441
void UnionRect(const THIS_t &rect) noexcept
Definition: cRectT.h:475
void RectClamp(TYPE cx=(TYPE) INT_MAX, TYPE cy=(TYPE) INT_MAX) noexcept
Definition: cRectT.h:526
void SetHeight(TYPE cy) noexcept
Definition: cRectT.h:445
void InflateRectX(TYPE dx) noexcept
Definition: cRectT.h:457
TYPE X() const noexcept
Definition: cRectT.h:386
TYPE Width() const noexcept
Definition: cRectT.h:404
cRectNT(const SUPER_t &rect) noexcept
Definition: cRectT.h:376
TYPE Y() const noexcept
Definition: cRectT.h:394
TYPE get_Height() const noexcept
Definition: cRectT.h:410
bool IsRectEmpty() const noexcept
Definition: cRectT.h:428
void SetWH(TYPE nWidth=0, TYPE nHeight=0) noexcept
Definition: cRectT.h:449
cRectNT() noexcept
Definition: cRectT.h:369
void InflateRectY(TYPE dy) noexcept
Definition: cRectT.h:462
TYPE get_Y() const noexcept
Definition: cRectT.h:390
void SetLT(TYPE nLeft2, TYPE nTop2) noexcept
Definition: cRectT.h:436
void SetRectNotEmpty(TYPE iMin=10) noexcept
Definition: cRectT.h:301
void Union4(const THIS_t &rect) noexcept
Definition: cRectT.h:259
void SetRectNull() noexcept
Definition: cRectT.h:125
HRESULT SetRectAsStr(const char *pszStr)
Definition: cRectT.h:174
bool IsInRangeY(TYPE value) const noexcept
Definition: cRectT.h:118
void ScaleY(float my) noexcept
Definition: cRectT.h:321
void UnionX(TYPE x) noexcept
Definition: cRectT.h:209
cRectT(TYPE x1, TYPE y1, TYPE x2, TYPE y2) noexcept
Definition: cRectT.h:45
cVecT2< TYPE > get_Center() const noexcept
Definition: cRectT.h:73
bool isRectNull() const noexcept
Definition: cRectT.h:98
TYPE bottom
Definition: cRectT.h:35
void NormalizeRect() noexcept
Definition: cRectT.h:343
void OffsetRectY(TYPE dy) noexcept
Definition: cRectT.h:197
float get_AspectRatio() const noexcept
Definition: cRectT.h:77
TYPE DVALUE_t
Dimension value type.
Definition: cRectT.h:32
bool isRectNormal() const noexcept
Definition: cRectT.h:103
void SetRectAsPt(const POINT_t &pt) noexcept
Definition: cRectT.h:161
cRectT(const THIS_t &rect) noexcept
Definition: cRectT.h:52
void OffsetRect(TYPE dx, TYPE dy) noexcept
Definition: cRectT.h:202
void SetRectAsPt(TYPE x, TYPE y) noexcept
Definition: cRectT.h:153
void ScrollInRangeY(TYPE value)
Definition: cRectT.h:283
bool IsInRangeX(TYPE value) const noexcept
Definition: cRectT.h:113
void Union2(TYPE x, TYPE y) noexcept
Definition: cRectT.h:253
void SetRectEmptyX() noexcept
Definition: cRectT.h:140
void SetRectWH(TYPE nLeft, TYPE nTop, TYPE nWidth, TYPE nHeight) noexcept
Definition: cRectT.h:133
void SetRectFromSphere(TYPE x, TYPE y, TYPE nRadius) noexcept
Definition: cRectT.h:165
void UnionY(TYPE y) noexcept
Definition: cRectT.h:231
void ScaleX(float mx) noexcept
Definition: cRectT.h:316
void SetRect4(TYPE nLeft, TYPE nTop, TYPE nRight, TYPE nBottom) noexcept
Definition: cRectT.h:146
void Scale(float mx, float my) noexcept
Definition: cRectT.h:326
TYPE get_DiffX() const noexcept
Definition: cRectT.h:60
void OffsetRectX(TYPE dx) noexcept
Definition: cRectT.h:192
void ScrollInRangeX(TYPE value) noexcept
Definition: cRectT.h:266
void AddScaleY() noexcept
Definition: cRectT.h:331
bool IsEqual(const THIS_t &rect) const noexcept
Definition: cRectT.h:85
cRectT() noexcept
Definition: cRectT.h:38
bool isRectNormalE() const noexcept
Definition: cRectT.h:108
TYPE get_DiffY() const noexcept
Definition: cRectT.h:66
Definition: cVariant.h:26
static THIS_t _cdecl GetFormatf(const GChar_t *pszFormat,...)
Definition: cString.cpp:521
cRectFT< double > cRectd
Definition: cRectT.h:709
cRectFT< float > cRectf
Definition: cRectT.h:708
interface const RECTQ_t & rect
Definition: cQuadtree.h:44
class __DECL_IMPORT cVariant
Definition: cJSONWriter.h:19
int ITERATE_t
like size_t but signed
Definition: Index.h:28
bool operator!=(const cTimeDouble &dt1, const cTimeDouble &dt2)
Definition: cTimeDouble.h:254
bool operator==(const cTimeDouble &dt1, const cTimeDouble &dt2)
Definition: cTimeDouble.h:250
static TYPE Max(TYPE a, TYPE b) noexcept
Definition: Calc.h:98
static bool IsInBetween(TYPE n, TYPE a, TYPE b) noexcept
Definition: Calc.h:83
static TYPE Abs(TYPE a) noexcept
similar to ABS(n) macro. Does nothing for unsigned types.
static size_t __stdcall ToValArray(OUT _TYPE *pOut, size_t iQtyMax, const char *pszInp)
Definition: StrNum.h:135
static void Swap(TYPE &a, TYPE &b) noexcept
Definition: cValT.h:34