26 #ifndef SkRect_DEFINED 27 #define SkRect_DEFINED 41 void set(
float x,
float y) {
68 return Rect{0, 0, 0, 0};
71 #ifdef SK_SUPPORT_LEGACY_RECTMAKELARGEST 74 static Rect MakeLargest() {
75 return {SK_ScalarMin, SK_ScalarMin, SK_ScalarMax, SK_ScalarMax};
90 return Rect{0, 0, w, h};
105 r.
set(0, 0, (
float)(w), (
float)(h));
119 return Rect{l, t, r, b};
132 return Rect{x, y, x + w, y + h};
144 return !(fLeft < fRight && fTop < fBottom);
154 return fLeft <= fRight && fTop <= fBottom;
217 return fRight - fLeft;
226 return fBottom - fTop;
236 return 0.5f * (fLeft) + 0.5f * (fRight);
246 return 0.5f * (fTop) + 0.5f * (fBottom);
268 void set(
float left,
float top,
float right,
float bottom) {
284 void setLTRB(
float left,
float top,
float right,
float bottom) {
285 this->set(left, top, right, bottom);
298 void iset(
int left,
int top,
int right,
int bottom) {
299 fLeft = (float)(left);
301 fRight = (float)(right);
302 fBottom = (float)(bottom);
314 fRight = (float)(width);
315 fBottom = (float)(height);
326 void setXYWH(
float x,
float y,
float width,
float height) {
330 fBottom = y + height;
339 void setWH(
float width,
float height) {
358 return MakeLTRB(fLeft + dx, fTop + dy, fRight + dx, fBottom + dy);
373 return MakeLTRB(fLeft + dx, fTop + dy, fRight - dx, fBottom - dy);
388 return MakeLTRB(fLeft - dx, fTop - dy, fRight + dx, fBottom + dy);
415 fRight += newX - fLeft;
416 fBottom += newY - fTop;
449 this->inset(-dx, -dy);
460 bool intersect(
const Rect& r);
476 bool intersect(
float left,
float top,
float right,
float bottom);
487 bool intersect(
const Rect& a,
const Rect& b);
490 static bool Intersects(
float al,
float at,
float ar,
float ab,
float bl,
float bt,
float br,
float bb) {
491 float L = std::max(al, bl);
492 float R = std::min(ar, br);
493 float T = std::max(at, bt);
494 float B = std::min(ab, bb);
495 return L < R && T < B;
511 bool intersects(
float left,
float top,
float right,
float bottom)
const {
512 return Intersects(fLeft, fTop, fRight, fBottom, left, top, right, bottom);
549 void join(
float left,
float top,
float right,
float bottom);
574 if (fLeft >= fRight || fTop >= fBottom) {
577 this->joinPossiblyEmptyRect(r);
588 fLeft = std::min(fLeft, r.
left());
589 fTop = std::min(fTop, r.
top());
590 fRight = std::max(fRight, r.
right());
591 fBottom = std::max(fBottom, r.
bottom());
602 return x >= fLeft && x < fRight && y >= fTop && y < fBottom;
611 if (fLeft > fRight) {
615 if (fTop > fBottom) {
627 return MakeLTRB(std::min(fLeft, fRight), std::min(fTop, fBottom), std::max(fLeft, fRight),
628 std::max(fTop, fBottom));
Rect makeOutset(float dx, float dy) const
Definition: Rect.h:387
static constexpr Rect MakeXYWH(float x, float y, float w, float h)
Definition: Rect.h:131
bool contains(float x, float y) const
Definition: Rect.h:601
void join(const Rect &r)
Definition: Rect.h:558
float width() const
Definition: Rect.h:216
static constexpr Rect MakeWH(float w, float h)
Definition: Rect.h:89
float fTop
smaller y-axis bounds
Definition: Rect.h:56
float fBottom
larger y-axis bounds
Definition: Rect.h:58
#define MNN_ASSERT(x)
Definition: MNNDefine.h:41
static bool Intersects(const Rect &a, const Rect &b)
Definition: Rect.h:532
void isetWH(int width, int height)
Definition: Rect.h:312
float fRight
larger x-axis bounds
Definition: Rect.h:57
void offset(float dx, float dy)
Definition: Rect.h:401
float fLeft
smaller x-axis bounds
Definition: Rect.h:55
bool isSorted() const
Definition: Rect.h:153
void iset(int left, int top, int right, int bottom)
Definition: Rect.h:298
void set(float x, float y)
Definition: Rect.h:41
void joinNonEmptyArg(const Rect &r)
Definition: Rect.h:571
static Rect MakeIWH(int w, int h)
Definition: Rect.h:103
bool isEmpty() const
Definition: Rect.h:141
float y() const
Definition: Rect.h:171
float fY
Definition: Rect.h:39
void sort()
Definition: Rect.h:609
void inset(float dx, float dy)
Definition: Rect.h:431
void set(float left, float top, float right, float bottom)
Definition: Rect.h:268
void offsetTo(float newX, float newY)
Definition: Rect.h:414
float fX
Definition: Rect.h:38
Rect makeOffset(float dx, float dy) const
Definition: Rect.h:357
void joinPossiblyEmptyRect(const Rect &r)
Definition: Rect.h:587
void setWH(float width, float height)
Definition: Rect.h:339
float top() const
Definition: Rect.h:189
#define MNN_PUBLIC
Definition: MNNDefine.h:53
const float * asScalars() const
Definition: Rect.h:636
void outset(float dx, float dy)
Definition: Rect.h:448
static constexpr Rect MakeEmpty()
Definition: Rect.h:67
static constexpr Rect MakeLTRB(float l, float t, float r, float b)
Definition: Rect.h:118
Definition: AutoTime.hpp:16
void setEmpty()
Definition: Rect.h:255
float height() const
Definition: Rect.h:225
float bottom() const
Definition: Rect.h:207
float x() const
Definition: Rect.h:162
void setXYWH(float x, float y, float width, float height)
Definition: Rect.h:326
void setLTRB(float left, float top, float right, float bottom)
Definition: Rect.h:284
Rect makeSorted() const
Definition: Rect.h:626
bool intersects(const Rect &r) const
Definition: Rect.h:521
float right() const
Definition: Rect.h:198
bool intersects(float left, float top, float right, float bottom) const
Definition: Rect.h:511
float centerX() const
Definition: Rect.h:234
float centerY() const
Definition: Rect.h:244
Rect makeInset(float dx, float dy) const
Definition: Rect.h:372
float left() const
Definition: Rect.h:180