diff options
-rw-r--r-- | docs/SkIRect_Reference.bmh | 1314 | ||||
-rw-r--r-- | docs/SkPath_Reference.bmh | 3 | ||||
-rw-r--r-- | docs/SkRect_Reference.bmh | 1887 | ||||
-rw-r--r-- | docs/undocumented.bmh | 23 | ||||
-rw-r--r-- | site/user/api/SkIRect_Reference.md | 2197 | ||||
-rw-r--r-- | site/user/api/SkPath_Reference.md | 4 | ||||
-rw-r--r-- | site/user/api/SkRect_Reference.md | 2998 | ||||
-rw-r--r-- | site/user/api/undocumented.md | 49 | ||||
-rw-r--r-- | tools/bookmaker/spellCheck.cpp | 2 |
9 files changed, 7701 insertions, 776 deletions
diff --git a/docs/SkIRect_Reference.bmh b/docs/SkIRect_Reference.bmh index 06bcdf0905..0a9ddf8bf4 100644 --- a/docs/SkIRect_Reference.bmh +++ b/docs/SkIRect_Reference.bmh @@ -3,7 +3,11 @@ #Struct SkIRect -SkIRect holds four 32 bit integer coordinates for a rectangle +SkIRect holds four 32 bit integer coordinates describing the upper and +lower bounds of a rectangle. SkIRect may be created from outer bounds or +from position, width, and height. SkIRect describes an area; if its right +is less than or equal to its left, or if its bottom is less than or equal to +its top, it is considered empty. #Topic Overview @@ -21,8 +25,8 @@ SkIRect holds four 32 bit integer coordinates for a rectangle #Legend # description # function ## #Legend ## -# friend bool operator!=(const SkIRect& a, const SkIRect& b) # ## -# friend bool operator==(const SkIRect& a, const SkIRect& b) # ## +# friend bool operator!=(const SkIRect& a, const SkIRect& b) # Returns true if members are unequal. ## +# friend bool operator==(const SkIRect& a, const SkIRect& b) # Returns true if members are equal. ## #Table ## #Subtopic ## @@ -31,78 +35,104 @@ SkIRect holds four 32 bit integer coordinates for a rectangle #Legend # description # function ## #Legend ## -# EmptyIRect # ## -# Intersects # ## -# IntersectsNoEmptyCheck # ## -# MakeEmpty # ## -# MakeLTRB # ## -# MakeLargest # ## -# MakeSize # ## -# MakeWH # ## -# MakeXYWH # ## -# bottom # ## -# centerX # ## -# centerY # ## -# contains # ## -# containsNoEmptyCheck # ## -# height # ## -# inset # ## -# intersect # ## -# intersectNoEmptyCheck # ## -# is16Bit # ## -# isEmpty # ## -# isLargest # ## -# join # ## -# left # ## -# makeInset # ## -# makeOffset # ## -# makeOutset # ## -# makeSorted # ## -# offset # ## -# offsetTo # ## -# outset # ## -# quickReject # ## -# right # ## -# set # ## -# setEmpty # ## -# setLTRB # ## -# setLargest # ## -# setLargestInverted # ## -# setXYWH # ## -# size # ## -# sort # ## -# top # ## -# width # ## -# x # ## -# y # ## +# EmptyIRect # Returns immutable bounds of (0, 0, 0, 0). ## +# Intersects # Returns true if areas overlap. ## +# IntersectsNoEmptyCheck # Returns true if areas overlap. Skips empty check. ## +# MakeEmpty # Returns bounds of (0, 0, 0, 0). ## +# MakeLTRB # Constructs from int left, top, right, bottom. ## +# MakeLargest # Constructs from (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32). ## +# MakeSize # Constructs from ISize returning (0, 0, width, height). ## +# MakeWH # Constructs from int input returning (0, 0, width, height). ## +# MakeXYWH # Constructs from int input returning (x, y, width, height). ## +# bottom() # Returns larger bounds in y, if sorted. ## +# centerX # Returns midpoint in x. ## +# centerY # Returns midpoint in y. ## +# contains() # Returns true if points are equal or inside. ## +# containsNoEmptyCheck # Returns true if points are equal or inside. Skips empty check. ## +# height() # Returns span in y. ## +# inset() # Moves the sides symmetrically about the center. ## +# intersect # Sets to shared area; returns true if not empty. ## +# intersectNoEmptyCheck # Sets to shared area; returns true if not empty. Skips empty check. ## +# is16Bit # Returns true if members fit in 16-bit word. ## +# isEmpty # Returns true if width or height are zero or negative. ## +# isLargest # Returns true if equal to (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32). ## +# join() # Sets to union of bounds. ## +# left() # Returns smaller bounds in x, if sorted. ## +# makeInset # Constructs from sides moved symmetrically about the center. ## +# makeOffset # Constructs from translated sides. ## +# makeOutset # Constructs from sides moved symmetrically about the center. ## +# makeSorted # Constructs, ordering sides from smaller to larger. ## +# offset() # Translates sides without changing width and height. ## +# offsetTo # Translates to (x, y) without changing width and height. ## +# outset() # Moves the sides symmetrically about the center. ## +# quickReject # Returns true if rectangles do not intersect. ## +# right() # Returns larger bounds in x, if sorted. ## +# set() # Sets to (left, top, right, bottom). ## +# setEmpty # Sets to (0, 0, 0, 0). ## +# setLTRB # Sets to SkScalar input (left, top, right, bottom). ## +# setLargest # Sets to (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32). ## +# setLargestInverted # Sets to (SK_MaxS32, SK_MaxS32, SK_MinS32, SK_MinS32). ## +# setXYWH # Sets to (x, y, width, height). ## +# size() # Returns ISize (width, height). ## +# sort() # Orders sides from smaller to larger. ## +# top() # Returns smaller bounds in y, if sorted. ## +# width() # Returns span in x. ## +# x() # Returns bounds left. ## +# y() # Returns bounds top. ## #Table ## #Subtopic ## #Topic ## #Member int32_t fLeft +May contain any value. The smaller of the horizontal values when sorted. +When equal to or greater than fRight, IRect is empty. ## #Member int32_t fTop +May contain any value. The smaller of the horizontal values when sorted. +When equal to or greater than fBottom, IRect is empty. ## #Member int32_t fRight +May contain any value. The larger of the vertical values when sorted. +When equal to or less than fLeft, IRect is empty. ## #Member int32_t fBottom +May contain any value. The larger of the vertical values when sorted. +When equal to or less than fTop, IRect is empty. ## # ------------------------------------------------------------------------------ #Method static SkIRect SK_WARN_UNUSED_RESULT MakeEmpty() -#Return incomplete ## +Returns constructed IRect set to (0, 0, 0, 0). +Many other rectangles are empty; if left is equal to or greater than right, +or if top is equal to or greater than bottom. Setting all members to zero +is a convenience, but does not designate a special empty rectangle. + +#Return bounds (0, 0, 0, 0) ## #Example -// incomplete + SkIRect rect = SkIRect::MakeEmpty();
+ SkDebugf("MakeEmpty isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+ rect.offset(10, 10);
+ SkDebugf("offset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+ rect.inset(10, 10);
+ SkDebugf("inset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+ rect.outset(20, 20);
+ SkDebugf("outset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+#StdOut
+MakeEmpty isEmpty: true
+offset rect isEmpty: true
+inset rect isEmpty: true
+outset rect isEmpty: false
+##
## -#ToDo incomplete ## +#SeeAlso EmptyIRect isEmpty setEmpty setLargestInverted SkRect::MakeEmpty ## @@ -110,13 +140,27 @@ SkIRect holds four 32 bit integer coordinates for a rectangle #Method static SkIRect SK_WARN_UNUSED_RESULT MakeLargest() -#Return incomplete ## +Returns constructed IRect setting left and top to most negative value, and +setting right and bottom to most positive value. + +#Return bounds (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32) ## #Example -// incomplete + SkIRect rect = SkIRect::MakeLargest();
+ SkDebugf("MakeLargest isLargest: %s\n", rect.isLargest() ? "true" : "false");
+ SkDebugf("MakeLargest isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+ rect.outset(1, 1);
+ SkDebugf("outset isLargest: %s\n", rect.isLargest() ? "true" : "false");
+ SkDebugf("outset isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+#StdOut
+MakeLargest isLargest: true
+MakeLargest isEmpty: false
+outset isLargest: false
+outset isEmpty: true
+##
## -#ToDo incomplete ## +#SeeAlso isLargest setLargest SkRect::MakeLargest ## @@ -124,16 +168,27 @@ SkIRect holds four 32 bit integer coordinates for a rectangle #Method static SkIRect SK_WARN_UNUSED_RESULT MakeWH(int32_t w, int32_t h) -#Param w incomplete ## -#Param h incomplete ## +Returns constructed IRect set to (0, 0, w, h). Does not validate input; w or h +may be negative. + +#Param w width of constructed Rect ## +#Param h height of constructed Rect ## -#Return incomplete ## +#Return bounds (0, 0, w, h) ## #Example -// incomplete + SkIRect rect1 = SkIRect::MakeWH(25, 35);
+ SkIRect rect2 = SkIRect::MakeSize({25, 35});
+ SkIRect rect3 = SkIRect::MakeXYWH(0, 0, 25, 35);
+ SkIRect rect4 = SkIRect::MakeLTRB(0, 0, 25, 35);
+ SkDebugf("all %s" "equal\n", rect1 == rect2 && rect2 == rect3 && rect3 == rect4 ?
+ "" : "not ");
+#StdOut +all equal +## ## -#ToDo incomplete ## +#SeeAlso MakeSize MakeXYWH SkRect::MakeWH SkRect::MakeIWH ## @@ -141,15 +196,26 @@ SkIRect holds four 32 bit integer coordinates for a rectangle #Method static SkIRect SK_WARN_UNUSED_RESULT MakeSize(const SkISize& size) -#Param size incomplete ## +Returns constructed IRect set to (0, 0, size.width(), size.height()). +Does not validate input; size.width() or size.height() may be negative. + +#Param size values for Rect width and height ## -#Return incomplete ## +#Return bounds (0, 0, size.width(), size.height()) ## #Example -// incomplete + SkSize size = {25.5f, 35.5f};
+ SkIRect rect = SkIRect::MakeSize(size.toRound());
+ SkDebugf("round width: %d height: %d\n", rect.width(), rect.height());
+ rect = SkIRect::MakeSize(size.toFloor());
+ SkDebugf("floor width: %d height: %d\n", rect.width(), rect.height());
+#StdOut +round width: 26 height: 36
+floor width: 25 height: 35 +## ## -#ToDo incomplete ## +#SeeAlso MakeWH MakeXYWH SkRect::Make SkRect::MakeIWH ## @@ -157,18 +223,30 @@ SkIRect holds four 32 bit integer coordinates for a rectangle #Method static SkIRect SK_WARN_UNUSED_RESULT MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b) -#Param l incomplete ## -#Param t incomplete ## -#Param r incomplete ## -#Param b incomplete ## +Returns constructed IRect set to (l, t, r, b). Does not sort input; Rect may +result in fLeft greater than fRight, or fTop greater than fBottom. + +#Param l integer stored in fLeft ## +#Param t integer stored in fTop ## +#Param r integer stored in fRight ## +#Param b integer stored in fBottom ## -#Return incomplete ## +#Return bounds (l, t, r, b) ## #Example -// incomplete + SkIRect rect = SkIRect::MakeLTRB(5, 35, 15, 25);
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect.sort();
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut +rect: 5, 35, 15, 25 isEmpty: true
+rect: 5, 25, 15, 35 isEmpty: false +## ## -#ToDo incomplete ## +#SeeAlso MakeXYWH SkRect::MakeLTRB ## @@ -176,18 +254,34 @@ SkIRect holds four 32 bit integer coordinates for a rectangle #Method static SkIRect SK_WARN_UNUSED_RESULT MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h) -#Param x incomplete ## -#Param y incomplete ## -#Param w incomplete ## -#Param h incomplete ## +Returns constructed IRect set to +#Formula +(x, y, x + w, y + h) +## +. Does not validate input; +w or h may be negative. + +#Param x stored in fLeft ## +#Param y stored in fTop ## +#Param w added to x and stored in fRight ## +#Param h added to y and stored in fBottom ## -#Return incomplete ## +#Return bounds (x, y, x + w, y + h) ## #Example -// incomplete + SkIRect rect = SkIRect::MakeXYWH(5, 35, -15, 25);
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect.sort();
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut +rect: 5, 35, -10, 60 isEmpty: true
+rect: -10, 35, 5, 60 isEmpty: false +## ## -#ToDo incomplete ## +#SeeAlso MakeLTRB SkRect::MakeXYWH ## @@ -195,13 +289,23 @@ SkIRect holds four 32 bit integer coordinates for a rectangle #Method int left() const -#Return incomplete ## +Returns left edge of IRect, if sorted. +Call sort() to reverse fLeft and fRight if needed. + +#Return fLeft ## #Example -// incomplete + SkIRect unsorted = { 15, 5, 10, 25 };
+ SkDebugf("unsorted.fLeft: %d unsorted.left(): %d\n", unsorted.fLeft, unsorted.left());
+ SkIRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fLeft: %d sorted.left(): %d\n", sorted.fLeft, sorted.left());
+#StdOut +unsorted.fLeft: 15 unsorted.left(): 15
+sorted.fLeft: 10 sorted.left(): 10 +## ## -#ToDo incomplete ## +#SeeAlso fLeft x() SkRect::left() ## @@ -209,13 +313,23 @@ SkIRect holds four 32 bit integer coordinates for a rectangle #Method int top() const -#Return incomplete ## +Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid, +and sort() to reverse fTop and fBottom if needed. + +#Return fTop ## #Example -// incomplete + SkIRect unsorted = { 15, 25, 10, 5 };
+ SkDebugf("unsorted.fTop: %d unsorted.top(): %d\n", unsorted.fTop, unsorted.top());
+ SkIRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fTop: %d sorted.top(): %d\n", sorted.fTop, sorted.top()); +#StdOut +unsorted.fTop: 25 unsorted.top(): 25
+sorted.fTop: 5 sorted.top(): 5 +## ## -#ToDo incomplete ## +#SeeAlso fTop y() SkRect::top() ## @@ -223,13 +337,23 @@ SkIRect holds four 32 bit integer coordinates for a rectangle #Method int right() const -#Return incomplete ## +Returns right edge of IRect, if sorted. +Call sort() to reverse fLeft and fRight if needed. + +#Return fRight ## #Example -// incomplete + SkIRect unsorted = { 15, 25, 10, 5 };
+ SkDebugf("unsorted.fRight: %d unsorted.right(): %d\n", unsorted.fRight, unsorted.right());
+ SkIRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fRight: %d sorted.right(): %d\n", sorted.fRight, sorted.right());
+#StdOut +unsorted.fRight: 10 unsorted.right(): 10
+sorted.fRight: 15 sorted.right(): 15 +## ## -#ToDo incomplete ## +#SeeAlso fRight SkRect::right() ## @@ -237,13 +361,23 @@ SkIRect holds four 32 bit integer coordinates for a rectangle #Method int bottom() const -#Return incomplete ## +Returns bottom edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid, +and sort() to reverse fTop and fBottom if needed. + +#Return fBottom ## #Example -// incomplete + SkIRect unsorted = { 15, 25, 10, 5 };
+ SkDebugf("unsorted.fBottom: %d unsorted.bottom(): %d\n", unsorted.fBottom, unsorted.bottom());
+ SkIRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fBottom: %d sorted.bottom(): %d\n", sorted.fBottom, sorted.bottom());
+#StdOut +unsorted.fBottom: 5 unsorted.bottom(): 5
+sorted.fBottom: 25 sorted.bottom(): 25 +## ## -#ToDo incomplete ## +#SeeAlso fBottom SkRect::bottom() ## @@ -251,15 +385,23 @@ SkIRect holds four 32 bit integer coordinates for a rectangle #Method int x() const -return the left edge of the rectangle +Returns left edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid, +and sort() to reverse fLeft and fRight if needed. -#Return incomplete ## +#Return fLeft ## #Example -// incomplete + SkIRect unsorted = { 15, 5, 10, 25 };
+ SkDebugf("unsorted.fLeft: %d unsorted.x(): %d\n", unsorted.fLeft, unsorted.x());
+ SkIRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fLeft: %d sorted.x(): %d\n", sorted.fLeft, sorted.x());
+#StdOut +unsorted.fLeft: 15 unsorted.x(): 15
+sorted.fLeft: 10 sorted.x(): 10 +## ## -#ToDo incomplete ## +#SeeAlso fLeft left() y() SkRect::x() ## @@ -267,15 +409,23 @@ return the left edge of the rectangle #Method int y() const -return the top edge of the rectangle +Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid, +and sort() to reverse fTop and fBottom if needed. -#Return incomplete ## +#Return fTop ## #Example -// incomplete + SkIRect unsorted = { 15, 25, 10, 5 };
+ SkDebugf("unsorted.fTop: %d unsorted.y(): %d\n", unsorted.fTop, unsorted.y());
+ SkIRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fTop: %d sorted.y(): %d\n", sorted.fTop, sorted.y()); +#StdOut +unsorted.fTop: 25 unsorted.y(): 25
+sorted.fTop: 5 sorted.y(): 5 +## ## -#ToDo incomplete ## +#SeeAlso fTop top() x() SkRect::y() ## @@ -283,16 +433,23 @@ return the top edge of the rectangle #Method int width() const -Returns the rectangle width. This does not check for a valid rectangle -(i.e. left <= right) so the result may be negative. +Returns span on the x-axis. This does not check if IRect is sorted, or if +result fits in 32-bit signed integer; result may be negative. -#Return incomplete ## +#Return fRight minus fLeft ## #Example -// incomplete + SkIRect unsorted = { 15, 25, 10, 5 };
+ SkDebugf("unsorted width: %d\n", unsorted.width());
+ SkIRect large = { -2147483647, 1, 2147483644, 2 };
+ SkDebugf("large width: %d\n", large.width());
+#StdOut +unsorted width: -5
+large width: -5 +## ## -#ToDo incomplete ## +#SeeAlso height() SkRect::width() ## @@ -300,16 +457,23 @@ Returns the rectangle width. This does not check for a valid rectangle #Method int height() const -Returns the rectangle height. This does not check for a valid rectangle -(i.e. top <= bottom) so the result may be negative. +Returns span on the y-axis. This does not check if IRect is sorted, or if +result fits in 32-bit signed integer; result may be negative. -#Return incomplete ## +#Return fBottom minus fTop ## #Example -// incomplete + SkIRect unsorted = { 15, 25, 10, 20 };
+ SkDebugf("unsorted height: %d\n", unsorted.height());
+ SkIRect large = { 1, -2147483647, 2, 2147483644 };
+ SkDebugf("large height: %d\n", large.height());
+#StdOut +unsorted height: -5
+large height: -5 +## ## -#ToDo incomplete ## +#SeeAlso width() SkRect::height() ## @@ -317,13 +481,32 @@ Returns the rectangle height. This does not check for a valid rectangle #Method SkISize size() const -#Return incomplete ## +Returns spans on the x-axis and y-axis. This does not check if IRect is sorted, +or if result fits in 32-bit signed integer; result may be negative. + +#Return ISize (width, height) ## #Example -// incomplete + auto debugster = [](const char* prefix, const SkIRect& rect) -> void {
+ SkISize size = rect.size();
+ SkDebugf("%s ", prefix);
+ SkDebugf("rect: %d, %d, %d, %d ", rect.left(), rect.top(), rect.right(), rect.bottom());
+ SkDebugf("size: %d, %d\n", size.width(), size.height());
+ };
+ SkIRect rect = {20, 30, 40, 50};
+ debugster("original", rect);
+ rect.offset(20, 20);
+ debugster(" offset", rect);
+ rect.outset(20, 20);
+ debugster(" outset", rect); +#StdOut +original rect: 20, 30, 40, 50 size: 20, 20
+ offset rect: 40, 50, 60, 70 size: 20, 20
+ outset rect: 20, 30, 80, 90 size: 60, 60 +## ## -#ToDo incomplete ## +#SeeAlso height() width() MakeSize ## @@ -331,18 +514,30 @@ Returns the rectangle height. This does not check for a valid rectangle #Method int centerX() const -Since the center of an integer rectangle may fall on a factional value, this -method is defined to return (right + left) >> 1. -This is a specific "truncation" of the average, which is different than -(right + left) / 2 when the sum is negative. +Returns average of left edge and right edge. Result does not change if Rect +is sorted. Result may be incorrect if Rect is far from the origin. -#Return incomplete ## +Result is rounded down. + +#Return midpoint in x ## #Example -// incomplete +#Description +Dividing by two rounds towards zero. centerX uses a bit shift and rounds down. +## + SkIRect tests[] = {{20, 30, 41, 51}, {-20, -30, -41, -51}, {-10, -10, 11, 11}};
+ for (auto rect : tests) {
+ SkDebugf("left: %3d right: %3d centerX: %3d ", rect.left(), rect.right(), rect.centerX());
+ SkDebugf("div2: %3d\n", (rect.left() + rect.right()) / 2);
+ }
+#StdOut +left: 20 right: 41 centerX: 30 div2: 30
+left: -20 right: -41 centerX: -31 div2: -30
+left: -10 right: 11 centerX: 0 div2: 0 +## ## -#ToDo incomplete ## +#SeeAlso centerY SkRect::centerX ## @@ -350,18 +545,24 @@ This is a specific "truncation" of the average, which is different than #Method int centerY() const -Since the center of an integer rectangle may fall on a factional value, this -method is defined to return (bottom + top) >> 1. -This is a specific "truncation" of the average, which is different than -(bottom + top) / 2 when the sum is negative. +Returns average of top edge and bottom edge. Result does not change if Rect +is sorted. Result may be incorrect if Rect is far from the origin. -#Return incomplete ## +Result is rounded down. + +#Return midpoint in y ## #Example -// incomplete + SkIRect rect = { 0, 0, 2, 2 };
+ rect.offset(0x40000000, 0x40000000);
+ SkDebugf("left: %d right: %d centerX: %d ", rect.left(), rect.right(), rect.centerX());
+ SkDebugf("safe mid x: %d\n", rect.left() / 2 + rect.right() / 2); +#StdOut +left: 1073741824 right: 1073741826 centerX: -1073741823 safe mid x: 1073741825 +## ## -#ToDo incomplete ## +#SeeAlso centerX SkRect::centerY ## @@ -369,15 +570,30 @@ This is a specific "truncation" of the average, which is different than #Method bool isEmpty() const -Return true if the rectangle width or height are <= 0 +Returns true if fLeft is equal to or greater than fRight, or if fTop is equal +to or greater than fBottom. Call sort() to reverse rectangles with negative +width() or height(). -#Return incomplete ## +#Return true if width() or height() are zero or negative ## #Example -// incomplete + SkIRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}};
+ for (auto rect : tests) {
+ SkDebugf("rect: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "" : " not");
+ rect.sort();
+ SkDebugf("sorted: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "" : " not");
+ } +#StdOut
+rect: {20, 40, 10, 50} is empty
+sorted: {10, 40, 20, 50} is not empty
+rect: {20, 40, 20, 50} is empty
+sorted: {20, 40, 20, 50} is empty
+##
## -#ToDo incomplete ## +#SeeAlso EmptyIRect MakeEmpty sort SkRect::isEmpty ## @@ -385,13 +601,27 @@ Return true if the rectangle width or height are <= 0 #Method bool isLargest() const -#Return incomplete ## +Returns true if IRect encloses largest possible area. + +#Return true if equal to (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32) ## #Example -// incomplete +#Description +Note that the width is not negative, yet it cannot be represented as a 32-bit +signed integer. +## + SkIRect large = SkIRect::MakeLargest();
+ SkDebugf("large is largest: %s\n" ,large.isLargest() ? "true" : "false");
+ SkDebugf("large width %d\n", large.width());
+ SkDebugf("large is empty: %s\n", large.isEmpty() ? "true" : "false"); +#StdOut
+large is largest: true
+large width -2
+large is empty: false
+##
## -#ToDo incomplete ## +#SeeAlso MakeLargest SkRect::isLargest ## @@ -399,16 +629,24 @@ Return true if the rectangle width or height are <= 0 #Method friend bool operator==(const SkIRect& a, const SkIRect& b) -#Param a incomplete ## -#Param b incomplete ## +Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are +identical to corresponding members in b. + +#Param a IRect to compare ## +#Param b IRect to compare ## -#Return incomplete ## +#Return true if members are equal ## #Example -// incomplete + SkIRect test = {0, 0, 2, 2};
+ SkIRect sorted = test.makeSorted();
+ SkDebugf("test %c= sorted\n", test == sorted ? '=' : '!'); +#StdOut
+test == sorted
+##
## -#ToDo incomplete ## +#SeeAlso operator!=(const SkIRect& a, const SkIRect& b) ## @@ -416,16 +654,24 @@ Return true if the rectangle width or height are <= 0 #Method friend bool operator!=(const SkIRect& a, const SkIRect& b) -#Param a incomplete ## -#Param b incomplete ## +Returns true if any member in a: fLeft, fTop, fRight, and fBottom; is not +identical to the corresponding member in b. -#Return incomplete ## +#Param a IRect to compare ## +#Param b IRect to compare ## + +#Return true if members are not equal ## #Example -// incomplete + SkIRect test = {2, 2, 0, 0};
+ SkIRect sorted = test.makeSorted();
+ SkDebugf("test %c= sorted\n", test != sorted ? '!' : '=');
+#StdOut
+test != sorted
+##
## -#ToDo incomplete ## +#SeeAlso operator==(const SkIRect& a, const SkIRect& b) ## @@ -433,13 +679,24 @@ Return true if the rectangle width or height are <= 0 #Method bool is16Bit() const -#Return incomplete ## +Returns true if all members: fLeft, fTop, fRight, and fBottom; values are +equal to or larger than -32768 and equal to or smaller than 32767. + +#Return true if members fit in 16-bit word ## #Example -// incomplete + SkIRect tests[] = {{-32768, -32768, 32767, 32767}, {-32768, -32768, 32768, 32768}};
+ for (auto rect : tests) {
+ SkDebugf("{%d, %d, %d, %d} %s in 16 bits\n", rect.fLeft, rect.fTop, rect.fRight,
+ rect.fBottom, rect.is16Bit() ? "fits" : "does not fit");
+}
+#StdOut
+{-32768, -32768, 32767, 32767} fits in 16 bits
+{-32768, -32768, 32768, 32768} does not fit in 16 bits
+##
## -#ToDo incomplete ## +#SeeAlso SkTFitsIn ## @@ -447,13 +704,26 @@ Return true if the rectangle width or height are <= 0 #Method void setEmpty() -Set the rectangle to (0,0,0,0) +Sets IRect to (0, 0, 0, 0). + +Many other rectangles are empty; if left is equal to or greater than right, +or if top is equal to or greater than bottom. Setting all members to zero +is a convenience, but does not designate a special empty rectangle. #Example -// incomplete + SkIRect rect = {3, 4, 1, 2};
+ for (int i = 0; i < 2; ++i) {
+ SkDebugf("rect: {%d, %d, %d, %d} is %s" "empty\n", rect.fLeft, rect.fTop,
+ rect.fRight, rect.fBottom, rect.isEmpty() ? "" : "not ");
+ rect.setEmpty();
+ }
+#StdOut
+rect: {3, 4, 1, 2} is empty
+rect: {0, 0, 0, 0} is empty
+##
## -#ToDo incomplete ## +#SeeAlso MakeEmpty SkRect::setEmpty ## @@ -461,16 +731,28 @@ Set the rectangle to (0,0,0,0) #Method void set(int32_t left, int32_t top, int32_t right, int32_t bottom) -#Param left incomplete ## -#Param top incomplete ## -#Param right incomplete ## -#Param bottom incomplete ## +Sets IRect to (left, top, right, bottom). +left and right are not sorted; left is not necessarily less than right. +top and bottom are not sorted; top is not necessarily less than bottom. + +#Param left assigned to fLeft ## +#Param top assigned to fTop ## +#Param right assigned to fRight ## +#Param bottom assigned to fBottom ## #Example -// incomplete + SkIRect rect1 = {3, 4, 1, 2};
+ SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
+ SkIRect rect2;
+ rect2.set(3, 4, 1, 2);
+ SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
+#StdOut
+rect1: {3, 4, 1, 2}
+rect2: {3, 4, 1, 2}
+##
## -#ToDo incomplete ## +#SeeAlso setLTRB setXYWH SkRect::set ## @@ -478,18 +760,28 @@ Set the rectangle to (0,0,0,0) #Method void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom) -alias for set(l, t, r, b) +Sets IRect to (left, top, right, bottom). +left and right are not sorted; left is not necessarily less than right. +top and bottom are not sorted; top is not necessarily less than bottom. -#Param left incomplete ## -#Param top incomplete ## -#Param right incomplete ## -#Param bottom incomplete ## +#Param left stored in fLeft ## +#Param top stored in fTop ## +#Param right stored in fRight ## +#Param bottom stored in fBottom ## #Example -// incomplete + SkIRect rect1 = {3, 4, 1, 2};
+ SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
+ SkIRect rect2;
+ rect2.setLTRB(3, 4, 1, 2);
+ SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
+#StdOut
+rect1: {3, 4, 1, 2}
+rect2: {3, 4, 1, 2}
+##
## -#ToDo incomplete ## +#SeeAlso set setXYWH SkRect::setLTRB ## @@ -497,16 +789,33 @@ alias for set(l, t, r, b) #Method void setXYWH(int32_t x, int32_t y, int32_t width, int32_t height) -#Param x incomplete ## -#Param y incomplete ## -#Param width incomplete ## -#Param height incomplete ## +Sets IRect to +#Formula +(x, y, x + width, y + height) +## +. Does not validate input; +width or height may be negative. + +#Param x stored in fLeft ## +#Param y stored in fTop ## +#Param width added to x and stored in fRight ## +#Param height added to y and stored in fBottom ## #Example -// incomplete + SkIRect rect;
+ rect.setXYWH(5, 35, -15, 25);
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect.sort();
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut +rect: 5, 35, -10, 60 isEmpty: true
+rect: -10, 35, 5, 60 isEmpty: false +## ## -#ToDo incomplete ## +#SeeAlso MakeXYWH setLTRB set SkRect::setXYWH ## @@ -518,25 +827,39 @@ Sets rectangle left and top to most negative value, and sets right and bottom to most positive value. #Example -// incomplete + SkIRect rect;
+ rect.setLargest();
+ SkDebugf("MakeLargest isLargest: %s\n", rect.isLargest() ? "true" : "false");
+ SkDebugf("MakeLargest isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+ rect.outset(1, 1);
+ SkDebugf("outset isLargest: %s\n", rect.isLargest() ? "true" : "false");
+ SkDebugf("outset isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+#StdOut
+MakeLargest isLargest: true
+MakeLargest isEmpty: false
+outset isLargest: false
+outset isEmpty: true
+##
## -#ToDo incomplete ## +#SeeAlso MakeLargest isLargest setLargestInverted SK_MinS32 SK_MaxS32 ## # ------------------------------------------------------------------------------ #Method void setLargestInverted() +#ToDo move this to private +## Sets rectangle left and top to most positive value, and sets -right and bottom to most negative value. +right and bottom to most negative value. This is used internally to +flag that a condition is met, but otherwise has no special purpose. -#Example -// incomplete +#NoExample ## -#ToDo incomplete ## +#SeeAlso setEmpty setLargest ## @@ -544,18 +867,32 @@ right and bottom to most negative value. #Method SkIRect makeOffset(int32_t dx, int32_t dy) const -Return a new IRect, built as an offset of this rectangle. +Returns IRect offset by (dx, dy). + +If dx is negative, IRect returned is moved to the left. +If dx is positive, IRect returned is moved to the right. +If dy is negative, IRect returned is moved upward. +If dy is positive, IRect returned is moved downward. -#Param dx incomplete ## -#Param dy incomplete ## +#Param dx offset added to fLeft and fRight ## +#Param dy offset added to fTop and fBottom ## -#Return incomplete ## +#Return Rect offset in x or y, with original width and height ## #Example -// incomplete + SkIRect rect = { 10, 50, 20, 60 };
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect = rect.makeOffset(15, 32);
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut
+rect: 10, 50, 20, 60 isEmpty: false
+rect: 25, 82, 35, 92 isEmpty: false
+##
## -#ToDo incomplete ## +#SeeAlso offset() makeInset makeOutset SkRect::makeOffset ## @@ -563,18 +900,32 @@ Return a new IRect, built as an offset of this rectangle. #Method SkIRect makeInset(int32_t dx, int32_t dy) const -Return a new IRect, built as an inset of this rectangle. +Returns IRect, inset by (dx, dy). -#Param dx incomplete ## -#Param dy incomplete ## +If dx is negative, IRect returned is wider. +If dx is positive, IRect returned is narrower. +If dy is negative, IRect returned is taller. +If dy is positive, IRect returned is shorter. -#Return incomplete ## +#Param dx offset added to fLeft and subtracted from fRight ## +#Param dy offset added to fTop and subtracted from fBottom ## + +#Return Rect inset symmetrically left and right, top and bottom ## #Example -// incomplete + SkIRect rect = { 10, 50, 20, 60 };
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect = rect.makeInset(15, 32);
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut
+rect: 10, 50, 20, 60 isEmpty: false
+rect: 25, 82, 5, 28 isEmpty: true
+##
## -#ToDo incomplete ## +#SeeAlso inset() makeOffset makeOutset SkRect::makeInset ## @@ -582,18 +933,32 @@ Return a new IRect, built as an inset of this rectangle. #Method SkIRect makeOutset(int32_t dx, int32_t dy) const -Return a new Rect, built as an outset of this rectangle. +Returns IRect, outset by (dx, dy). + +If dx is negative, IRect returned is narrower. +If dx is positive, IRect returned is wider. +If dy is negative, IRect returned is shorter. +If dy is positive, IRect returned is taller. -#Param dx incomplete ## -#Param dy incomplete ## +#Param dx offset subtracted to fLeft and added from fRight ## +#Param dy offset subtracted to fTop and added from fBottom ## -#Return incomplete ## +#Return Rect outset symmetrically left and right, top and bottom ## #Example -// incomplete + SkIRect rect = { 10, 50, 20, 60 };
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect = rect.makeOutset(15, 32);
+ SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut
+rect: 10, 50, 20, 60 isEmpty: false
+rect: -5, 18, 35, 92 isEmpty: false
+##
## -#ToDo incomplete ## +#SeeAlso outset() makeOffset makeInset SkRect::makeOutset ## @@ -601,17 +966,26 @@ Return a new Rect, built as an outset of this rectangle. #Method void offset(int32_t dx, int32_t dy) -Offset set the rectangle by adding dx to its left and right, -and adding dy to its top and bottom. +Offsets IRect by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom. -#Param dx incomplete ## -#Param dy incomplete ## +If dx is negative, moves IRect returned to the left. +If dx is positive, moves IRect returned to the right. +If dy is negative, moves IRect returned upward. +If dy is positive, moves IRect returned downward. + +#Param dx offset added to fLeft and fRight ## +#Param dy offset added to fTop and fBottom ## #Example -// incomplete + SkIRect rect = { 10, 14, 50, 73 };
+ rect.offset(5, 13);
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 15, 27, 55, 86
+##
## -#ToDo incomplete ## +#SeeAlso offsetTo makeOffset SkRect::offset ## @@ -619,13 +993,26 @@ and adding dy to its top and bottom. #Method void offset(const SkIPoint& delta) -#Param delta incomplete ## +Offsets IRect by adding delta.fX to fLeft, fRight; and by adding delta.fY to +fTop, fBottom. + +If delta.fX is negative, moves IRect returned to the left. +If delta.fX is positive, moves IRect returned to the right. +If delta.fY is negative, moves IRect returned upward. +If delta.fY is positive, moves IRect returned downward. + +#Param delta offset added to IRect ## #Example -// incomplete + SkIRect rect = { 10, 14, 50, 73 };
+ rect.offset({5, 13});
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 15, 27, 55, 86
+##
## -#ToDo incomplete ## +#SeeAlso offsetTo makeOffset SkRect::offset ## @@ -633,16 +1020,22 @@ and adding dy to its top and bottom. #Method void offsetTo(int32_t newX, int32_t newY) -Offset this rectangle such its new x() and y() will equal newX and newY. +Offsets IRect so that fLeft equals newX, and fTop equals newY. width and height +are unchanged. -#Param newX incomplete ## -#Param newY incomplete ## +#Param newX stored in fLeft, preserving width() ## +#Param newY stored in fTop, preserving height() ## #Example -// incomplete + SkIRect rect = { 10, 14, 50, 73 };
+ rect.offsetTo(15, 27);
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 15, 27, 55, 86
+##
## -#ToDo incomplete ## +#SeeAlso offset makeOffset setXYWH SkRect::offsetTo ## @@ -650,18 +1043,26 @@ Offset this rectangle such its new x() and y() will equal newX and newY. #Method void inset(int32_t dx, int32_t dy) -Inset the rectangle by (dx,dy). If dx is positive, then the sides are moved inwards, -making the rectangle narrower. If dx is negative, then the sides are moved outwards, -making the rectangle wider. The same holds true for dy and the top and bottom. +Insets IRect by (dx,dy). -#Param dx incomplete ## -#Param dy incomplete ## +If dx is positive, makes IRect narrower. +If dx is negative, makes IRect wider. +If dy is positive, makes IRect shorter. +If dy is negative, makes IRect taller. + +#Param dx offset added to fLeft and subtracted from fRight ## +#Param dy offset added to fTop and subtracted from fBottom ## #Example -// incomplete + SkIRect rect = { 10, 14, 50, 73 };
+ rect.inset(5, 13);
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 15, 27, 45, 60
+##
## -#ToDo incomplete ## +#SeeAlso outset makeInset SkRect::inset ## @@ -669,19 +1070,26 @@ making the rectangle wider. The same holds true for dy and the top and bottom. #Method void outset(int32_t dx, int32_t dy) -Outset the rectangle by (dx,dy). If dx is positive, then the sides are -moved outwards, making the rectangle wider. If dx is negative, then the -sides are moved inwards, making the rectangle narrower. The same holds -true for dy and the top and bottom. +Outsets IRect by (dx, dy). + +If dx is positive, makes Rect wider. +If dx is negative, makes Rect narrower. +If dy is positive, makes Rect taller. +If dy is negative, makes Rect shorter. -#Param dx incomplete ## -#Param dy incomplete ## +#Param dx subtracted to fLeft and added from fRight ## +#Param dy subtracted to fTop and added from fBottom ## #Example -// incomplete + SkIRect rect = { 10, 14, 50, 73 };
+ rect.outset(5, 13);
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 5, 1, 55, 86
+##
## -#ToDo incomplete ## +#SeeAlso inset makeOutset SkRect::outset ## @@ -689,18 +1097,41 @@ true for dy and the top and bottom. #Method bool quickReject(int l, int t, int r, int b) const -#Param l incomplete ## -#Param t incomplete ## -#Param r incomplete ## -#Param b incomplete ## +Constructs IRect (l, t, r, b) and returns true if constructed IRect does not +intersect IRect. Does not check to see if construction or IRect is empty. -#Return incomplete ## +Is implemented with short circuit logic so that true can be returned after +a single compare. + +#Param l x minimum of constructed Rect ## +#Param t y minimum of constructed Rect ## +#Param r x maximum of constructed Rect ## +#Param b y maximum of constructed Rect ## + +#Return true if construction and IRect have no area in common ## #Example -// incomplete +#Description +quickReject is the complement of Intersects. +## + const SkIRect rect = {7, 11, 13, 17};
+ const int32_t* r = &rect.fLeft;
+ const SkIRect tests[] = { {13, 11, 15, 17}, { 7, 7, 13, 11 }, { 12, 16, 14, 18 } };
+ for (auto& test : tests) {
+ const int32_t* t = &test.fLeft;
+ SkDebugf("rect (%d, %d, %d, %d) test(%d, %d, %d, %d) quickReject %s; intersects %s\n",
+ r[0], r[1], r[2], r[3], t[0], t[1], t[2], t[3],
+ rect.quickReject(t[0], t[1], t[2], t[3]) ? "true" : "false",
+ SkIRect::Intersects(rect, test) ? "true" : "false");
+ }
+#StdOut
+rect (7, 11, 13, 17) test(13, 11, 15, 17) quickReject true; intersects false
+rect (7, 11, 13, 17) test(7, 7, 13, 11) quickReject true; intersects false
+rect (7, 11, 13, 17) test(12, 16, 14, 18) quickReject false; intersects true
+##
## -#ToDo incomplete ## +#SeeAlso Intersects ## @@ -708,21 +1139,37 @@ true for dy and the top and bottom. #Method bool contains(int32_t x, int32_t y) const -Returns true if (x,y) is inside the rectangle and the rectangle is not -empty. The left and top are considered to be inside, while the right -and bottom are not. Thus for the rectangle (0, 0, 5, 10), the -points (0,0) and (0,9) are inside, while (-1,0) and (5,9) are not. +Returns true if +#Formula +fLeft <= x < fRight && fTop <= y < fBottom +## +. +Returns false if Rect is empty. + +Considers input to describe constructed IRect (x, y, x + 1, y + 1) and +returns true if constructed area is completely enclosed by IRect area. -#Param x incomplete ## -#Param y incomplete ## +#Param x test Point x-coordinate ## +#Param y test Point y-coordinate ## -#Return incomplete ## +#Return true if (x, y) is inside IRect ## #Example -// incomplete + SkIRect rect = { 30, 50, 40, 60 };
+ SkIPoint pts[] = { { 30, 50}, { 40, 50}, { 30, 60} };
+ for (auto pt : pts) {
+ SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d)\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom(),
+ rect.contains(pt.x(), pt.y()) ? "contains" : "does not contain", pt.x(), pt.y());
+ }
+#StdOut
+rect: (30, 50, 40, 60) contains (30, 50)
+rect: (30, 50, 40, 60) does not contain (40, 50)
+rect: (30, 50, 40, 60) does not contain (30, 60)
+##
## -#ToDo incomplete ## +#SeeAlso containsNoEmptyCheck SkRect::contains ## @@ -730,21 +1177,38 @@ points (0,0) and (0,9) are inside, while (-1,0) and (5,9) are not. #Method bool contains(int32_t left, int32_t top, int32_t right, int32_t bottom) const -Returns true if the 4 specified sides of a rectangle are inside or equal to this rectangle. -If either rectangle is empty, contains() returns false. +Constructs Rect to intersect from (left, top, right, bottom). Does not sort +construction. -#Param left incomplete ## -#Param top incomplete ## -#Param right incomplete ## -#Param bottom incomplete ## +Returns true if Rect contains construction. +Returns false if Rect is empty or construction is empty. -#Return incomplete ## +#Param left x minimum of constructed Rect ## +#Param top y minimum of constructed Rect ## +#Param right x maximum of constructed Rect ## +#Param bottom y maximum of constructed Rect ## + +#Return true if all sides of IRect are outside construction ## #Example -// incomplete + SkIRect rect = { 30, 50, 40, 60 };
+ SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
+ for (auto contained : tests) {
+ bool success = rect.contains(
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom(),
+ success ? "contains" : "does not contain",
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ }
+#StdOut
+rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
+rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
+rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
+##
## -#ToDo incomplete ## +#SeeAlso containsNoEmptyCheck SkRect::contains ## @@ -752,17 +1216,32 @@ If either rectangle is empty, contains() returns false. #Method bool contains(const SkIRect& r) const -Returns true if the specified rectangle r is inside or equal to this rectangle. +Returns true if Rect contains r. +Returns false if Rect is empty or r is empty. + +Rect contains r when Rect area completely includes r area. -#Param r incomplete ## +#Param r IRect contained ## -#Return incomplete ## +#Return true if all sides of IRect are outside r ## #Example -// incomplete + SkIRect rect = { 30, 50, 40, 60 };
+ SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
+ for (auto contained : tests) {
+ SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom(),
+ rect.contains(contained) ? "contains" : "does not contain",
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ }
+#StdOut
+rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
+rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
+rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
+##
## -#ToDo incomplete ## +#SeeAlso containsNoEmptyCheck SkRect::contains ## @@ -770,17 +1249,32 @@ Returns true if the specified rectangle r is inside or equal to this rectangle. #Method bool contains(const SkRect& r) const -Returns true if the specified rectangle r is inside or equal to this rectangle. +Returns true if Rect contains r. +Returns false if Rect is empty or r is empty. + +Rect contains r when Rect area completely includes r area. -#Param r incomplete ## +#Param r Rect contained ## -#Return incomplete ## +#Return true if all sides of IRect are outside r ## #Example -// incomplete + SkIRect rect = { 30, 50, 40, 60 };
+ SkRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
+ for (auto contained : tests) {
+ SkDebugf("rect: (%d, %d, %d, %d) %s (%g, %g, %g, %g)\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom(),
+ rect.contains(contained) ? "contains" : "does not contain",
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ }
+#StdOut
+rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
+rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
+rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
+##
## -#ToDo incomplete ## +#SeeAlso containsNoEmptyCheck SkRect::contains ## @@ -789,24 +1283,40 @@ Returns true if the specified rectangle r is inside or equal to this rectangle. #Method bool containsNoEmptyCheck(int32_t left, int32_t top, int32_t right, int32_t bottom) const -Return true if this rectangle contains the specified rectangle. -For speed, this method does not check if either this or the specified -rectangles are empty, and if either is, its return value is undefined. -In the debugging build however, we assert that both this and the -specified rectangles are non-empty. +Constructs IRect from (left, top, right, bottom). Does not sort +construction. + +Returns true if Rect contains construction. +Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined. + +Return is undefined if Rect is empty or construction is empty. -#Param left incomplete ## -#Param top incomplete ## -#Param right incomplete ## -#Param bottom incomplete ## +#Param left x minimum of constructed Rect ## +#Param top y minimum of constructed Rect ## +#Param right x maximum of constructed Rect ## +#Param bottom y maximum of constructed Rect ## -#Return incomplete ## +#Return true if all sides of IRect are outside construction ## #Example -// incomplete + SkIRect rect = { 30, 50, 40, 60 };
+ SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
+ for (auto contained : tests) {
+ bool success = rect.containsNoEmptyCheck(
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom(),
+ success ? "contains" : "does not contain",
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ }
+#StdOut
+rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
+rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
+rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
+##
## -#ToDo incomplete ## +#SeeAlso contains SkRect::contains ## @@ -814,35 +1324,77 @@ specified rectangles are non-empty. #Method bool containsNoEmptyCheck(const SkIRect& r) const -#Param r incomplete ## +Returns true if Rect contains construction. +Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined. -#Return incomplete ## +Return is undefined if Rect is empty or construction is empty. + +#Param r Rect contained ## + +#Return true if all sides of IRect are outside r ## #Example -// incomplete + SkIRect rect = { 30, 50, 40, 60 };
+ SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
+ for (auto contained : tests) {
+ SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom(),
+ rect.containsNoEmptyCheck(contained) ? "contains" : "does not contain",
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ }
+#StdOut
+rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
+rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
+rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
+##
+## + +#SeeAlso contains SkRect::contains + ## -#ToDo incomplete ## +#Topic Intersection +IRects intersect when they enclose a common area. To intersect, each of the pair +must describe area; fLeft is less than fRight, and fTop is less than fBottom; +empty() returns false. The intersection of IRect a and IRect b can be described by: +#Formula +(max(a.fLeft, b.fLeft), max(a.fTop, b.fTop), + min(a.fRight, b.fRight), min(a.fBottom, b.fBottom)) ## +The intersection is only meaningful if the resulting IRect is not empty and +describes an area: fLeft is less than fRight, and fTop is less than fBottom. # ------------------------------------------------------------------------------ #Method bool intersect(const SkIRect& r) -If r intersects this rectangle, return true and set this rectangle to that -intersection, otherwise return false and do not change this rectangle. -If either rectangle is empty, do nothing and return false. +Returns true if IRect intersects r, and sets IRect to intersection. +Returns false if IRect does not intersect r, and leaves IRect unchanged. -#Param r incomplete ## +Returns false if either r or IRect is empty, leaving IRect unchanged. -#Return incomplete ## +#Param r limit of result ## + +#Return true if r and Rect have area in common ## #Example -// incomplete +#Description +Two SkDebugf calls are required. If the calls are combined, their arguments +may not be evaluated in left to right order: the printed intersection may +be before or after the call to intersect. +## + SkIRect leftRect = { 10, 40, 50, 80 };
+ SkIRect rightRect = { 30, 60, 70, 90 };
+ SkDebugf("%s intersection: ", leftRect.intersect(rightRect) ? "" : "no ");
+ SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
+ leftRect.right(), leftRect.bottom()); +#StdOut + intersection: 30, 60, 50, 80 +## ## -#ToDo incomplete ## +#SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect ## @@ -850,20 +1402,27 @@ If either rectangle is empty, do nothing and return false. #Method bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& a, const SkIRect& b) -If rectangles a and b intersect, return true and set this rectangle to -that intersection, otherwise return false and do not change this -rectangle. If either rectangle is empty, do nothing and return false. +Returns true if a intersects b, and sets IRect to intersection. +Returns false if a does not intersect b, and leaves IRect unchanged. + +Returns false if either a or b is empty, leaving IRect unchanged. -#Param a incomplete ## -#Param b incomplete ## +#Param a IRect to intersect ## +#Param b IRect to intersect ## -#Return incomplete ## +#Return true if a and b have area in common ## #Example -// incomplete + SkIRect result;
+ bool intersected = result.intersect({ 10, 40, 50, 80 }, { 30, 60, 70, 90 });
+ SkDebugf("%s intersection: %d, %d, %d, %d\n", intersected ? "" : "no ",
+ result.left(), result.top(), result.right(), result.bottom());
+#StdOut + intersection: 30, 60, 50, 80 +## ## -#ToDo incomplete ## +#SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect ## @@ -871,22 +1430,27 @@ rectangle. If either rectangle is empty, do nothing and return false. #Method bool SK_WARN_UNUSED_RESULT intersectNoEmptyCheck(const SkIRect& a, const SkIRect& b) -If rectangles a and b intersect, return true and set this rectangle to -that intersection, otherwise return false and do not change this -rectangle. For speed, no check to see if a or b are empty is performed. -If either is, then the return result is undefined. In the debug build, -we assert that both rectangles are non-empty. +Returns true if a intersects b, and sets IRect to intersection. +Returns false if a does not intersect b, and leaves IRect unchanged. -#Param a incomplete ## -#Param b incomplete ## +Asserts if either a or b is empty, and if SK_DEBUG is defined. -#Return incomplete ## +#Param a IRect to intersect ## +#Param b IRect to intersect ## + +#Return true if a and b have area in common ## #Example -// incomplete + SkIRect result;
+ bool intersected = result.intersectNoEmptyCheck({ 10, 40, 50, 80 }, { 30, 60, 70, 90 });
+ SkDebugf("intersection: %d, %d, %d, %d\n",
+ result.left(), result.top(), result.right(), result.bottom());
+#StdOut + intersection: 30, 60, 50, 80 +## ## -#ToDo incomplete ## +#SeeAlso Intersects intersect join SkRect::intersect ## @@ -894,23 +1458,37 @@ we assert that both rectangles are non-empty. #Method bool intersect(int32_t left, int32_t top, int32_t right, int32_t bottom) -If the rectangle specified by left,top,right,bottom intersects this rectangle, -return true and set this rectangle to that intersection, -otherwise return false and do not change this rectangle. -If either rectangle is empty, do nothing and return false. +Constructs IRect to intersect from (left, top, right, bottom). Does not sort +construction. + +Returns true if IRect intersects construction, and sets IRect to intersection. +Returns false if IRect does not intersect construction, and leaves IRect unchanged. -#Param left incomplete ## -#Param top incomplete ## -#Param right incomplete ## -#Param bottom incomplete ## +Returns false if either construction or IRect is empty, leaving IRect unchanged. -#Return incomplete ## +#Param left x minimum of constructed IRect ## +#Param top y minimum of constructed IRect ## +#Param right x maximum of constructed IRect ## +#Param bottom y maximum of constructed IRect ## + +#Return true if construction and IRect have area in common ## #Example -// incomplete +#Description +Two SkDebugf calls are required. If the calls are combined, their arguments +may not be evaluated in left to right order: the printed intersection may +be before or after the call to intersect. +## + SkIRect leftRect = { 10, 40, 50, 80 };
+ SkDebugf("%s intersection: ", leftRect.intersect(30, 60, 70, 90) ? "" : "no ");
+ SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
+ leftRect.right(), leftRect.bottom()); +#StdOut + intersection: 30, 60, 50, 80 +## ## -#ToDo incomplete ## +#SeeAlso intersectNoEmptyCheck Intersects join SkRect::intersect ## @@ -918,18 +1496,22 @@ If either rectangle is empty, do nothing and return false. #Method static bool Intersects(const SkIRect& a, const SkIRect& b) -Returns true if a and b are not empty, and they intersect +Returns true if a intersects b. +Returns false if either a or b is empty, or do not intersect. -#Param a incomplete ## -#Param b incomplete ## +#Param a IRect to intersect ## +#Param b IRect to intersect ## -#Return incomplete ## +#Return true if a and b have area in common ## #Example -// incomplete + SkDebugf("%s intersection", SkIRect::Intersects({10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
+#StdOut + intersection +## ## -#ToDo incomplete ## +#SeeAlso IntersectsNoEmptyCheck intersect SkRect::intersect ## @@ -937,39 +1519,55 @@ Returns true if a and b are not empty, and they intersect #Method static bool IntersectsNoEmptyCheck(const SkIRect& a, const SkIRect& b) -Returns true if a and b intersect. debug-asserts that neither are empty. +Returns true if a intersects b. +Asserts if either a or b is empty, and if SK_DEBUG is defined. -#Param a incomplete ## -#Param b incomplete ## +#Param a IRect to intersect ## +#Param b IRect to intersect ## -#Return incomplete ## +#Return true if a and b have area in common ## #Example -// incomplete + SkDebugf("%s intersection", SkIRect::IntersectsNoEmptyCheck(
+ {10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
+#StdOut + intersection +## ## -#ToDo incomplete ## +#SeeAlso Intersects intersect SkRect::intersect ## +#Topic Intersection ## + # ------------------------------------------------------------------------------ #Method void join(int32_t left, int32_t top, int32_t right, int32_t bottom) -Update this rectangle to enclose itself and the specified rectangle. -If this rectangle is empty, just set it to the specified rectangle. If the specified -rectangle is empty, do nothing. +Constructs Rect to intersect from (left, top, right, bottom). Does not sort +construction. + +Sets Rect to the union of itself and the construction. + +Has no effect if construction is empty. Otherwise, if Rect is empty, sets +Rect to construction. -#Param left incomplete ## -#Param top incomplete ## -#Param right incomplete ## -#Param bottom incomplete ## +#Param left x minimum of constructed Rect ## +#Param top y minimum of constructed Rect ## +#Param right x maximum of constructed Rect ## +#Param bottom y maximum of constructed Rect ## #Example -// incomplete + SkIRect rect = { 10, 20, 15, 25};
+ rect.join(50, 60, 55, 65);
+ SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut + join: 10, 20, 55, 65 +## ## -#ToDo incomplete ## +#SeeAlso set SkRect::join ## @@ -977,17 +1575,22 @@ rectangle is empty, do nothing. #Method void join(const SkIRect& r) -Update this rectangle to enclose itself and the specified rectangle. -If this rectangle is empty, just set it to the specified rectangle. If the specified -rectangle is empty, do nothing. +Sets Rect to the union of itself and r. -#Param r incomplete ## +Has no effect if r is empty. Otherwise, if Rect is empty, sets Rect to r. + +#Param r expansion Rect ## #Example -// incomplete + SkIRect rect = { 10, 20, 15, 25};
+ rect.join({50, 60, 55, 65});
+ SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut + join: 10, 20, 55, 65 +## ## -#ToDo incomplete ## +#SeeAlso set SkRect::join ## @@ -995,16 +1598,22 @@ rectangle is empty, do nothing. #Method void sort() -Swap top/bottom or left/right if there are flipped. -This can be called if the edges are computed separately, -and may have crossed over each other. -When this returns, left <= right && top <= bottom +Swaps fLeft and fRight if fLeft is greater than fRight; and swaps +fTop and fBottom if fTop is greater than fBottom. Result may be empty, +and width() and height() will be zero or positive. #Example -// incomplete + SkIRect rect = { 30, 50, 20, 10 };
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+ rect.sort();
+ SkDebugf("sorted: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut +rect: 30, 50, 20, 10
+sorted: 20, 10, 30, 50 +## ## -#ToDo incomplete ## +#SeeAlso makeSorted SkRect::sort ## @@ -1012,15 +1621,24 @@ When this returns, left <= right && top <= bottom #Method SkIRect makeSorted() const -Return a new Rect that is the sorted version of this rectangle (left <= right, top <= bottom). +Returns Rect with fLeft and fRight swapped if fLeft is greater than fRight; and +with fTop and fBottom swapped if fTop is greater than fBottom. Result may be empty; +and width() and height() will be zero or positive. -#Return incomplete ## +#Return sorted IRect ## #Example -// incomplete + SkIRect rect = { 30, 50, 20, 10 };
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+ SkIRect sort = rect.makeSorted();
+ SkDebugf("sorted: %d, %d, %d, %d\n", sort.fLeft, sort.fTop, sort.fRight, sort.fBottom);
+#StdOut +rect: 30, 50, 20, 10
+sorted: 20, 10, 30, 50 +## ## -#ToDo incomplete ## +#SeeAlso sort SkRect::makeSorted ## @@ -1028,13 +1646,19 @@ Return a new Rect that is the sorted version of this rectangle (left <= right, t #Method static const SkIRect& SK_WARN_UNUSED_RESULT EmptyIRect() -#Return incomplete ## +Returns a reference to immutable empty IRect, set to (0, 0, 0, 0). + +#Return global IRect set to all zeroes ## #Example -// incomplete + const SkIRect& rect = SkIRect::EmptyIRect();
+ SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut +rect: 0, 0, 0, 0 +## ## -#ToDo incomplete ## +#SeeAlso MakeEmpty ## diff --git a/docs/SkPath_Reference.bmh b/docs/SkPath_Reference.bmh index c34a21298b..8eb00777b7 100644 --- a/docs/SkPath_Reference.bmh +++ b/docs/SkPath_Reference.bmh @@ -5042,7 +5042,7 @@ for (int y = 2; y < 256; y += 9) { Writes text representation of Path to stream. If stream is nullptr, dump() writes to standard output. Set forceClose to true to get -edges used to fill Path. Set dumpAsHex true to get exact binary representations +edges used to fill Path. Set dumpAsHex true to generate exact binary representations of floating point numbers used in Point_Array and Conic_Weights. #Param stream writable Stream receiving Path text representation; may be nullptr ## @@ -5126,7 +5126,6 @@ original Path. Use instead of dump() when submitting #A bug reports against Skia # http://bug.skia.org ## . -Slight value changes in Point_Array may cause the bug to disappear. #Example SkPath path, copy; diff --git a/docs/SkRect_Reference.bmh b/docs/SkRect_Reference.bmh index 33d9e54591..57f3ec6b98 100644 --- a/docs/SkRect_Reference.bmh +++ b/docs/SkRect_Reference.bmh @@ -4,6 +4,16 @@ #Struct SkRect +SkRect holds four SkScalar coordinates describing the upper and +lower bounds of a rectangle. SkRect may be created from outer bounds or +from position, width, and height. SkRect describes an area; if its right +is less than or equal to its left, or if its bottom is less than or equal to +its top, it is considered empty. + +# move to topic about MakeIWH and friends +SkRect can be constructed from int values to avoid compiler warnings that +integer input cannot convert to SkScalar without loss of precision. + #Topic Overview #Subtopic Subtopics @@ -20,87 +30,128 @@ #Legend # description # function ## #Legend ## -# friend bool operator!=(const SkRect& a, const SkRect& b) # ## -# friend bool operator==(const SkRect& a, const SkRect& b) # ## +# friend bool operator!=(const SkRect& a, const SkRect& b) # Returns true if member bits are unequal. ## +# friend bool operator==(const SkRect& a, const SkRect& b) # Returns true if member bits are equal. ## #Table ## #Subtopic ## #Subtopic Member_Functions #Table #Legend -# description # function ## +# description # function ## #Legend ## -# Make # ## -# MakeEmpty # ## -# MakeFromIRect # ## -# MakeIWH # ## -# MakeLTRB # ## -# MakeLargest # ## -# MakeSize # ## -# MakeWH # ## -# MakeXYWH # ## -# bottom # ## -# centerX # ## -# centerY # ## -# height # ## -# inset # ## -# intersect # ## -# isEmpty # ## -# isFinite # ## -# isLargest # ## -# isSorted # ## -# iset # ## -# isetWH # ## -# left # ## -# makeInset # ## -# makeOffset # ## -# makeOutset # ## -# offset # ## -# offsetTo # ## -# outset # ## -# right # ## -# set # ## -# setBounds # ## -# setBoundsCheck # ## -# setEmpty # ## -# setLTRB # ## -# setLargest # ## -# setLargestInverted # ## -# setWH # ## -# setXYWH # ## -# toQuad # ## -# top # ## -# width # ## -# x # ## -# y # ## +# Intersects # Returns true if areas overlap. ## +# Make # Constructs from ISize returning (0, 0, width, height). ## +# MakeEmpty # Constructs from bounds of (0, 0, 0, 0). ## +# MakeFromIRect # Deprecated. ## +# MakeIWH # Constructs from int input returning (0, 0, width, height). ## +# MakeLTRB # Constructs from SkScalar left, top, right, bottom. ## +# MakeLargest # Constructs (SK_ScalarMin, SK_ScalarMin, SK_ScalarMax, SK_ScalarMax). ## +# MakeSize # Constructs from Size returning (0, 0, width, height). ## +# MakeWH # Constructs from SkScalar input returning (0, 0, width, height). ## +# MakeXYWH # Constructs from SkScalar input returning (x, y, width, height). ## +# asScalars # Returns pointer to members as array. ## +# bottom() # Returns larger bounds in y, if sorted. ## +# centerX # Returns midpoint in x. ## +# centerY # Returns midpoint in y. ## +# contains() # Returns true if points are equal or inside. ## +# dump() # Sends text representation using floats to standard output. ## +# dumpHex # Sends text representation using hexadecimal to standard output. ## +# growToInclude # Sets to union of bounds and one or more Points. ## +# height # Returns span in y. ## +# inset() # Moves the sides symmetrically about the center. ## +# intersect() # Sets to shared area; returns true if not empty. ## +# intersects() # Returns true if areas overlap. ## +# isEmpty # Returns true if width or height are zero or negative. ## +# isFinite # Returns true if no member is infinite or NaN. ## +# isLargest # Returns equal to (SK_ScalarMin, SK_ScalarMin, SK_ScalarMax, SK_ScalarMax). ## +# isSorted # Returns true if width or height are zero or positive. ## +# iset() # Sets to int input (left, top, right, bottom). ## +# isetWH # Sets to int input (0, 0, width, height). ## +# join() # Sets to union of bounds. ## +# joinNonEmptyArg # Sets to union of bounds, asserting that argument is not empty. ## +# joinPossiblyEmptyRect # Sets to union of bounds. Skips empty check for both. ## +# left() # Returns smaller bounds in x, if sorted. ## +# makeInset # Constructs from sides moved symmetrically about the center. ## +# makeOffset # Constructs from translated sides. ## +# makeOutset # Constructs from sides moved symmetrically about the center. ## +# makeSorted # Constructs, ordering sides from smaller to larger. ## +# offset() # Translates sides without changing width and height. ## +# offsetTo # Translates to (x, y) without changing width and height. ## +# outset() # Moves the sides symmetrically about the center. ## +# right() # Returns larger bounds in x, if sorted. ## +# round() # Sets members to nearest integer value. ## +# roundIn # Sets members to nearest integer value towards opposite. ## +# roundOut # Sets members to nearest integer value away from opposite. ## +# set() # Sets to SkScalar input (left, top, right, bottom) and others. ## +# setBounds # Sets to upper and lower limits of Point array. ## +# setBoundsCheck # Sets to upper and lower limits of Point array. ## +# setEmpty # Sets to (0, 0, 0, 0). ## +# setLTRB # Sets to SkScalar input (left, top, right, bottom). ## +# setLargest # Sets to (SK_ScalarMin, SK_ScalarMin, SK_ScalarMax, SK_ScalarMax). ## +# setLargestInverted # Sets to (SK_ScalarMax, SK_ScalarMax, SK_ScalarMin, SK_ScalarMin). ## +# setWH # Sets to SkScalar input (0, 0, width, height). ## +# setXYWH # Sets to SkScalar input (x, y, width, height). ## +# sort() # Orders sides from smaller to larger. ## +# toQuad # Returns four corners as Point. ## +# top() # Returns smaller bounds in y, if sorted. ## +# width() # Returns span in x. ## +# x() # Returns bounds left. ## +# y() # Returns bounds top. ## #Table ## #Subtopic ## #Topic ## #Member SkScalar fLeft +May contain any value, including infinities and NaN. The smaller of the +horizontal values when sorted. When equal to or greater than fRight, Rect is empty. ## #Member SkScalar fTop +May contain any value, including infinities and NaN. The smaller of the +vertical values when sorted. When equal to or greater than fBottom, Rect is empty. ## #Member SkScalar fRight +May contain any value, including infinities and NaN. The larger of the +horizontal values when sorted. When equal to or less than fLeft, Rect is empty. ## #Member SkScalar fBottom +May contain any value, including infinities and NaN. The larger of the +vertical values when sorted. When equal to or less than fTop, Rect is empty. ## # ------------------------------------------------------------------------------ #Method static constexpr SkRect SK_WARN_UNUSED_RESULT MakeEmpty() -#Return incomplete ## +Returns constructed Rect set to (0, 0, 0, 0). +Many other rectangles are empty; if left is equal to or greater than right, +or if top is equal to or greater than bottom. Setting all members to zero +is a convenience, but does not designate a special empty rectangle. + +#Return bounds (0, 0, 0, 0) ## #Example -// incomplete + SkRect rect = SkRect::MakeEmpty();
+ SkDebugf("MakeEmpty isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+ rect.offset(10, 10);
+ SkDebugf("offset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+ rect.inset(10, 10);
+ SkDebugf("inset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+ rect.outset(20, 20);
+ SkDebugf("outset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+#StdOut
+MakeEmpty isEmpty: true
+offset rect isEmpty: true
+inset rect isEmpty: true
+outset rect isEmpty: false
+##
## -#ToDo incomplete ## +#SeeAlso isEmpty setEmpty setLargestInverted SkIRect::MakeEmpty ## @@ -108,13 +159,32 @@ #Method static SkRect SK_WARN_UNUSED_RESULT MakeLargest() -#Return incomplete ## +Returns constructed Rect setting left and top to most negative finite value, and +setting right and bottom to most positive finite value. + +#Return bounds (SK_ScalarMin, SK_ScalarMin, SK_ScalarMax, SK_ScalarMax) ## #Example -// incomplete + SkRect rect = SkRect::MakeLargest();
+ SkDebugf("MakeLargest isLargest: %s\n", rect.isLargest() ? "true" : "false");
+ SkDebugf("MakeLargest isFinite: %s\n", rect.isFinite() ? "true" : "false");
+ rect.outset(1e31, 1e31);
+ SkDebugf("outset a little isLargest: %s\n", rect.isLargest() ? "true" : "false");
+ SkDebugf("outset a little isFinite: %s\n", rect.isFinite() ? "true" : "false");
+ rect.outset(1e32, 1e32);
+ SkDebugf("outset a little more isLargest: %s\n", rect.isLargest() ? "true" : "false");
+ SkDebugf("outset a little more isFinite: %s\n", rect.isFinite() ? "true" : "false");
+#StdOut
+MakeLargest isLargest: true
+MakeLargest isFinite: true
+outset a little isLargest: true
+outset a little isFinite: true
+outset a little more isLargest: false
+outset a little more isFinite: false
+##
## -#ToDo incomplete ## +#SeeAlso isLargest setLargest SkIRect::MakeLargest ## @@ -122,16 +192,30 @@ #Method static SkRect SK_WARN_UNUSED_RESULT MakeWH(SkScalar w, SkScalar h) -#Param w incomplete ## -#Param h incomplete ## +Returns constructed Rect set to SkScalar values (0, 0, w, h). Does not +validate input; w or h may be negative. -#Return incomplete ## +Passing integer values may generate a compiler warning since Rect cannot +represent 32-bit integers exactly. Use SkIRect for an exact integer rectangle. + +#Param w SkScalar width of constructed Rect ## +#Param h SkScalar height of constructed Rect ## + +#Return bounds (0, 0, w, h) ## #Example -// incomplete + SkRect rect1 = SkRect::MakeWH(25, 35);
+ SkRect rect2 = SkRect::MakeIWH(25, 35);
+ SkRect rect3 = SkRect::MakeXYWH(0, 0, 25, 35);
+ SkRect rect4 = SkRect::MakeLTRB(0, 0, 25, 35);
+ SkDebugf("all %s" "equal\n", rect1 == rect2 && rect2 == rect3 && rect3 == rect4 ?
+ "" : "not "); +#StdOut +all equal +## ## -#ToDo incomplete ## +#SeeAlso MakeSize MakeXYWH MakeIWH setWH SkIRect::MakeWH ## @@ -139,16 +223,31 @@ #Method static SkRect SK_WARN_UNUSED_RESULT MakeIWH(int w, int h) -#Param w incomplete ## -#Param h incomplete ## +Returns constructed Rect set to integer values (0, 0, w, h). Does not validate +input; w or h may be negative. -#Return incomplete ## +Use to avoid a compiler warning that input may lose precision when stored. +Use SkIRect for an exact integer rectangle. + +#Param w integer width of constructed Rect ## +#Param h integer height of constructed Rect ## + +#Return bounds (0, 0, w, h) ## #Example -// incomplete + SkIRect i_rect = SkIRect::MakeWH(25, 35);
+ SkRect f_rect = SkRect::MakeIWH(25, 35);
+ SkDebugf("i_rect width: %d f_rect width:%g\n", i_rect.width(), f_rect.width());
+ i_rect = SkIRect::MakeWH(125000111, 0);
+ f_rect = SkRect::MakeIWH(125000111, 0);
+ SkDebugf("i_rect width: %d f_rect width:%.0f\n", i_rect.width(), f_rect.width());
+#StdOut +i_rect width: 25 f_rect width:25
+i_rect width: 125000111 f_rect width:125000112 +## ## -#ToDo incomplete ## +#SeeAlso MakeXYWH MakeWH isetWH SkIRect::MakeWH ## @@ -156,15 +255,27 @@ #Method static SkRect SK_WARN_UNUSED_RESULT MakeSize(const SkSize& size) -#Param size incomplete ## +Returns constructed Rect set to (0, 0, size.width(), size.height()). Does not +validate input; size.width() or size.height() may be negative. -#Return incomplete ## +#Param size SkScalar values for Rect width and height ## + +#Return bounds (0, 0, size.width(), size.height()) ## #Example -// incomplete + SkSize size = {25.5f, 35.5f};
+ SkRect rect = SkRect::MakeSize(size);
+ SkDebugf("rect width: %g height: %g\n", rect.width(), rect.height());
+ SkISize floor = size.toFloor();
+ rect = SkRect::MakeSize(SkSize::Make(floor));
+ SkDebugf("floor width: %g height: %g\n", rect.width(), rect.height());
+#StdOut +rect width: 25.5 height: 35.5
+floor width: 25 height: 35 +## ## -#ToDo incomplete ## +#SeeAlso MakeWH MakeXYWH MakeIWH setWH SkIRect::MakeWH ## @@ -173,18 +284,30 @@ #Method static constexpr SkRect SK_WARN_UNUSED_RESULT MakeLTRB(SkScalar l, SkScalar t, SkScalar r, SkScalar b) -#Param l incomplete ## -#Param t incomplete ## -#Param r incomplete ## -#Param b incomplete ## +Returns constructed Rect set to (l, t, r, b). Does not sort input; Rect may +result in fLeft greater than fRight, or fTop greater than fBottom. + +#Param l SkScalar stored in fLeft ## +#Param t SkScalar stored in fTop ## +#Param r SkScalar stored in fRight ## +#Param b SkScalar stored in fBottom ## -#Return incomplete ## +#Return bounds (l, t, r, b) ## #Example -// incomplete + SkRect rect = SkRect::MakeLTRB(5, 35, 15, 25);
+ SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect.sort();
+ SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut +rect: 5, 35, 15, 25 isEmpty: true
+rect: 5, 25, 15, 35 isEmpty: false +## ## -#ToDo incomplete ## +#SeeAlso MakeXYWH SkIRect::MakeLTRB ## @@ -192,18 +315,34 @@ #Method static SkRect SK_WARN_UNUSED_RESULT MakeXYWH(SkScalar x, SkScalar y, SkScalar w, SkScalar h) -#Param x incomplete ## -#Param y incomplete ## -#Param w incomplete ## -#Param h incomplete ## +Returns constructed Rect set to +#Formula +(x, y, x + w, y + h) +## +. Does not validate input; +w or h may be negative. + +#Param x stored in fLeft ## +#Param y stored in fTop ## +#Param w added to x and stored in fRight ## +#Param h added to y and stored in fBottom ## -#Return incomplete ## +#Return bounds (x, y, x + w, y + h) ## #Example -// incomplete + SkRect rect = SkRect::MakeXYWH(5, 35, -15, 25);
+ SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect.sort();
+ SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut +rect: 5, 35, -10, 60 isEmpty: true
+rect: -10, 35, 5, 60 isEmpty: false +## ## -#ToDo incomplete ## +#SeeAlso MakeLTRB SkIRect::MakeXYWH ## @@ -211,15 +350,19 @@ #Method static SkRect SK_WARN_UNUSED_RESULT MakeFromIRect(const SkIRect& irect) -#Param irect incomplete ## +Deprecated. -#Return incomplete ## +#Deprecated +## -#Example -// incomplete +#Param irect integer rect ## + +#Return irect as SkRect ## + +#NoExample ## -#ToDo incomplete ## +#SeeAlso Make ## @@ -227,15 +370,23 @@ #Method static SkRect Make(const SkISize& size) -#Param size incomplete ## +Returns constructed IRect set to (0, 0, size.width(), size.height()). +Does not validate input; size.width() or size.height() may be negative. + +#Param size integer values for Rect width and height ## -#Return incomplete ## +#Return bounds (0, 0, size.width(), size.height()) ## #Example -// incomplete + SkRect rect1 = SkRect::MakeSize({2, 35});
+ SkRect rect2 = SkRect::MakeIWH(2, 35);
+ SkDebugf("rect1 %c= rect2\n", rect1 == rect2 ? '=' : '!');
+#StdOut +rect1 == rect2 +## ## -#ToDo incomplete ## +#SeeAlso MakeWH MakeXYWH SkRect::MakeIWH SkIRect::MakeSize ## @@ -243,15 +394,24 @@ #Method static SkRect SK_WARN_UNUSED_RESULT Make(const SkIRect& irect) -#Param irect incomplete ## +Returns constructed IRect set to irect, promoting integers to Scalar. +Does not validate input; fLeft may be greater than fRight, fTop may be greater +than fBottom. + +#Param irect integer unsorted bounds ## -#Return incomplete ## +#Return irect members converted to SkScalar ## #Example -// incomplete + SkIRect i_rect1 = {2, 35, 22, 53};
+ SkRect f_rect = SkRect::Make(i_rect1);
+ f_rect.offset(0.49f, 0.49f);
+ SkIRect i_rect2;
+ f_rect.round(&i_rect2);
+ SkDebugf("i_rect1 %c= i_rect2\n", i_rect1 == i_rect2? '=' : '!');
## -#ToDo incomplete ## +#SeeAlso MakeLTRB ## @@ -259,15 +419,30 @@ #Method bool isEmpty() const -Return true if the rectangle width or height are <= 0 +Returns true if fLeft is equal to or greater than fRight, or if fTop is equal +to or greater than fBottom. Call sort() to reverse rectangles with negative +width() or height(). -#Return incomplete ## +#Return true if width() or height() are zero or negative ## #Example -// incomplete + SkRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}};
+ for (auto rect : tests) {
+ SkDebugf("rect: {%g, %g, %g, %g} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "" : " not");
+ rect.sort();
+ SkDebugf("sorted: {%g, %g, %g, %g} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "" : " not");
+ }
+#StdOut
+rect: {20, 40, 10, 50} is empty
+sorted: {10, 40, 20, 50} is not empty
+rect: {20, 40, 20, 50} is empty
+sorted: {20, 40, 20, 50} is empty
+##
## -#ToDo incomplete ## +#SeeAlso MakeEmpty sort SkIRect::isEmpty ## @@ -275,15 +450,30 @@ Return true if the rectangle width or height are <= 0 #Method bool isSorted() const -Return true if the rectangle width and height are >= 0 +Returns true if fLeft is equal to or less than fRight, or if fTop is equal +to or less than fBottom. Call sort() to reverse rectangles with negative +width() or height(). -#Return incomplete ## +#Return true if width() or height() are zero or positive ## #Example -// incomplete + SkRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}};
+ for (auto rect : tests) {
+ SkDebugf("rect: {%g, %g, %g, %g} is" "%s sorted\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isSorted() ? "" : " not");
+ rect.sort();
+ SkDebugf("sorted: {%g, %g, %g, %g} is" "%s sorted\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isSorted() ? "" : " not");
+ }
+#StdOut
+rect: {20, 40, 10, 50} is not sorted
+sorted: {10, 40, 20, 50} is sorted
+rect: {20, 40, 20, 50} is sorted
+sorted: {20, 40, 20, 50} is sorted
+##
## -#ToDo incomplete ## +#SeeAlso sort makeSorted isEmpty ## @@ -291,13 +481,30 @@ Return true if the rectangle width and height are >= 0 #Method bool isLargest() const -#Return incomplete ## +Returns true if Rect encloses largest possible area. + +#Return true if equal to (SK_ScalarMin, SK_ScalarMin, SK_ScalarMax, SK_ScalarMax) ## #Example -// incomplete +#Description +Note that the width cannot be represented as a 32-bit finite value. +## + SkRect large = SkRect::MakeLargest();
+ SkDebugf("large is largest: %s\n" ,large.isLargest() ? "true" : "false");
+ SkDebugf("large width %g\n", large.width());
+ SkDebugf("large is empty: %s\n", large.isEmpty() ? "true" : "false");
+ SkDebugf("large is sorted: %s\n", large.isSorted() ? "true" : "false"); + SkDebugf("large is finite: %s\n", large.isFinite() ? "true" : "false");
+#StdOut
+large is largest: true
+large width inf
+large is empty: false
+large is sorted: true +large is finite: true +## ## -#ToDo incomplete ## +#SeeAlso MakeLargest SkIRect::isLargest ## @@ -305,16 +512,25 @@ Return true if the rectangle width and height are >= 0 #Method bool isFinite() const -Returns true if and only if all values in the rectangle are finite. If any are -infinite or NaN then this returns false. +Returns true if all values in the rectangle are finite: SK_ScalarMin or larger, +and SK_ScalarMax or smaller. -#Return incomplete ## +#Return true if no member is infinite or NaN ## #Example -// incomplete + SkRect largest = SkRect::MakeLargest();
+ SkDebugf("largest is finite: %s\n", largest.isFinite() ? "true" : "false");
+ SkDebugf("large width %g\n", largest.width());
+ SkRect widest = SkRect::MakeWH(largest.width(), largest.height());
+ SkDebugf("widest is finite: %s\n", widest.isFinite() ? "true" : "false");
+#StdOut
+largest is finite: true
+large width inf
+widest is finite: false +## ## -#ToDo incomplete ## +#SeeAlso SkScalarIsFinite SkScalarIsNaN ## @@ -322,13 +538,23 @@ infinite or NaN then this returns false. #Method SkScalar x() const -#Return incomplete ## +Returns left edge of Rect, if sorted. Call isSorted to see if Rect is valid. +Call sort() to reverse fLeft and fRight if needed. + +#Return fLeft ## #Example -// incomplete + SkRect unsorted = { 15, 5, 10, 25 };
+ SkDebugf("unsorted.fLeft: %g unsorted.x(): %g\n", unsorted.fLeft, unsorted.x());
+ SkRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fLeft: %g sorted.x(): %g\n", sorted.fLeft, sorted.x());
+#StdOut +unsorted.fLeft: 15 unsorted.x(): 15
+sorted.fLeft: 10 sorted.x(): 10 +## ## -#ToDo incomplete ## +#SeeAlso fLeft left() y() SkIRect::x() ## @@ -336,13 +562,23 @@ infinite or NaN then this returns false. #Method SkScalar y() const -#Return incomplete ## +Returns top edge of Rect, if sorted. Call isEmpty to see if Rect may be invalid, +and sort() to reverse fTop and fBottom if needed. + +#Return fTop ## #Example -// incomplete + SkRect unsorted = { 15, 25, 10, 5 };
+ SkDebugf("unsorted.fTop: %g unsorted.y(): %g\n", unsorted.fTop, unsorted.y());
+ SkRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fTop: %g sorted.y(): %g\n", sorted.fTop, sorted.y()); +#StdOut +unsorted.fTop: 25 unsorted.y(): 25
+sorted.fTop: 5 sorted.y(): 5 +## ## -#ToDo incomplete ## +#SeeAlso fTop top() x() SkIRect::y() ## @@ -350,13 +586,23 @@ infinite or NaN then this returns false. #Method SkScalar left() const -#Return incomplete ## +Returns left edge of Rect, if sorted. Call isSorted to see if Rect is valid. +Call sort() to reverse fLeft and fRight if needed. + +#Return fLeft ## #Example -// incomplete + SkRect unsorted = { 15, 5, 10, 25 };
+ SkDebugf("unsorted.fLeft: %g unsorted.left(): %g\n", unsorted.fLeft, unsorted.left());
+ SkRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fLeft: %g sorted.left(): %g\n", sorted.fLeft, sorted.left());
+#StdOut +unsorted.fLeft: 15 unsorted.left(): 15
+sorted.fLeft: 10 sorted.left(): 10 +## ## -#ToDo incomplete ## +#SeeAlso fLeft x() SkIRect::left() ## @@ -364,13 +610,23 @@ infinite or NaN then this returns false. #Method SkScalar top() const -#Return incomplete ## +Returns top edge of Rect, if sorted. Call isEmpty to see if Rect may be invalid, +and sort() to reverse fTop and fBottom if needed. + +#Return fTop ## #Example -// incomplete + SkRect unsorted = { 15, 25, 10, 5 };
+ SkDebugf("unsorted.fTop: %g unsorted.top(): %g\n", unsorted.fTop, unsorted.top());
+ SkRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fTop: %g sorted.top(): %g\n", sorted.fTop, sorted.top()); +#StdOut +unsorted.fTop: 25 unsorted.top(): 25
+sorted.fTop: 5 sorted.top(): 5 +## ## -#ToDo incomplete ## +#SeeAlso fTop y() SkIRect::top() ## @@ -378,13 +634,23 @@ infinite or NaN then this returns false. #Method SkScalar right() const -#Return incomplete ## +Returns right edge of Rect, if sorted. Call isSorted to see if Rect is valid. +Call sort() to reverse fLeft and fRight if needed. + +#Return fRight ## #Example -// incomplete + SkRect unsorted = { 15, 25, 10, 5 };
+ SkDebugf("unsorted.fRight: %g unsorted.right(): %g\n", unsorted.fRight, unsorted.right());
+ SkRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fRight: %g sorted.right(): %g\n", sorted.fRight, sorted.right());
+#StdOut +unsorted.fRight: 10 unsorted.right(): 10
+sorted.fRight: 15 sorted.right(): 15 +## ## -#ToDo incomplete ## +#SeeAlso fRight SkIRect::right() ## @@ -392,13 +658,23 @@ infinite or NaN then this returns false. #Method SkScalar bottom() const -#Return incomplete ## +Returns bottom edge of Rect, if sorted. Call isEmpty to see if Rect may be invalid, +and sort() to reverse fTop and fBottom if needed. + +#Return fBottom ## #Example -// incomplete + SkRect unsorted = { 15, 25, 10, 5 };
+ SkDebugf("unsorted.fBottom: %g unsorted.bottom(): %g\n", unsorted.fBottom, unsorted.bottom());
+ SkRect sorted = unsorted.makeSorted();
+ SkDebugf("sorted.fBottom: %g sorted.bottom(): %g\n", sorted.fBottom, sorted.bottom());
+#StdOut +unsorted.fBottom: 5 unsorted.bottom(): 5
+sorted.fBottom: 25 sorted.bottom(): 25 +## ## -#ToDo incomplete ## +#SeeAlso fBottom SkIRect::bottom() ## @@ -406,13 +682,26 @@ infinite or NaN then this returns false. #Method SkScalar width() const -#Return incomplete ## +Returns span on the x-axis. This does not check if Rect is sorted, or if +result fits in 32-bit float; result may be negative or infinity. + +#Return fRight minus fLeft ## #Example -// incomplete +#Description +Compare with SkIRect::width() example. +## + SkRect unsorted = { 15, 25, 10, 5 };
+ SkDebugf("unsorted width: %g\n", unsorted.width());
+ SkRect large = { -2147483647.f, 1, 2147483644.f, 2 };
+ SkDebugf("large width: %.0f\n", large.width());
+#StdOut +unsorted width: -5
+large width: 4294967296 +## ## -#ToDo incomplete ## +#SeeAlso height() SkIRect::width() ## @@ -420,13 +709,26 @@ infinite or NaN then this returns false. #Method SkScalar height() const -#Return incomplete ## +Returns span on the y-axis. This does not check if IRect is sorted, or if +result fits in 32-bit float; result may be negative or infinity. + +#Return fBottom minus fTop ## #Example -// incomplete +#Description +Compare with SkIRect::height() example. +## + SkRect unsorted = { 15, 25, 10, 20 };
+ SkDebugf("unsorted height: %g\n", unsorted.height());
+ SkRect large = { 1, -2147483647.f, 2, 2147483644.f };
+ SkDebugf("large height: %.0f\n", large.height());
+#StdOut +unsorted height: -5
+large height: 4294967296 +## ## -#ToDo incomplete ## +#SeeAlso width() SkIRect::height() ## @@ -434,13 +736,27 @@ infinite or NaN then this returns false. #Method SkScalar centerX() const -#Return incomplete ## +Returns average of left edge and right edge. Result does not change if Rect +is sorted. Result may overflow to infinity if Rect is far from the origin. + +#Return midpoint in x ## #Example -// incomplete + SkRect tests[] = {{20, 30, 41, 51}, {-20, -30, -41, -51}};
+ for (auto rect : tests) {
+ SkDebugf("left: %3g right: %3g centerX: %3g\n", rect.left(), rect.right(), rect.centerX());
+ rect.sort();
+ SkDebugf("left: %3g right: %3g centerX: %3g\n", rect.left(), rect.right(), rect.centerX());
+ }
+#StdOut +left: 20 right: 41 centerX: 30.5
+left: 20 right: 41 centerX: 30.5
+left: -20 right: -41 centerX: -30.5
+left: -41 right: -20 centerX: -30.5 +## ## -#ToDo incomplete ## +#SeeAlso centerY SkIRect::centerX ## @@ -448,13 +764,21 @@ infinite or NaN then this returns false. #Method SkScalar centerY() const -#Return incomplete ## +Returns average of top edge and bottom edge. Result does not change if Rect +is sorted. Result may overflow to infinity if Rect is far from the origin. + +#Return midpoint in y ## #Example -// incomplete + SkRect rect = { 2e+38, 2e+38, 3e+38, 3e+38 };
+ SkDebugf("left: %g right: %g centerX: %g ", rect.left(), rect.right(), rect.centerX());
+ SkDebugf("safe mid x: %g\n", rect.left() / 2 + rect.right() / 2);
+#StdOut +left: 2e+38 right: 3e+38 centerX: inf safe mid x: 2.5e+38 +## ## -#ToDo incomplete ## +#SeeAlso centerX SkIRect::centerY ## @@ -462,16 +786,42 @@ infinite or NaN then this returns false. #Method friend bool operator==(const SkRect& a, const SkRect& b) -#Param a incomplete ## -#Param b incomplete ## +Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are +equal to the corresponding members in b. -#Return incomplete ## +a and b are not equal if either contain NaN. a and b are equal if members +contain zeroes width different signs. + +#Param a Rect to compare ## +#Param b Rect to compare ## + +#Return true if members are equal ## #Example -// incomplete + auto debugster = [](const SkRect& test) -> void {
+ SkRect negZero = {-0.0f, -0.0f, 2, 2};
+ SkDebugf("{%g, %g, %g, %g} %c= {%g, %g, %g, %g} %s numerically equal\n",
+ test.fLeft, test.fTop, test.fRight, test.fBottom,
+ negZero.fLeft, negZero.fTop, negZero.fRight, negZero.fBottom,
+ test == negZero ? '=' : '!',
+ test.fLeft == negZero.fLeft && test.fTop == negZero.fTop &&
+ test.fRight == negZero.fRight && test.fBottom == negZero.fBottom ?
+ "and are" : "yet are not");
+ };
+ SkRect tests[] = {{0, 0, 2, 2}, {-0, -0, 2, 2}, {0.0f, 0.0f, 2, 2}};
+ SkDebugf("tests are %s" "equal\n", tests[0] == tests[1] && tests[1] == tests[2] ? "" : "not ");
+ for (auto rect : tests) {
+ debugster(rect);
+ } +#StdOut
+tests are equal
+{0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal
+{0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal
+{0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal +## ## -#ToDo incomplete ## +#SeeAlso operator!=(const SkRect& a, const SkRect& b) ## @@ -479,16 +829,26 @@ infinite or NaN then this returns false. #Method friend bool operator!=(const SkRect& a, const SkRect& b) -#Param a incomplete ## -#Param b incomplete ## +Returns true if any in a: fLeft, fTop, fRight, and fBottom; does not +equal the corresponding members in b. -#Return incomplete ## +a and b are not equal if either contain NaN. a and b are equal if members +contain zeroes width different signs. + +#Param a Rect to compare ## +#Param b Rect to compare ## + +#Return true if members are not equal ## #Example -// incomplete + SkRect test = {0, 0, 2, SK_ScalarNaN};
+ SkDebugf("test with NaN is %s" "equal to itself\n", test == test ? "" : "not ");
+#StdOut
+test with NaN is not equal to itself +## ## -#ToDo incomplete ## +#SeeAlso operator==(const SkRect& a, const SkRect& b) ## @@ -496,19 +856,32 @@ infinite or NaN then this returns false. #Method void toQuad(SkPoint quad[4]) const -return the 4 points that enclose the rectangle (top-left, top-right, bottom-right, -bottom-left). -#ToDo +Returns four points in quad that enclose Rect ordered as: top-left, top-right, +bottom-right, bottom-left. + +#Private Consider adding param to control whether quad is CW or CCW. ## -#Param quad incomplete ## +#Param quad storage for corners of Rect ## #Example -// incomplete + SkRect rect = {1, 2, 3, 4};
+ SkPoint corners[4];
+ rect.toQuad(corners);
+ SkDebugf("rect: {%g, %g, %g, %g}\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+ SkDebugf("corners:");
+ for (auto corner : corners) {
+ SkDebugf(" {%g, %g}", corner.fX, corner.fY);
+ }
+ SkDebugf("\n");
+#StdOut
+rect: {1, 2, 3, 4}
+corners: {1, 2} {3, 2} {3, 4} {1, 4} +## ## -#ToDo incomplete ## +#SeeAlso SkPath::addRect ## @@ -516,13 +889,26 @@ Consider adding param to control whether quad is CW or CCW. #Method void setEmpty() -Set this rectangle to the empty rectangle (0,0,0,0) +Sets Rect to (0, 0, 0, 0). + +Many other rectangles are empty; if left is equal to or greater than right, +or if top is equal to or greater than bottom. Setting all members to zero +is a convenience, but does not designate a special empty rectangle. #Example -// incomplete + SkRect rect = {3, 4, 1, 2};
+ for (int i = 0; i < 2; ++i) {
+ SkDebugf("rect: {%g, %g, %g, %g} is %s" "empty\n", rect.fLeft, rect.fTop,
+ rect.fRight, rect.fBottom, rect.isEmpty() ? "" : "not ");
+ rect.setEmpty();
+ }
+#StdOut
+rect: {3, 4, 1, 2} is empty
+rect: {0, 0, 0, 0} is empty
+##
## -#ToDo incomplete ## +#SeeAlso MakeEmpty SkIRect::setEmpty ## @@ -530,13 +916,24 @@ Set this rectangle to the empty rectangle (0,0,0,0) #Method void set(const SkIRect& src) -#Param src incomplete ## +Sets Rect to src, promoting src members from integer to Scalar. +Very large values in src may lose precision. + +#Param src integer Rect ## #Example -// incomplete + SkIRect i_rect = {3, 4, 1, 2};
+ SkDebugf("i_rect: {%d, %d, %d, %d}\n", i_rect.fLeft, i_rect.fTop, i_rect.fRight, i_rect.fBottom);
+ SkRect f_rect;
+ f_rect.set(i_rect);
+ SkDebugf("f_rect: {%g, %g, %g, %g}\n", f_rect.fLeft, f_rect.fTop, f_rect.fRight, f_rect.fBottom);
+#StdOut
+i_rect: {3, 4, 1, 2}
+f_rect: {3, 4, 1, 2}
+##
## -#ToDo incomplete ## +#SeeAlso setLTRB SkIntToScalar ## @@ -544,16 +941,28 @@ Set this rectangle to the empty rectangle (0,0,0,0) #Method void set(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) -#Param left incomplete ## -#Param top incomplete ## -#Param right incomplete ## -#Param bottom incomplete ## +Sets Rect to (left, top, right, bottom). +left and right are not sorted; left is not necessarily less than right. +top and bottom are not sorted; top is not necessarily less than bottom. + +#Param left stored in fLeft ## +#Param top stored in fTop ## +#Param right stored in fRight ## +#Param bottom stored in fBottom ## #Example -// incomplete + SkRect rect1 = {3, 4, 1, 2};
+ SkDebugf("rect1: {%g, %g, %g, %g}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
+ SkRect rect2;
+ rect2.set(3, 4, 1, 2);
+ SkDebugf("rect2: {%g, %g, %g, %g}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
+#StdOut
+rect1: {3, 4, 1, 2}
+rect2: {3, 4, 1, 2}
+##
## -#ToDo incomplete ## +#SeeAlso setLTRB setXYWH SkIRect::set ## @@ -561,18 +970,28 @@ Set this rectangle to the empty rectangle (0,0,0,0) #Method void setLTRB(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) -alias for set(l, t, r, b) +Sets Rect to (left, top, right, bottom). +left and right are not sorted; left is not necessarily less than right. +top and bottom are not sorted; top is not necessarily less than bottom. -#Param left incomplete ## -#Param top incomplete ## -#Param right incomplete ## -#Param bottom incomplete ## +#Param left stored in fLeft ## +#Param top stored in fTop ## +#Param right stored in fRight ## +#Param bottom stored in fBottom ## #Example -// incomplete + SkRect rect1 = {3, 4, 1, 2};
+ SkDebugf("rect1: {%g, %g, %g, %g}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
+ SkRect rect2;
+ rect2.setLTRB(3, 4, 1, 2);
+ SkDebugf("rect2: {%g, %g, %g, %g}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
+#StdOut
+rect1: {3, 4, 1, 2}
+rect2: {3, 4, 1, 2}
+##
## -#ToDo incomplete ## +#SeeAlso set setXYWH SkIRect::set ## @@ -580,19 +999,29 @@ alias for set(l, t, r, b) #Method void iset(int left, int top, int right, int bottom) -Initialize the rectangle with the 4 specified integers. The routine handles -converting them to scalars (by calling SkIntToScalar) +Sets Rect to (left, top, right, bottom). +All parameters are promoted from integer to Scalar. +left and right are not sorted; left is not necessarily less than right. +top and bottom are not sorted; top is not necessarily less than bottom. -#Param left incomplete ## -#Param top incomplete ## -#Param right incomplete ## -#Param bottom incomplete ## +#Param left promoted to SkScalar and stored in fLeft ## +#Param top promoted to SkScalar and stored in fTop ## +#Param right promoted to SkScalar and stored in fRight ## +#Param bottom promoted to SkScalar and stored in fBottom ## #Example -// incomplete + SkRect rect1 = {3, 4, 1, 2};
+ SkDebugf("rect1: {%g, %g, %g, %g}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
+ SkRect rect2;
+ rect2.iset(3, 4, 1, 2);
+ SkDebugf("rect2: {%g, %g, %g, %g}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
+#StdOut
+rect1: {3, 4, 1, 2}
+rect2: {3, 4, 1, 2}
+##
## -#ToDo incomplete ## +#SeeAlso set setLTRB SkIRect::set SkIntToScalar ## @@ -600,17 +1029,26 @@ converting them to scalars (by calling SkIntToScalar) #Method void isetWH(int width, int height) -Set this rectangle to be left/top at 0,0, and have the specified width -and height (automatically converted to SkScalar). +Sets Rect to (0, 0, width, height). +width and height may be zero or negative. width and height are promoted from +integer to SkScalar, large values may lose precision. -#Param width incomplete ## -#Param height incomplete ## +#Param width promoted to SkScalar and stored in fRight ## +#Param height promoted to SkScalar and stored in fBottom ## #Example -// incomplete + SkRect rect1 = {0, 0, 1, 2};
+ SkDebugf("rect1: {%g, %g, %g, %g}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
+ SkRect rect2;
+ rect2.isetWH(1, 2);
+ SkDebugf("rect2: {%g, %g, %g, %g}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom); +#StdOut
+rect1: {0, 0, 1, 2}
+rect2: {0, 0, 1, 2}
+##
## -#ToDo incomplete ## +#SeeAlso MakeWH MakeXYWH iset() SkIRect:MakeWH ## @@ -618,18 +1056,38 @@ and height (automatically converted to SkScalar). #Method void set(const SkPoint pts[], int count) -Set this rectangle to be the bounds of the array of points. -If the array is empty (count == 0), then set this rectangle -to the empty rectangle (0,0,0,0) +Sets to bounds of Point array with count entries. If count is zero or smaller, +or if Point array contains an infinity or NaN, sets Rect to (0, 0, 0, 0). + +Result is either empty or sorted: fLeft is less than or equal to fRight, and +fTop is less than or equal to fBottom. -#Param pts incomplete ## -#Param count incomplete ## +#Param pts Point array ## +#Param count entries in array ## #Example -// incomplete + SkPoint points[] = {{3, 4}, {1, 2}, {5, 6}, {SK_ScalarNaN, 8}};
+ for (int count = 0; count <= (int) SK_ARRAY_COUNT(points); ++count) {
+ SkRect rect;
+ rect.set(points, count);
+ if (count > 0) {
+ SkDebugf("added: %3g, %g ", points[count - 1].fX, points[count - 1].fY);
+ } else {
+ SkDebugf("%14s", " ");
+ }
+ SkDebugf("count: %d rect: %g, %g, %g, %g\n", count,
+ rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+ }
+#StdOut
+ count: 0 rect: 0, 0, 0, 0
+added: 3, 4 count: 1 rect: 3, 4, 3, 4
+added: 1, 2 count: 2 rect: 1, 2, 3, 4
+added: 5, 6 count: 3 rect: 1, 2, 5, 6
+added: nan, 8 count: 4 rect: 0, 0, 0, 0
+##
## -#ToDo incomplete ## +#SeeAlso setBounds setBoundsCheck SkPath::addPoly ## @@ -637,16 +1095,38 @@ to the empty rectangle (0,0,0,0) #Method void setBounds(const SkPoint pts[], int count) -alias for set(pts, count) +Sets to bounds of Point array with count entries. If count is zero or smaller, +or if Point array contains an infinity or NaN, sets to (0, 0, 0, 0). -#Param pts incomplete ## -#Param count incomplete ## +Result is either empty or sorted: fLeft is less than or equal to fRight, and +fTop is less than or equal to fBottom. + +#Param pts Point array ## +#Param count entries in array ## #Example -// incomplete + SkPoint points[] = {{3, 4}, {1, 2}, {5, 6}, {SK_ScalarNaN, 8}};
+ for (int count = 0; count <= (int) SK_ARRAY_COUNT(points); ++count) {
+ SkRect rect;
+ rect.setBounds(points, count);
+ if (count > 0) {
+ SkDebugf("added: %3g, %g ", points[count - 1].fX, points[count - 1].fY);
+ } else {
+ SkDebugf("%14s", " ");
+ }
+ SkDebugf("count: %d rect: %g, %g, %g, %g\n", count,
+ rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+ }
+#StdOut
+ count: 0 rect: 0, 0, 0, 0
+added: 3, 4 count: 1 rect: 3, 4, 3, 4
+added: 1, 2 count: 2 rect: 1, 2, 3, 4
+added: 5, 6 count: 3 rect: 1, 2, 5, 6
+added: nan, 8 count: 4 rect: 0, 0, 0, 0
+##
## -#ToDo incomplete ## +#SeeAlso set setBoundsCheck SkPath::addPoly ## @@ -654,20 +1134,41 @@ alias for set(pts, count) #Method bool setBoundsCheck(const SkPoint pts[], int count) -Compute the bounds of the array of points, and set this rectangle to that -bounds and return true... unless a non-finite value is encountered, -in which case this rectangle is set to empty and false is returned. +Sets to bounds of Point array with count entries. Returns false if count is +zero or smaller, or if Point array contains an infinity or NaN; in these cases +sets Rect to (0, 0, 0, 0). + +Result is either empty or sorted: fLeft is less than or equal to fRight, and +fTop is less than or equal to fBottom. -#Param pts incomplete ## -#Param count incomplete ## +#Param pts Point array ## +#Param count entries in array ## -#Return incomplete ## +#Return true if all Point values are finite ## #Example -// incomplete + SkPoint points[] = {{3, 4}, {1, 2}, {5, 6}, {SK_ScalarNaN, 8}};
+ for (int count = 0; count <= (int) SK_ARRAY_COUNT(points); ++count) {
+ SkRect rect;
+ bool success = rect.setBoundsCheck(points, count);
+ if (count > 0) {
+ SkDebugf("added: %3g, %g ", points[count - 1].fX, points[count - 1].fY);
+ } else {
+ SkDebugf("%14s", " ");
+ }
+ SkDebugf("count: %d rect: %g, %g, %g, %g success: %s\n", count,
+ rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, success ? "true" : "false");
+ }
+#StdOut
+ count: 0 rect: 0, 0, 0, 0 success: true
+added: 3, 4 count: 1 rect: 3, 4, 3, 4 success: true
+added: 1, 2 count: 2 rect: 1, 2, 3, 4 success: true
+added: 5, 6 count: 3 rect: 1, 2, 5, 6 success: true
+added: nan, 8 count: 4 rect: 0, 0, 0, 0 success: false
+##
## -#ToDo incomplete ## +#SeeAlso set setBounds SkPath::addPoly ## @@ -675,14 +1176,26 @@ in which case this rectangle is set to empty and false is returned. #Method void set(const SkPoint& p0, const SkPoint& p1) -#Param p0 incomplete ## -#Param p1 incomplete ## +Sets bounds to the smallest Rect enclosing Points p0 and p1. The result is +sorted and may be empty. Does not check to see if values are finite. + +#Param p0 corner to include ## +#Param p1 corner to include ## #Example -// incomplete +#Description +p0 and p1 may be swapped and have the same effect unless one contains NaN. +## + SkPoint point1 = {SK_ScalarNaN, 8};
+ SkPoint point2 = {3, 4};
+ SkRect rect;
+ rect.set(point1, point2);
+ SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+ rect.set(point2, point1);
+ SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
## -#ToDo incomplete ## +#SeeAlso setBounds setBoundsCheck ## @@ -690,16 +1203,33 @@ in which case this rectangle is set to empty and false is returned. #Method void setXYWH(SkScalar x, SkScalar y, SkScalar width, SkScalar height) -#Param x incomplete ## -#Param y incomplete ## -#Param width incomplete ## -#Param height incomplete ## +Sets Rect to +#Formula +(x, y, x + width, y + height) +## +. Does not validate input; +width or height may be negative. + +#Param x stored in fLeft ## +#Param y stored in fTop ## +#Param width added to x and stored in fRight ## +#Param height added to y and stored in fBottom ## #Example -// incomplete + SkRect rect;
+ rect.setXYWH(5, 35, -15, 25);
+ SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect.sort();
+ SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut +rect: 5, 35, -10, 60 isEmpty: true
+rect: -10, 35, 5, 60 isEmpty: false +## ## -#ToDo incomplete ## +#SeeAlso MakeXYWH setLTRB set SkIRect::setXYWH ## @@ -707,14 +1237,27 @@ in which case this rectangle is set to empty and false is returned. #Method void setWH(SkScalar width, SkScalar height) -#Param width incomplete ## -#Param height incomplete ## +Sets Rect to (0, 0, width, height). Does not validate input; +width or height may be negative. + +#Param width stored in fRight ## +#Param height stored in fBottom ## #Example -// incomplete + SkRect rect;
+ rect.setWH(-15, 25);
+ SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect.sort();
+ SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut +rect: 0, 0, -15, 25 isEmpty: true
+rect: -15, 0, 0, 25 isEmpty: false +## ## -#ToDo incomplete ## +#SeeAlso MakeWH setXYWH isetWH ## @@ -722,14 +1265,31 @@ in which case this rectangle is set to empty and false is returned. #Method void setLargest() -Sets rectangle left and top to most negative value, and sets -right and bottom to most positive value. +Sets rectangle left and top to most negative finite value, and sets +right and bottom to most positive finite value. #Example -// incomplete + SkRect rect;
+ rect.setLargest();
+ SkDebugf("MakeLargest isLargest: %s\n", rect.isLargest() ? "true" : "false");
+ SkDebugf("MakeLargest isFinite: %s\n", rect.isFinite() ? "true" : "false");
+ rect.outset(1e31, 1e31);
+ SkDebugf("outset a little isLargest: %s\n", rect.isLargest() ? "true" : "false");
+ SkDebugf("outset a little isFinite: %s\n", rect.isFinite() ? "true" : "false");
+ rect.outset(1e32, 1e32);
+ SkDebugf("outset a little more isLargest: %s\n", rect.isLargest() ? "true" : "false");
+ SkDebugf("outset a little more isFinite: %s\n", rect.isFinite() ? "true" : "false");
+#StdOut
+MakeLargest isLargest: true
+MakeLargest isFinite: true
+outset a little isLargest: true
+outset a little isFinite: true
+outset a little more isLargest: false
+outset a little more isFinite: false
+##
## -#ToDo incomplete ## +#SeeAlso MakeLargest isLargest setLargestInverted SK_ScalarMin SK_ScalarMax ## @@ -737,14 +1297,29 @@ right and bottom to most positive value. #Method void setLargestInverted() -Sets rectangle left and top to most positive value, and sets -right and bottom to most negative value. +Sets rectangle left and top to most positive finite value, and sets +right and bottom to most negative finite value. + +Use to initial Rect before one or more calls to growToInclude. #Example -// incomplete + auto debugster = [](const char* prefix, const SkRect& rect) -> void {
+ SkDebugf("%s ", prefix);
+ SkDebugf("rect: %g, %g, %g, %g ", rect.left(), rect.top(), rect.right(), rect.bottom());
+ SkDebugf("isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+ };
+ SkRect ptBounds;
+ ptBounds.setLargestInverted();
+ debugster("original", ptBounds);
+ ptBounds.growToInclude( { 42, 24 } );
+ debugster("grown", ptBounds); +#StdOut
+original rect: 3.40282e+38, 3.40282e+38, -3.40282e+38, -3.40282e+38 isEmpty: true
+grown rect: 42, 24, 42, 24 isEmpty: true
+##
## -#ToDo incomplete ## +#SeeAlso growToInclude setEmpty setLargest ## @@ -752,18 +1327,32 @@ right and bottom to most negative value. #Method SkRect makeOffset(SkScalar dx, SkScalar dy) const -Return a new Rect, built as an offset of this rectangle. +Returns Rect offset by (dx, dy). + +If dx is negative, Rect returned is moved to the left. +If dx is positive, Rect returned is moved to the right. +If dy is negative, Rect returned is moved upward. +If dy is positive, Rect returned is moved downward. -#Param dx incomplete ## -#Param dy incomplete ## +#Param dx added to fLeft and fRight ## +#Param dy added to fTop and fBottom ## -#Return incomplete ## +#Return Rect offset in x or y, with original width and height ## #Example -// incomplete + SkRect rect = { 10, 50, 20, 60 };
+ SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect = rect.makeOffset(15, 32);
+ SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut
+rect: 10, 50, 20, 60 isEmpty: false
+rect: 25, 82, 35, 92 isEmpty: false
+##
## -#ToDo incomplete ## +#SeeAlso offset() makeInset makeOutset SkIRect::makeOffset ## @@ -771,18 +1360,32 @@ Return a new Rect, built as an offset of this rectangle. #Method SkRect makeInset(SkScalar dx, SkScalar dy) const -Return a new Rect, built as an inset of this rectangle. +Returns Rect, inset by (dx, dy). -#Param dx incomplete ## -#Param dy incomplete ## +If dx is negative, Rect returned is wider. +If dx is positive, Rect returned is narrower. +If dy is negative, Rect returned is taller. +If dy is positive, Rect returned is shorter. -#Return incomplete ## +#Param dx added to fLeft and subtracted from fRight ## +#Param dy added to fTop and subtracted from fBottom ## + +#Return Rect inset symmetrically left and right, top and bottom ## #Example -// incomplete + SkRect rect = { 10, 50, 20, 60 };
+ SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect = rect.makeInset(15, 32);
+ SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut
+rect: 10, 50, 20, 60 isEmpty: false
+rect: 25, 82, 5, 28 isEmpty: true
+##
## -#ToDo incomplete ## +#SeeAlso inset() makeOffset makeOutset SkIRect::makeInset ## @@ -790,18 +1393,32 @@ Return a new Rect, built as an inset of this rectangle. #Method SkRect makeOutset(SkScalar dx, SkScalar dy) const -Return a new Rect, built as an outset of this rectangle. +Returns Rect, outset by (dx, dy). + +If dx is negative, Rect returned is narrower. +If dx is positive, Rect returned is wider. +If dy is negative, Rect returned is shorter. +If dy is positive, Rect returned is taller. -#Param dx incomplete ## -#Param dy incomplete ## +#Param dx subtracted to fLeft and added from fRight ## +#Param dy subtracted to fTop and added from fBottom ## -#Return incomplete ## +#Return Rect outset symmetrically left and right, top and bottom ## #Example -// incomplete + SkRect rect = { 10, 50, 20, 60 };
+ SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+ rect = rect.makeOutset(15, 32);
+ SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
+ rect.bottom(), rect.isEmpty() ? "true" : "false");
+#StdOut
+rect: 10, 50, 20, 60 isEmpty: false
+rect: -5, 18, 35, 92 isEmpty: false
+##
## -#ToDo incomplete ## +#SeeAlso outset() makeOffset makeInset SkIRect::makeOutset ## @@ -809,17 +1426,26 @@ Return a new Rect, built as an outset of this rectangle. #Method void offset(SkScalar dx, SkScalar dy) -Offset set the rectangle by adding dx to its left and right, -and adding dy to its top and bottom. +Offsets Rect by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom. + +If dx is negative, moves Rect to the left. +If dx is positive, moves Rect to the right. +If dy is negative, moves Rect upward. +If dy is positive, moves Rect downward. -#Param dx incomplete ## -#Param dy incomplete ## +#Param dx offset added to fLeft and fRight ## +#Param dy offset added to fTop and fBottom ## #Example -// incomplete + SkRect rect = { 10, 14, 50, 73 };
+ rect.offset(5, 13);
+ SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 15, 27, 55, 86
+##
## -#ToDo incomplete ## +#SeeAlso offsetTo makeOffset SkIRect::offset ## @@ -827,13 +1453,26 @@ and adding dy to its top and bottom. #Method void offset(const SkPoint& delta) -#Param delta incomplete ## +Offsets Rect by adding delta.fX to fLeft, fRight; and by adding delta.fY to +fTop, fBottom. + +If delta.fX is negative, moves Rect to the left. +If delta.fX is positive, moves Rect to the right. +If delta.fY is negative, moves Rect upward. +If delta.fY is positive, moves Rect downward. + +#Param delta added to Rect ## #Example -// incomplete + SkRect rect = { 10, 14, 50, 73 };
+ rect.offset({5, 13});
+ SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 15, 27, 55, 86
+##
## -#ToDo incomplete ## +#SeeAlso offsetTo makeOffset SkIRect::offset ## @@ -841,16 +1480,22 @@ and adding dy to its top and bottom. #Method void offsetTo(SkScalar newX, SkScalar newY) -Offset this rectangle such its new x() and y() will equal newX and newY. +Offsets Rect so that fLeft equals newX, and fTop equals newY. width and height +are unchanged. -#Param newX incomplete ## -#Param newY incomplete ## +#Param newX stored in fLeft, preserving width() ## +#Param newY stored in fTop, preserving height() ## #Example -// incomplete + SkRect rect = { 10, 14, 50, 73 };
+ rect.offsetTo(15, 27);
+ SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 15, 27, 55, 86
+##
## -#ToDo incomplete ## +#SeeAlso offset makeOffset setXYWH SkIRect::offsetTo ## @@ -858,19 +1503,26 @@ Offset this rectangle such its new x() and y() will equal newX and newY. #Method void inset(SkScalar dx, SkScalar dy) -Inset the rectangle by (dx,dy). If dx is positive, then the sides are -moved inwards, making the rectangle narrower. If dx is negative, then -the sides are moved outwards, making the rectangle wider. The same holds -true for dy and the top and bottom. +Insets Rect by (dx, dy). + +If dx is positive, makes Rect narrower. +If dx is negative, makes Rect wider. +If dy is positive, makes Rect shorter. +If dy is negative, makes Rect taller. -#Param dx incomplete ## -#Param dy incomplete ## +#Param dx added to fLeft and subtracted from fRight ## +#Param dy added to fTop and subtracted from fBottom ## #Example -// incomplete + SkRect rect = { 10, 14, 50, 73 };
+ rect.inset(5, 13);
+ SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 15, 27, 45, 60
+##
## -#ToDo incomplete ## +#SeeAlso outset makeInset SkIRect::inset ## @@ -878,39 +1530,71 @@ true for dy and the top and bottom. #Method void outset(SkScalar dx, SkScalar dy) -Outset the rectangle by (dx,dy). If dx is positive, then the sides are -moved outwards, making the rectangle wider. If dx is negative, then the -sides are moved inwards, making the rectangle narrower. The same holds -true for dy and the top and bottom. +Outsets Rect by (dx, dy). -#Param dx incomplete ## -#Param dy incomplete ## +If dx is positive, makes Rect wider. +If dx is negative, makes Rect narrower. +If dy is positive, makes Rect taller. +If dy is negative, makes Rect shorter. + +#Param dx subtracted to fLeft and added from fRight ## +#Param dy subtracted to fTop and added from fBottom ## #Example -// incomplete + SkRect rect = { 10, 14, 50, 73 };
+ rect.outset(5, 13);
+ SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut
+rect: 5, 1, 55, 86
+##
## -#ToDo incomplete ## +#SeeAlso inset makeOutset SkIRect::outset ## +#Topic Intersection + +Rects intersect when they enclose a common area. To intersect, each of the pair +must describe area; fLeft is less than fRight, and fTop is less than fBottom; +empty() returns false. The intersection of Rect a and Rect b can be described by: +#Formula +(max(a.fLeft, b.fLeft), max(a.fTop, b.fTop), + min(a.fRight, b.fRight), min(a.fBottom, b.fBottom)) +## +The intersection is only meaningful if the resulting Rect is not empty and +describes an area: fLeft is less than fRight, and fTop is less than fBottom. + # ------------------------------------------------------------------------------ #Method bool intersect(const SkRect& r) -If this rectangle intersects r, return true and set this rectangle to that -intersection, otherwise return false and do not change this rectangle. -If either rectangle is empty, do nothing and return false. +Returns true if Rect intersects r, and sets Rect to intersection. +Returns false if Rect does not intersect r, and leaves Rect unchanged. + +Returns false if either r or Rect is empty, leaving Rect unchanged. -#Param r incomplete ## +#Param r limit of result ## -#Return incomplete ## +#Return true if r and Rect have area in common ## #Example -// incomplete +#Description +Two SkDebugf calls are required. If the calls are combined, their arguments +may not be evaluated in left to right order: the printed intersection may +be before or after the call to intersect. +## + SkRect leftRect = { 10, 40, 50, 80 };
+ SkRect rightRect = { 30, 60, 70, 90 };
+ SkDebugf("%s intersection: ", leftRect.intersect(rightRect) ? "" : "no ");
+ SkDebugf("%g, %g, %g, %g\n", leftRect.left(), leftRect.top(),
+ leftRect.right(), leftRect.bottom()); +#StdOut + intersection: 30, 60, 50, 80 +## ## -#ToDo incomplete ## +#SeeAlso intersects Intersects join SkIRect::intersect ## @@ -918,23 +1602,37 @@ If either rectangle is empty, do nothing and return false. #Method bool intersect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) -If this rectangle intersects the rectangle specified by left, top, right, bottom, -return true and set this rectangle to that intersection, otherwise return false -and do not change this rectangle. -If either rectangle is empty, do nothing and return false. +Constructs Rect to intersect from (left, top, right, bottom). Does not sort +construction. -#Param left incomplete ## -#Param top incomplete ## -#Param right incomplete ## -#Param bottom incomplete ## +Returns true if Rect intersects construction, and sets Rect to intersection. +Returns false if Rect does not intersect construction, and leaves Rect unchanged. -#Return incomplete ## +Returns false if either construction or Rect is empty, leaving Rect unchanged. + +#Param left x minimum of constructed Rect ## +#Param top y minimum of constructed Rect ## +#Param right x maximum of constructed Rect ## +#Param bottom y maximum of constructed Rect ## + +#Return true if construction and Rect have area in common ## #Example -// incomplete +#Description +Two SkDebugf calls are required. If the calls are combined, their arguments +may not be evaluated in left to right order: the printed intersection may +be before or after the call to intersect. +## + SkRect leftRect = { 10, 40, 50, 80 };
+ SkDebugf("%s intersection: ", leftRect.intersect(30, 60, 70, 90) ? "" : "no ");
+ SkDebugf("%g, %g, %g, %g\n", leftRect.left(), leftRect.top(),
+ leftRect.right(), leftRect.bottom()); +#StdOut + intersection: 30, 60, 50, 80 +## ## -#ToDo incomplete ## +#SeeAlso intersects Intersects join SkIRect::intersect ## @@ -942,376 +1640,715 @@ If either rectangle is empty, do nothing and return false. #Method bool SK_WARN_UNUSED_RESULT intersect(const SkRect& a, const SkRect& b) -If rectangles a and b intersect, return true and set this rectangle to -that intersection, otherwise return false and do not change this -rectangle. If either rectangle is empty, do nothing and return false. +Returns true if a intersects b, and sets Rect to intersection. +Returns false if a does not intersect b, and leaves Rect unchanged. -#Param a incomplete ## -#Param b incomplete ## +Returns false if either a or b is empty, leaving Rect unchanged. -#Return incomplete ## +#Param a Rect to intersect ## +#Param b Rect to intersect ## + +#Return true if a and b have area in common ## #Example -// incomplete + SkRect result;
+ bool intersected = result.intersect({ 10, 40, 50, 80 }, { 30, 60, 70, 90 });
+ SkDebugf("%s intersection: %g, %g, %g, %g\n", intersected ? "" : "no ",
+ result.left(), result.top(), result.right(), result.bottom());
+#StdOut + intersection: 30, 60, 50, 80 +## ## -#ToDo incomplete ## +#SeeAlso intersects Intersects join SkIRect::intersect ## +# ------------------------------------------------------------------------------ + #Method bool intersects(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) const -Returns true if this rectangle is not empty, and the specified sides of -a rectangle are not empty, and they intersect. +Constructs Rect to intersect from (left, top, right, bottom). Does not sort +construction. -#Param left incomplete ## -#Param top incomplete ## -#Param right incomplete ## -#Param bottom incomplete ## +Returns true if Rect intersects construction. +Returns false if either construction or Rect is empty, or do not intersect. -#Return incomplete ## +#Param left x minimum of constructed Rect ## +#Param top y minimum of constructed Rect ## +#Param right x maximum of constructed Rect ## +#Param bottom y maximum of constructed Rect ## + +#Return true if construction and Rect have area in common ## #Example -// incomplete + SkRect rect = { 10, 40, 50, 80 };
+ SkDebugf("%s intersection", rect.intersects(30, 60, 70, 90) ? "" : "no ");
+#StdOut + intersection +## ## -#SeeAlso incomplete +#SeeAlso intersect Intersects SkIRect::Intersects ## +# ------------------------------------------------------------------------------ + #Method bool intersects(const SkRect& r) const -#Param r incomplete ## +Returns true if Rect intersects r. +Returns false if either r or Rect is empty, or do not intersect. + +#Param r Rect to intersect ## -#Return incomplete ## +#Return true if r and Rect have area in common ## #Example -// incomplete + SkRect rect = { 10, 40, 50, 80 };
+ SkDebugf("%s intersection", rect.intersects({30, 60, 70, 90}) ? "" : "no ");
+#StdOut + intersection +## ## -#SeeAlso incomplete +#SeeAlso intersect Intersects SkIRect::Intersects ## +# ------------------------------------------------------------------------------ + #Method static bool Intersects(const SkRect& a, const SkRect& b) -Returns true if rectangles a and b are not empty and intersect. +Returns true if a intersects b. +Returns false if either a or b is empty, or do not intersect. -#Param a incomplete ## -#Param b incomplete ## +#Param a Rect to intersect ## +#Param b Rect to intersect ## -#Return incomplete ## +#Return true if a and b have area in common ## #Example -// incomplete + SkDebugf("%s intersection", SkRect::Intersects({10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
+#StdOut + intersection +## ## -#SeeAlso incomplete +#SeeAlso intersect intersects SkIRect::Intersects ## +#Topic Intersection ## + + +# ------------------------------------------------------------------------------ #Method void join(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) -Updates rectangle to enclose itself and the specified rectangle. -If this rectangle is empty, just set it to the specified rectangle. -If the specified rectangle is empty, do nothing. +Constructs Rect to intersect from (left, top, right, bottom). Does not sort +construction. + +Sets Rect to the union of itself and the construction. + +Has no effect if construction is empty. Otherwise, if Rect is empty, sets +Rect to construction. -#Param left incomplete ## -#Param top incomplete ## -#Param right incomplete ## -#Param bottom incomplete ## +#Param left x minimum of constructed Rect ## +#Param top y minimum of constructed Rect ## +#Param right x maximum of constructed Rect ## +#Param bottom y maximum of constructed Rect ## #Example -// incomplete + SkRect rect = { 10, 20, 15, 25};
+ rect.join(50, 60, 55, 65);
+ SkDebugf("join: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut + join: 10, 20, 55, 65 +## ## -#SeeAlso incomplete +#SeeAlso joinNonEmptyArg joinPossiblyEmptyRect SkIRect::join ## +# ------------------------------------------------------------------------------ + #Method void join(const SkRect& r) -If this rectangle is empty, just set it to the specified rectangle. If the specified -rectangle is empty, do nothing. +Sets Rect to the union of itself and r. + +Has no effect if r is empty. Otherwise, if Rect is empty, sets +Rect to r. -#Param r incomplete ## +#Param r expansion Rect ## #Example -// incomplete + SkRect rect = { 10, 20, 15, 25};
+ rect.join({50, 60, 55, 65});
+ SkDebugf("join: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut + join: 10, 20, 55, 65 +## ## -#SeeAlso incomplete +#SeeAlso joinNonEmptyArg joinPossiblyEmptyRect SkIRect::join ## +# ------------------------------------------------------------------------------ + #Method void joinNonEmptyArg(const SkRect& r) -#Param r incomplete ## +Sets Rect to the union of itself and r. + +Asserts if r is empty and SK_DEBUG is defined. +If Rect is empty, sets Rect to r. + +May produce incorrect results if r is empty. + +#Param r expansion Rect ## #Example -// incomplete +#Description +Since Rect is not sorted, first result is copy of toJoin. +## + SkRect rect = { 10, 100, 15, 0};
+ SkRect sorted = rect.makeSorted();
+ SkRect toJoin = { 50, 60, 55, 65 };
+ rect.joinNonEmptyArg(toJoin);
+ SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+ sorted.joinNonEmptyArg(toJoin);
+ SkDebugf("sorted: %g, %g, %g, %g\n", sorted.fLeft, sorted.fTop, sorted.fRight, sorted.fBottom); +#StdOut +rect: 50, 60, 55, 65
+sorted: 10, 0, 55, 100 +## ## -#SeeAlso incomplete +#SeeAlso join joinPossiblyEmptyRect SkIRect::join ## +# ------------------------------------------------------------------------------ + #Method void joinPossiblyEmptyRect(const SkRect& r) -Joins the rectangle with another without checking if either are empty (may produce unexpected -results if either rectangle is inverted). +Sets Rect to the union of itself and the construction. + +May produce incorrect results if Rect or r is empty. -#Param r incomplete ## +#Param r expansion Rect ## #Example -// incomplete +#Description +Since Rect is not sorted, first result is not useful. +## + SkRect rect = { 10, 100, 15, 0};
+ SkRect sorted = rect.makeSorted();
+ SkRect toJoin = { 50, 60, 55, 65 };
+ rect.joinPossiblyEmptyRect(toJoin);
+ SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+ sorted.joinPossiblyEmptyRect(toJoin);
+ SkDebugf("sorted: %g, %g, %g, %g\n", sorted.fLeft, sorted.fTop, sorted.fRight, sorted.fBottom);
+#StdOut +rect: 10, 60, 55, 65
+sorted: 10, 0, 55, 100 +## ## -#SeeAlso incomplete +#SeeAlso joinNonEmptyArg join SkIRect::join ## +# ------------------------------------------------------------------------------ + #Method void growToInclude(SkPoint pt) -Grows rectangle to include the specified (x,y). After this call, the -following will be true: fLeft <= x <= fRight && fTop <= y <= fBottom. +Grows Rect to include (pt.fX, pt.fY), modifying it so that: +#Formula +fLeft <= pt.fX <= fRight && fTop <= pt.fY <= fBottom +## +. -This is close, but not quite the same contract as contains(), since -contains() treats the left and top different from the right and bottom. -contains(x,y) -> fLeft <= x < fRight && fTop <= y < fBottom. Also note -that contains(x,y) always returns false if the rectangle is empty. +If Rect is initialized with setLargestInverted, then Rect will contain bounds of +Points after one or more calls. In this case, Rect is empty after first call. -#Param pt incomplete ## +#Param pt Point to include ## #Example -// incomplete + SkRect rect;
+ rect.setLargestInverted();
+ rect.growToInclude( { 42, 24 } );
+ SkDebugf("rect: %g, %g, %g, %g ", rect.left(), rect.top(), rect.right(), rect.bottom());
+ SkDebugf("isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
+#StdOut +rect: 42, 24, 42, 24 isEmpty: true +## ## -#SeeAlso incomplete +#SeeAlso setLargestInverted join ## +# ------------------------------------------------------------------------------ + #Method void growToInclude(const SkPoint pts[], int count) -Bulk version of growToInclude +For each of count Point in pts, grows Rect to include (pt.fX, pt.fY), modifying +it so that: +#Formula +fLeft <= pt.fX <= fRight && fTop <= pt.fY <= fBottom +## +. + +If Rect is initialized with setLargestInverted, then Rect will contain bounds of +Points after one or more calls. In this case, Rect is empty after first call. -#Param pts incomplete ## -#Param count incomplete ## +#Param pts Point array ## +#Param count number of points in array ## #Example -// incomplete + SkPoint pts[] = { { 30, 50 }, { 40, 50 }, { 30, 60 } };
+ SkRect rect = { pts[0].fX, pts[0].fY, pts[0].fX, pts[0].fY };
+ rect.growToInclude( pts[1] );
+ rect.growToInclude( pts[2] );
+ SkDebugf("rect: %g, %g, %g, %g ", rect.left(), rect.top(), rect.right(), rect.bottom());
+#StdOut +rect: 30, 50, 40, 60 +## ## -#SeeAlso incomplete +#SeeAlso setLargestInverted join ## +# ------------------------------------------------------------------------------ + #Method void growToInclude(const SkPoint pts[], size_t stride, int count) -Bulk version of growToInclude with stride. +For each of count Point in pts, grows Rect to include (pt.fX, pt.fY), modifying +it so that: +#Formula +fLeft <= pt.fX <= fRight && fTop <= pt.fY <= fBottom +## +. Point may be followed with other data in each array element. stride is number + of bytes in element; the interval to skip to advance from one Point to +the next. + +If Rect is initialized with setLargestInverted, then Rect will contain bounds of +Points after one or more calls. In this case, Rect is empty after first call. -#Param pts incomplete ## -#Param stride incomplete ## -#Param count incomplete ## +#Param pts array of elements beginning with Point ## +#Param stride size of pts elements in 32-bit words; zero or greater ## +#Param count number of elements in array ## +#Bug 7142 ## #Example -// incomplete + SkPoint3 pts[] = { { 30, 50, -1 }, { 40, 50, -1 }, { 30, 60, -1 } };
+ SkRect rect;
+ rect.setLargestInverted();
+ rect.growToInclude((SkPoint* ) &pts[0].fX, sizeof(SkPoint3), SK_ARRAY_COUNT(pts));
+ SkDebugf("rect: %g, %g, %g, %g ", rect.left(), rect.top(), rect.right(), rect.bottom());
+#StdOut +#Volatile +rect: 30, 50, 40, 60 +## ## -#SeeAlso incomplete +#SeeAlso setLargestInverted join ## +# ------------------------------------------------------------------------------ + #Method bool contains(const SkRect& r) const { -Return true if this rectangle contains r, and if both rectangles are -not empty. +Returns true if Rect contains r. +Returns false if Rect is empty or r is empty. -#Param r incomplete ## +Rect contains r when Rect area completely includes r area. -#Return incomplete ## +#Param r Rect contained ## + +#Return true if all sides of Rect are outside r ## #Example -// incomplete + SkRect rect = { 30, 50, 40, 60 };
+ SkRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
+ for (auto contained : tests) {
+ SkDebugf("rect: (%g, %g, %g, %g) %s (%g, %g, %g, %g)\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom(),
+ rect.contains(contained) ? "contains" : "does not contain",
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ }
+#StdOut
+rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
+rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
+rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
+##
## -#SeeAlso incomplete +#SeeAlso SkIRect::contains ## +# ------------------------------------------------------------------------------ + #Method bool contains(const SkIRect& r) const -Returns true if the specified rectangle r is inside or equal to this rectangle. +Returns true if Rect contains r. +Returns false if Rect is empty or r is empty. -#Param r incomplete ## +Rect contains r when Rect area completely includes r area. -#Return incomplete ## +#Param r IRect contained ## + +#Return true if all sides of Rect are outside r ## #Example -// incomplete + SkRect rect = { 30, 50, 40, 60 };
+ SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
+ for (auto contained : tests) {
+ SkDebugf("rect: (%g, %g, %g, %g) %s (%d, %d, %d, %d)\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom(),
+ rect.contains(contained) ? "contains" : "does not contain",
+ contained.left(), contained.top(), contained.right(), contained.bottom());
+ }
+#StdOut
+rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
+rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
+rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
+##
## -#SeeAlso incomplete +#SeeAlso SkIRect::contains ## +#Topic Round + +# ------------------------------------------------------------------------------ + #Method void round(SkIRect* dst) const -Sets dst rectangle by rounding this rectangle coordinates to their -nearest integer values using SkScalarRoundToInt. +Sets IRect by adding 0.5 and discarding the fractional portion of Rect +members, using +#Formula +(SkScalarRoundToInt(fLeft), SkScalarRoundToInt(fTop), + SkScalarRoundToInt(fRight), SkScalarRoundToInt(fBottom)) +## +. -#Param dst incomplete ## +#Param dst storage for IRect ## #Example -// incomplete + SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f };
+ SkIRect round;
+ rect.round(&round);
+ SkDebugf("round: %d, %d, %d, %d\n", round.fLeft, round.fTop, round.fRight, round.fBottom);
+#StdOut +round: 31, 51, 41, 61 +## ## -#SeeAlso incomplete +#SeeAlso roundIn roundOut SkScalarRoundToInt ## +# ------------------------------------------------------------------------------ + #Method void roundOut(SkIRect* dst) const -Sets dst rectangle by rounding "out" this rectangle, choosing the -SkScalarFloorToInt of top and left, and the SkScalarCeilToInt of right and bottom. +Sets IRect by discarding the fractional portion of fLeft and fTop; and +rounding up fRight and FBottom, using +#Formula +(SkScalarFloorToInt(fLeft), SkScalarFloorToInt(fTop), + SkScalarCeilToInt(fRight), SkScalarCeilToInt(fBottom)) +## +. -#Param dst incomplete ## +#Param dst storage for IRect ## #Example -// incomplete + SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f };
+ SkIRect round;
+ rect.roundOut(&round);
+ SkDebugf("round: %d, %d, %d, %d\n", round.fLeft, round.fTop, round.fRight, round.fBottom);
+#StdOut +round: 30, 50, 41, 61 +## ## -#SeeAlso incomplete +#SeeAlso roundIn round SkScalarRoundToInt ## -#Method void roundOut(SkRect* dst) const +# ------------------------------------------------------------------------------ -Sets the dst rectangle by rounding "out" this rectangle, choosing the -SkScalarFloorToScalar of top and left, and the SkScalarCeilToScalar of right and bottom. +#Method void roundOut(SkRect* dst) const -It is safe for this to equal dst. +Sets Rect by discarding the fractional portion of fLeft and fTop; and +rounding up fRight and FBottom, using +#Formula +(SkScalarFloorToInt(fLeft), SkScalarFloorToInt(fTop), + SkScalarCeilToInt(fRight), SkScalarCeilToInt(fBottom)) +## +. -#Param dst incomplete ## +#Param dst storage for Rect ## #Example -// incomplete + SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f };
+ SkRect round;
+ rect.roundOut(&round);
+ SkDebugf("round: %g, %g, %g, %g\n", round.fLeft, round.fTop, round.fRight, round.fBottom);
+#StdOut +round: 30, 50, 41, 61 +## ## -#SeeAlso incomplete +#SeeAlso roundIn round SkScalarRoundToInt ## +# ------------------------------------------------------------------------------ + #Method void roundIn(SkIRect* dst) const -Set the dst rectangle by rounding "in" this rectangle, choosing the -ceil() of top and left, and the floor of right and bottom. This does *not* -call sort(), so it is possible that the resulting rectangle is inverted; -either left >= right or top >= bottom. Call isEmpty() to detect that. +Sets Rect by rounding up fLeft and fTop; and +discarding the fractional portion of fRight and FBottom, using +#Formula +(SkScalarCeilToInt(fLeft), SkScalarCeilToInt(fTop), + SkScalarFloorToInt(fRight), SkScalarFloorToInt(fBottom)) +## +. -#Param dst incomplete ## +#Param dst storage for IRect ## #Example -// incomplete + SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f };
+ SkIRect round;
+ rect.roundIn(&round);
+ SkDebugf("round: %d, %d, %d, %d\n", round.fLeft, round.fTop, round.fRight, round.fBottom);
+#StdOut +round: 31, 51, 40, 60
+## ## -#SeeAlso incomplete +#SeeAlso roundOut round SkScalarRoundToInt ## +# ------------------------------------------------------------------------------ + #Method SkIRect round() const -Returns the result of calling round(&dst) +Returns IRect by adding 0.5 and discarding the fractional portion of Rect +members, using +#Formula +(SkScalarRoundToInt(fLeft), SkScalarRoundToInt(fTop), + SkScalarRoundToInt(fRight), SkScalarRoundToInt(fBottom)) +## +. -#Return incomplete ## +#Return rounded IRect ## #Example -// incomplete + SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f };
+ SkIRect round = rect.round();
+ SkDebugf("round: %d, %d, %d, %d\n", round.fLeft, round.fTop, round.fRight, round.fBottom);
+#StdOut +round: 31, 51, 41, 61
+## ## -#SeeAlso incomplete +#SeeAlso roundOut roundIn SkScalarRoundToInt ## +# ------------------------------------------------------------------------------ + #Method SkIRect roundOut() const -Returns the result of calling roundOut(&dst) +Sets IRect by discarding the fractional portion of fLeft and fTop; and +rounding up fRight and FBottom, using +#Formula +(SkScalarFloorToInt(fLeft), SkScalarFloorToInt(fTop), + SkScalarCeilToInt(fRight), SkScalarCeilToInt(fBottom)) +## +. -#Return incomplete ## +#Return rounded IRect ## #Example -// incomplete + SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f };
+ SkIRect round = rect.roundOut();
+ SkDebugf("round: %d, %d, %d, %d\n", round.fLeft, round.fTop, round.fRight, round.fBottom);
+#StdOut +round: 30, 50, 41, 61
+## ## -#SeeAlso incomplete +#SeeAlso round roundIn SkScalarRoundToInt ## +#Topic Round ## + +# ------------------------------------------------------------------------------ + #Method void sort() -Swaps top/bottom or left/right if there are flipped; if width() -or height() would have returned a negative value. This should be called -if the edges are computed separately, and may have crossed over each -other. When this returns, left <= right && top <= bottom +Swaps fLeft and fRight if fLeft is greater than fRight; and swaps +fTop and fBottom if fTop is greater than fBottom. Result may be empty; +and width() and height() will be zero or positive. #Example -// incomplete + SkRect rect = { 30.5f, 50.5f, 20.5f, 10.5f };
+ SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+ rect.sort();
+ SkDebugf("sorted: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+#StdOut +rect: 30.5, 50.5, 20.5, 10.5
+sorted: 20.5, 10.5, 30.5, 50.5 +## ## -#SeeAlso incomplete +#SeeAlso makeSorted SkIRect::sort ## +# ------------------------------------------------------------------------------ + #Method SkRect makeSorted() const -Returns a new Rect that is the sorted version of this rectangle (left <= right, top <= bottom). +Returns Rect with fLeft and fRight swapped if fLeft is greater than fRight; and +with fTop and fBottom swapped if fTop is greater than fBottom. Result may be empty; +and width() and height() will be zero or positive. -#Return incomplete ## +#Return sorted Rect ## #Example -// incomplete + SkRect rect = { 30.5f, 50.5f, 20.5f, 10.5f };
+ SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+ SkRect sort = rect.makeSorted();
+ SkDebugf("sorted: %g, %g, %g, %g\n", sort.fLeft, sort.fTop, sort.fRight, sort.fBottom);
+#StdOut +rect: 30.5, 50.5, 20.5, 10.5
+sorted: 20.5, 10.5, 30.5, 50.5 +## ## -#SeeAlso incomplete +#SeeAlso sort SkIRect::makeSorted ## +# ------------------------------------------------------------------------------ + #Method const SkScalar* asScalars() const -Cast-safe way to treat the rectangle as a SkScalar array with four entries. +Returns pointer to first Scalar in Rect, to treat it as an array with four +entries. -#Return incomplete ## +#Return pointer to fLeft ## #Example -// incomplete + SkRect rect = {7, 11, 13, 17};
+SkDebugf("rect.asScalars() %c= &rect.fLeft\n", rect.asScalars() == &rect.fLeft? '=' : '!');
+#StdOut
+rect.asScalars() == &rect.fLeft
+##
## +#SeeAlso toQuad + ## +# ------------------------------------------------------------------------------ + #Method void dump(bool asHex) const -#Param asHex incomplete ## +Writes text representation of Rect to standard output. Set asHex to true to +generate exact binary representations of floating point numbers. + +#Param asHex true if SkScalar values are written as hexadecimal ## #Example -// incomplete + SkRect rect = {20, 30, 40, 50}; + for (bool dumpAsHex : { false, true } ) { + rect.dump(dumpAsHex); + SkDebugf("\n"); + } +#StdOut +SkRect::MakeLTRB(20, 30, 40, 50);
+
+SkRect::MakeLTRB(SkBits2Float(0x41a00000), /* 20.000000 */
+ SkBits2Float(0x41f00000), /* 30.000000 */
+ SkBits2Float(0x42200000), /* 40.000000 */
+ SkBits2Float(0x42480000) /* 50.000000 */);
## +## + +#SeeAlso dumpHex ## +# ------------------------------------------------------------------------------ + #Method void dump() const +Writes text representation of Rect to standard output. The representation may be +directly compiled as C++ code. Floating point values are written +with limited precision; it may not be possible to reconstruct original Rect +from output. + #Example -// incomplete +SkRect rect = {6.f / 7, 2.f / 3, 26.f / 10, 42.f / 6};
+rect.dump();
+SkRect copy = SkRect::MakeLTRB(0.857143f, 0.666667f, 2.6f, 7);
+SkDebugf("rect is " "%s" "equal to copy\n", rect == copy ? "" : "not ");
+#StdOut +SkRect::MakeLTRB(0.857143f, 0.666667f, 2.6f, 7);
+rect is not equal to copy ## +## + +#SeeAlso dumpHex ## +# ------------------------------------------------------------------------------ + #Method void dumpHex() const +Writes text representation of Rect to standard output. The representation may be +directly compiled as C++ code. Floating point values are written +in hexadecimal to preserve their exact bit pattern. The output reconstructs the +original Rect. + +Use instead of dump() when submitting +#A bug reports against Skia # http://bug.skia.org ## +. + #Example -// incomplete + SkRect rect = {6.f / 7, 2.f / 3, 26.f / 10, 42.f / 6};
+rect.dumpHex();
+SkRect copy = SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
+ SkBits2Float(0x3f2aaaab), /* 0.666667 */
+ SkBits2Float(0x40266666), /* 2.600000 */
+ SkBits2Float(0x40e00000) /* 7.000000 */);
+SkDebugf("rect is " "%s" "equal to copy\n", rect == copy ? "" : "not "); +#StdOut +SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
+ SkBits2Float(0x3f2aaaab), /* 0.666667 */
+ SkBits2Float(0x40266666), /* 2.600000 */
+ SkBits2Float(0x40e00000) /* 7.000000 */);
+rect is equal to copy ## +## + +#SeeAlso dump ## diff --git a/docs/undocumented.bmh b/docs/undocumented.bmh index d66bcf87af..d6a77b9743 100644 --- a/docs/undocumented.bmh +++ b/docs/undocumented.bmh @@ -168,6 +168,11 @@ FT_Load_Glyph #Topic Data ## +#Topic Debugging +#Method SK_API void SkDebugf(const char format[], ...) +## +## + #Topic Device #Class SkBaseDevice ## @@ -416,6 +421,12 @@ FT_Load_Glyph ## #Method SkScalarCeilToScalar(x) ## + #Method SkScalarIsFinite(x) + ## + #Method SkScalarIsNaN(x) + ## + #Method template <typename D, typename S> inline bool SkTFitsIn(S s) + ## ## #Topic Mip_Map @@ -427,8 +438,14 @@ FT_Load_Glyph #Topic Number_Types #Typedef SkGlyphID #Typedef ## + #Topic Scalar + #Alias Scalar #Typedef SkScalar #Typedef ## + ## + #Const SK_ScalarMin + to be written + ## #Const SK_ScalarMax to be written ## @@ -441,6 +458,12 @@ FT_Load_Glyph #Const SK_ScalarNaN to be written ## + #Const SK_MinS32 + to be written + ## + #Const SK_MaxS32 + to be written + ## #Typedef SkUnichar #Typedef ## #Typedef U8CPU diff --git a/site/user/api/SkIRect_Reference.md b/site/user/api/SkIRect_Reference.md new file mode 100644 index 0000000000..c7c643103b --- /dev/null +++ b/site/user/api/SkIRect_Reference.md @@ -0,0 +1,2197 @@ +SkIRect Reference +=== + +# <a name="IRect"></a> IRect + +# <a name="SkIRect"></a> Struct SkIRect +<a href="#SkIRect">SkIRect</a> holds four 32 bit integer coordinates describing the upper and +lower bounds of a rectangle. <a href="#SkIRect">SkIRect</a> may be created from outer bounds or +from position, <a href="#SkIRect_width">width</a>, and <a href="#SkIRect_height">height</a>. <a href="#SkIRect">SkIRect</a> describes an area; if its <a href="#SkIRect_right">right</a> +is less than or equal to its <a href="#SkIRect_left">left</a>, or if its <a href="#SkIRect_bottom">bottom</a> is less than or equal to +its <a href="#SkIRect_top">top</a>, it is considered empty. + +# <a name="Overview"></a> Overview + +## <a name="Subtopics"></a> Subtopics + +| topics | description | +| --- | --- | + +## <a name="Operators"></a> Operators + +| description | function | +| --- | --- | +| friend bool <a href="#SkIRect_not_equal_operator">operator!=(const SkIRect& a, const SkIRect& b)</a> | Returns true if members are unequal. | +| friend bool <a href="#SkIRect_equal_operator">operator==(const SkIRect& a, const SkIRect& b)</a> | Returns true if members are equal. | + +## <a name="Member_Functions"></a> Member Functions + +| description | function | +| --- | --- | +| <a href="#SkIRect_EmptyIRect">EmptyIRect</a> | Returns immutable bounds of (0, 0, 0, 0). | +| <a href="#SkIRect_Intersects">Intersects</a> | Returns true if areas overlap. | +| <a href="#SkIRect_IntersectsNoEmptyCheck">IntersectsNoEmptyCheck</a> | Returns true if areas overlap. Skips empty check. | +| <a href="#SkIRect_MakeEmpty">MakeEmpty</a> | Returns bounds of (0, 0, 0, 0). | +| <a href="#SkIRect_MakeLTRB">MakeLTRB</a> | Constructs from int <a href="#SkIRect_left">left</a>, <a href="#SkIRect_top">top</a>, <a href="#SkIRect_right">right</a>, <a href="#SkIRect_bottom">bottom</a>. | +| <a href="#SkIRect_MakeLargest">MakeLargest</a> | Constructs from (<a href="undocumented#SK_MinS32">SK MinS32</a>, <a href="undocumented#SK_MinS32">SK MinS32</a>, <a href="undocumented#SK_MaxS32">SK MaxS32</a>, <a href="undocumented#SK_MaxS32">SK MaxS32</a>). | +| <a href="#SkIRect_MakeSize">MakeSize</a> | Constructs from <a href="#Size">ISize</a> returning (0, 0, <a href="#SkIRect_width">width</a>, <a href="#SkIRect_height">height</a>). | +| <a href="#SkIRect_MakeWH">MakeWH</a> | Constructs from int input returning (0, 0, <a href="#SkIRect_width">width</a>, <a href="#SkIRect_height">height</a>). | +| <a href="#SkIRect_MakeXYWH">MakeXYWH</a> | Constructs from int input returning (<a href="#SkIRect_x">x</a>, <a href="#SkIRect_y">y</a>, <a href="#SkIRect_width">width</a>, <a href="#SkIRect_height">height</a>). | +| <a href="#SkIRect_bottom">bottom</a> | Returns larger bounds in <a href="#SkIRect_y">y</a>, if sorted. | +| <a href="#SkIRect_centerX">centerX</a> | Returns midpoint in <a href="#SkIRect_x">x</a>. | +| <a href="#SkIRect_centerY">centerY</a> | Returns midpoint in <a href="#SkIRect_y">y</a>. | +| <a href="#SkIRect_contains">contains</a> | Returns true if points are equal or inside. | +| <a href="#SkIRect_containsNoEmptyCheck">containsNoEmptyCheck</a> | Returns true if points are equal or inside. Skips empty check. | +| <a href="#SkIRect_height">height</a> | Returns span in <a href="#SkIRect_y">y</a>. | +| <a href="#SkIRect_inset">inset</a> | Moves the sides symmetrically about the center. | +| <a href="#SkIRect_intersect">intersect</a> | Sets to shared area; returns true if not empty. | +| <a href="#SkIRect_intersectNoEmptyCheck">intersectNoEmptyCheck</a> | Sets to shared area; returns true if not empty. Skips empty check. | +| <a href="#SkIRect_is16Bit">is16Bit</a> | Returns true if members fit in 16-bit word. | +| <a href="#SkIRect_isEmpty">isEmpty</a> | Returns true if <a href="#SkIRect_width">width</a> or <a href="#SkIRect_height">height</a> are zero or negative. | +| <a href="#SkIRect_isLargest">isLargest</a> | Returns true if equal to (<a href="undocumented#SK_MinS32">SK MinS32</a>, <a href="undocumented#SK_MinS32">SK MinS32</a>, <a href="undocumented#SK_MaxS32">SK MaxS32</a>, <a href="undocumented#SK_MaxS32">SK MaxS32</a>). | +| <a href="#SkIRect_join">join</a> | Sets to union of bounds. | +| <a href="#SkIRect_left">left</a> | Returns smaller bounds in <a href="#SkIRect_x">x</a>, if sorted. | +| <a href="#SkIRect_makeInset">makeInset</a> | Constructs from sides moved symmetrically about the center. | +| <a href="#SkIRect_makeOffset">makeOffset</a> | Constructs from translated sides. | +| <a href="#SkIRect_makeOutset">makeOutset</a> | Constructs from sides moved symmetrically about the center. | +| <a href="#SkIRect_makeSorted">makeSorted</a> | Constructs, ordering sides from smaller to larger. | +| <a href="#SkIRect_offset">offset</a> | Translates sides without changing <a href="#SkIRect_width">width</a> and <a href="#SkIRect_height">height</a>. | +| <a href="#SkIRect_offsetTo">offsetTo</a> | Translates to (<a href="#SkIRect_x">x</a>, <a href="#SkIRect_y">y</a>) without changing <a href="#SkIRect_width">width</a> and <a href="#SkIRect_height">height</a>. | +| <a href="#SkIRect_outset">outset</a> | Moves the sides symmetrically about the center. | +| <a href="#SkIRect_quickReject">quickReject</a> | Returns true if rectangles do not <a href="#SkIRect_intersect">intersect</a>. | +| <a href="#SkIRect_right">right</a> | Returns larger bounds in <a href="#SkIRect_x">x</a>, if sorted. | +| <a href="#SkIRect_set">set</a> | Sets to (<a href="#SkIRect_left">left</a>, <a href="#SkIRect_top">top</a>, <a href="#SkIRect_right">right</a>, <a href="#SkIRect_bottom">bottom</a>). | +| <a href="#SkIRect_setEmpty">setEmpty</a> | Sets to (0, 0, 0, 0). | +| <a href="#SkIRect_setLTRB">setLTRB</a> | Sets to <a href="undocumented#SkScalar">SkScalar</a> input (<a href="#SkIRect_left">left</a>, <a href="#SkIRect_top">top</a>, <a href="#SkIRect_right">right</a>, <a href="#SkIRect_bottom">bottom</a>). | +| <a href="#SkIRect_setLargest">setLargest</a> | Sets to (<a href="undocumented#SK_MinS32">SK MinS32</a>, <a href="undocumented#SK_MinS32">SK MinS32</a>, <a href="undocumented#SK_MaxS32">SK MaxS32</a>, <a href="undocumented#SK_MaxS32">SK MaxS32</a>). | +| <a href="#SkIRect_setLargestInverted">setLargestInverted</a> | Sets to (<a href="undocumented#SK_MaxS32">SK MaxS32</a>, <a href="undocumented#SK_MaxS32">SK MaxS32</a>, <a href="undocumented#SK_MinS32">SK MinS32</a>, <a href="undocumented#SK_MinS32">SK MinS32</a>). | +| <a href="#SkIRect_setXYWH">setXYWH</a> | Sets to (<a href="#SkIRect_x">x</a>, <a href="#SkIRect_y">y</a>, <a href="#SkIRect_width">width</a>, <a href="#SkIRect_height">height</a>). | +| <a href="#SkIRect_size">size</a> | Returns <a href="#Size">ISize</a> (<a href="#SkIRect_width">width</a>, <a href="#SkIRect_height">height</a>). | +| <a href="#SkIRect_sort">sort</a> | Orders sides from smaller to larger. | +| <a href="#SkIRect_top">top</a> | Returns smaller bounds in <a href="#SkIRect_y">y</a>, if sorted. | +| <a href="#SkIRect_width">width</a> | Returns span in <a href="#SkIRect_x">x</a>. | +| <a href="#SkIRect_x">x</a> | Returns bounds <a href="#SkIRect_left">left</a>. | +| <a href="#SkIRect_y">y</a> | Returns bounds <a href="#SkIRect_top">top</a>. | + +<a name="SkIRect_fLeft"> <code><strong>int32_t fLeft</strong></code> </a> + +May contain any value. The smaller of the horizontal values when sorted. +When equal to or greater than <a href="#SkIRect_fRight">fRight</a>, <a href="#IRect">IRect</a> is empty. + +<a name="SkIRect_fTop"> <code><strong>int32_t fTop</strong></code> </a> + +May contain any value. The smaller of the horizontal values when sorted. +When equal to or greater than <a href="#SkIRect_fBottom">fBottom</a>, <a href="#IRect">IRect</a> is empty. + +<a name="SkIRect_fRight"> <code><strong>int32_t fRight</strong></code> </a> + +May contain any value. The larger of the vertical values when sorted. +When equal to or less than <a href="#SkIRect_fLeft">fLeft</a>, <a href="#IRect">IRect</a> is empty. + +<a name="SkIRect_fBottom"> <code><strong>int32_t fBottom</strong></code> </a> + +May contain any value. The larger of the vertical values when sorted. +When equal to or less than <a href="#SkIRect_fTop">fTop</a>, <a href="#IRect">IRect</a> is empty. + +<a name="SkIRect_MakeEmpty"></a> +## MakeEmpty + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static SkIRect SK_WARN_UNUSED_RESULT MakeEmpty() +</pre> + +Returns constructed <a href="#IRect">IRect</a> <a href="#SkIRect_set">set</a> to (0, 0, 0, 0). +Many other rectangles are empty; if <a href="#SkIRect_left">left</a> is equal to or greater than <a href="#SkIRect_right">right</a>, +or if <a href="#SkIRect_top">top</a> is equal to or greater than <a href="#SkIRect_bottom">bottom</a>. Setting all members to zero +is a convenience, but does not designate a special empty rectangle. + +### Return Value + +bounds (0, 0, 0, 0) + +### Example + +<div><fiddle-embed name="0ade3971c1d2616564992e286966ec8a"> + +#### Example Output + +~~~~ +MakeEmpty isEmpty: true +offset rect isEmpty: true +inset rect isEmpty: true +outset rect isEmpty: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_EmptyIRect">EmptyIRect</a> <a href="#SkIRect_isEmpty">isEmpty</a> <a href="#SkIRect_setEmpty">setEmpty</a> <a href="#SkIRect_setLargestInverted">setLargestInverted</a> <a href="#SkRect_MakeEmpty">SkRect::MakeEmpty</a> + +--- + +<a name="SkIRect_MakeLargest"></a> +## MakeLargest + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static SkIRect SK_WARN_UNUSED_RESULT MakeLargest() +</pre> + +Returns constructed <a href="#IRect">IRect</a> setting <a href="#SkIRect_left">left</a> and <a href="#SkIRect_top">top</a> to most negative value, and +setting <a href="#SkIRect_right">right</a> and <a href="#SkIRect_bottom">bottom</a> to most positive value. + +### Return Value + +bounds (<a href="undocumented#SK_MinS32">SK MinS32</a>, <a href="undocumented#SK_MinS32">SK MinS32</a>, <a href="undocumented#SK_MaxS32">SK MaxS32</a>, <a href="undocumented#SK_MaxS32">SK MaxS32</a>) + +### Example + +<div><fiddle-embed name="2b32ed04a64cd3d5fb525d404cbb9a09"> + +#### Example Output + +~~~~ +MakeLargest isLargest: true +MakeLargest isEmpty: false +outset isLargest: false +outset isEmpty: true +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_isLargest">isLargest</a> <a href="#SkIRect_setLargest">setLargest</a> <a href="#SkRect_MakeLargest">SkRect::MakeLargest</a> + +--- + +<a name="SkIRect_MakeWH"></a> +## MakeWH + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static SkIRect SK_WARN_UNUSED_RESULT MakeWH(int32_t w, int32_t h) +</pre> + +Returns constructed <a href="#IRect">IRect</a> <a href="#SkIRect_set">set</a> to (0, 0, <a href="#SkIRect_MakeWH_w">w</a>, <a href="#SkIRect_MakeWH_h">h</a>). Does not validate input; <a href="#SkIRect_MakeWH_w">w</a> or <a href="#SkIRect_MakeWH_h">h</a> +may be negative. + +### Parameters + +<table> <tr> <td><a name="SkIRect_MakeWH_w"> <code><strong>w </strong></code> </a></td> <td> +<a href="#SkIRect_width">width</a> of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkIRect_MakeWH_h"> <code><strong>h </strong></code> </a></td> <td> +<a href="#SkIRect_height">height</a> of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> +</table> + +### Return Value + +bounds (0, 0, <a href="#SkIRect_MakeWH_w">w</a>, <a href="#SkIRect_MakeWH_h">h</a>) + +### Example + +<div><fiddle-embed name="e36827a1a6ae2b1c26e7a8a08f325a07"> + +#### Example Output + +~~~~ +all equal +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_MakeSize">MakeSize</a> <a href="#SkIRect_MakeXYWH">MakeXYWH</a> <a href="#SkRect_MakeWH">SkRect::MakeWH</a> <a href="#SkRect_MakeIWH">SkRect::MakeIWH</a> + +--- + +<a name="SkIRect_MakeSize"></a> +## MakeSize + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static SkIRect SK_WARN_UNUSED_RESULT MakeSize(const SkISize& size) +</pre> + +Returns constructed <a href="#IRect">IRect</a> <a href="#SkIRect_set">set</a> to (0, 0, <a href="#SkIRect_size">size</a>.<a href="#SkIRect_width">width</a>, <a href="#SkIRect_size">size</a>.<a href="#SkIRect_height">height</a>). +Does not validate input; <a href="#SkIRect_size">size</a>.<a href="#SkIRect_width">width</a> or <a href="#SkIRect_size">size</a>.<a href="#SkIRect_height">height</a> may be negative. + +### Parameters + +<table> <tr> <td><a name="SkIRect_MakeSize_size"> <code><strong>size </strong></code> </a></td> <td> +values for <a href="SkRect_Reference#Rect">Rect</a> <a href="#SkIRect_width">width</a> and <a href="#SkIRect_height">height</a></td> + </tr> +</table> + +### Return Value + +bounds (0, 0, <a href="#SkIRect_size">size</a>.<a href="#SkIRect_width">width</a>, <a href="#SkIRect_size">size</a>.<a href="#SkIRect_height">height</a>) + +### Example + +<div><fiddle-embed name="c6586ff8d24869c780169b0d19c75df6"> + +#### Example Output + +~~~~ +round width: 26 height: 36 +floor width: 25 height: 35 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_MakeWH">MakeWH</a> <a href="#SkIRect_MakeXYWH">MakeXYWH</a> <a href="#SkRect_Make">SkRect::Make</a> <a href="#SkRect_MakeIWH">SkRect::MakeIWH</a> + +--- + +<a name="SkIRect_MakeLTRB"></a> +## MakeLTRB + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static SkIRect SK_WARN_UNUSED_RESULT MakeLTRB(int32_t l, int32_t t, int32_t r, + int32_t b) +</pre> + +Returns constructed <a href="#IRect">IRect</a> <a href="#SkIRect_set">set</a> to (<a href="#SkIRect_MakeLTRB_l">l</a>, <a href="#SkIRect_MakeLTRB_t">t</a>, <a href="#SkIRect_MakeLTRB_r">r</a>, <a href="#SkIRect_MakeLTRB_b">b</a>). Does not <a href="#SkIRect_sort">sort</a> input; <a href="SkRect_Reference#Rect">Rect</a> may +result in <a href="#SkIRect_fLeft">fLeft</a> greater than <a href="#SkIRect_fRight">fRight</a>, or <a href="#SkIRect_fTop">fTop</a> greater than <a href="#SkIRect_fBottom">fBottom</a>. + +### Parameters + +<table> <tr> <td><a name="SkIRect_MakeLTRB_l"> <code><strong>l </strong></code> </a></td> <td> +integer stored in <a href="#SkIRect_fLeft">fLeft</a></td> + </tr> <tr> <td><a name="SkIRect_MakeLTRB_t"> <code><strong>t </strong></code> </a></td> <td> +integer stored in <a href="#SkIRect_fTop">fTop</a></td> + </tr> <tr> <td><a name="SkIRect_MakeLTRB_r"> <code><strong>r </strong></code> </a></td> <td> +integer stored in <a href="#SkIRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkIRect_MakeLTRB_b"> <code><strong>b </strong></code> </a></td> <td> +integer stored in <a href="#SkIRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Return Value + +bounds (<a href="#SkIRect_MakeLTRB_l">l</a>, <a href="#SkIRect_MakeLTRB_t">t</a>, <a href="#SkIRect_MakeLTRB_r">r</a>, <a href="#SkIRect_MakeLTRB_b">b</a>) + +### Example + +<div><fiddle-embed name="ec1473b700c594f2df9749a12a06b89b"> + +#### Example Output + +~~~~ +rect: 5, 35, 15, 25 isEmpty: true +rect: 5, 25, 15, 35 isEmpty: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_MakeXYWH">MakeXYWH</a> <a href="#SkRect_MakeLTRB">SkRect::MakeLTRB</a> + +--- + +<a name="SkIRect_MakeXYWH"></a> +## MakeXYWH + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static SkIRect SK_WARN_UNUSED_RESULT MakeXYWH(int32_t x, int32_t y, int32_t w, + int32_t h) +</pre> + +Returns constructed <a href="#IRect">IRect</a> <a href="#SkIRect_set">set</a> to(<a href="#SkIRect_x">x</a>, <a href="#SkIRect_y">y</a>, <a href="#SkIRect_x">x</a> + <a href="#SkIRect_MakeXYWH_w">w</a>, <a href="#SkIRect_y">y</a> + <a href="#SkIRect_MakeXYWH_h">h</a>). +Does not validate input; +<a href="#SkIRect_MakeXYWH_w">w</a> or <a href="#SkIRect_MakeXYWH_h">h</a> may be negative. + +### Parameters + +<table> <tr> <td><a name="SkIRect_MakeXYWH_x"> <code><strong>x </strong></code> </a></td> <td> +stored in <a href="#SkIRect_fLeft">fLeft</a></td> + </tr> <tr> <td><a name="SkIRect_MakeXYWH_y"> <code><strong>y </strong></code> </a></td> <td> +stored in <a href="#SkIRect_fTop">fTop</a></td> + </tr> <tr> <td><a name="SkIRect_MakeXYWH_w"> <code><strong>w </strong></code> </a></td> <td> +added to <a href="#SkIRect_x">x</a> and stored in <a href="#SkIRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkIRect_MakeXYWH_h"> <code><strong>h </strong></code> </a></td> <td> +added to <a href="#SkIRect_y">y</a> and stored in <a href="#SkIRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Return Value + +bounds (<a href="#SkIRect_x">x</a>, <a href="#SkIRect_y">y</a>, <a href="#SkIRect_x">x</a> + <a href="#SkIRect_MakeXYWH_w">w</a>, <a href="#SkIRect_y">y</a> + <a href="#SkIRect_MakeXYWH_h">h</a>) + +### Example + +<div><fiddle-embed name="598ee14350bd1d961cae6b36fa3df17e"> + +#### Example Output + +~~~~ +rect: 5, 35, -10, 60 isEmpty: true +rect: -10, 35, 5, 60 isEmpty: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_MakeLTRB">MakeLTRB</a> <a href="#SkRect_MakeXYWH">SkRect::MakeXYWH</a> + +--- + +<a name="SkIRect_left"></a> +## left + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +int left() const +</pre> + +Returns <a href="#SkIRect_left">left</a> edge of <a href="#IRect">IRect</a>, if sorted. +Call <a href="#SkIRect_sort">sort</a> to reverse <a href="#SkIRect_fLeft">fLeft</a> and <a href="#SkIRect_fRight">fRight</a> if needed. + +### Return Value + +<a href="#SkIRect_fLeft">fLeft</a> + +### Example + +<div><fiddle-embed name="caf38ea4431bc246ba198f6a8c2b0f01"> + +#### Example Output + +~~~~ +unsorted.fLeft: 15 unsorted.left(): 15 +sorted.fLeft: 10 sorted.left(): 10 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_fLeft">fLeft</a> <a href="#SkIRect_x">x</a> <a href="#SkRect_left">SkRect::left()</a> + +--- + +<a name="SkIRect_top"></a> +## top + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +int top() const +</pre> + +Returns <a href="#SkIRect_top">top</a> edge of <a href="#IRect">IRect</a>, if sorted. Call <a href="#SkIRect_isEmpty">isEmpty</a> to see if <a href="#IRect">IRect</a> may be invalid, +and <a href="#SkIRect_sort">sort</a> to reverse <a href="#SkIRect_fTop">fTop</a> and <a href="#SkIRect_fBottom">fBottom</a> if needed. + +### Return Value + +<a href="#SkIRect_fTop">fTop</a> + +### Example + +<div><fiddle-embed name="cbec1ae6530e95943775450b1d11f19e"> + +#### Example Output + +~~~~ +unsorted.fTop: 25 unsorted.top(): 25 +sorted.fTop: 5 sorted.top(): 5 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_fTop">fTop</a> <a href="#SkIRect_y">y</a> <a href="#SkRect_top">SkRect::top()</a> + +--- + +<a name="SkIRect_right"></a> +## right + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +int right() const +</pre> + +Returns <a href="#SkIRect_right">right</a> edge of <a href="#IRect">IRect</a>, if sorted. +Call <a href="#SkIRect_sort">sort</a> to reverse <a href="#SkIRect_fLeft">fLeft</a> and <a href="#SkIRect_fRight">fRight</a> if needed. + +### Return Value + +<a href="#SkIRect_fRight">fRight</a> + +### Example + +<div><fiddle-embed name="97e210976f1ee0387b30c70635cf114f"> + +#### Example Output + +~~~~ +unsorted.fRight: 10 unsorted.right(): 10 +sorted.fRight: 15 sorted.right(): 15 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_fRight">fRight</a> <a href="#SkRect_right">SkRect::right()</a> + +--- + +<a name="SkIRect_bottom"></a> +## bottom + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +int bottom() const +</pre> + +Returns <a href="#SkIRect_bottom">bottom</a> edge of <a href="#IRect">IRect</a>, if sorted. Call <a href="#SkIRect_isEmpty">isEmpty</a> to see if <a href="#IRect">IRect</a> may be invalid, +and <a href="#SkIRect_sort">sort</a> to reverse <a href="#SkIRect_fTop">fTop</a> and <a href="#SkIRect_fBottom">fBottom</a> if needed. + +### Return Value + +<a href="#SkIRect_fBottom">fBottom</a> + +### Example + +<div><fiddle-embed name="c32afebc296054a181621648a184b8e3"> + +#### Example Output + +~~~~ +unsorted.fBottom: 5 unsorted.bottom(): 5 +sorted.fBottom: 25 sorted.bottom(): 25 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_fBottom">fBottom</a> <a href="#SkRect_bottom">SkRect::bottom()</a> + +--- + +<a name="SkIRect_x"></a> +## x + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +int x() const +</pre> + +Returns <a href="#SkIRect_left">left</a> edge of <a href="#IRect">IRect</a>, if sorted. Call <a href="#SkIRect_isEmpty">isEmpty</a> to see if <a href="#IRect">IRect</a> may be invalid, +and <a href="#SkIRect_sort">sort</a> to reverse <a href="#SkIRect_fLeft">fLeft</a> and <a href="#SkIRect_fRight">fRight</a> if needed. + +### Return Value + +<a href="#SkIRect_fLeft">fLeft</a> + +### Example + +<div><fiddle-embed name="2a59cbfd1330a0db520d6ebb2b7c68c7"> + +#### Example Output + +~~~~ +unsorted.fLeft: 15 unsorted.x(): 15 +sorted.fLeft: 10 sorted.x(): 10 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_fLeft">fLeft</a> <a href="#SkIRect_left">left</a> <a href="#SkIRect_y">y</a> <a href="#SkRect_x">SkRect::x()</a> + +--- + +<a name="SkIRect_y"></a> +## y + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +int y() const +</pre> + +Returns <a href="#SkIRect_top">top</a> edge of <a href="#IRect">IRect</a>, if sorted. Call <a href="#SkIRect_isEmpty">isEmpty</a> to see if <a href="#IRect">IRect</a> may be invalid, +and <a href="#SkIRect_sort">sort</a> to reverse <a href="#SkIRect_fTop">fTop</a> and <a href="#SkIRect_fBottom">fBottom</a> if needed. + +### Return Value + +<a href="#SkIRect_fTop">fTop</a> + +### Example + +<div><fiddle-embed name="6ea461e71f7fc80605818fbf493caa63"> + +#### Example Output + +~~~~ +unsorted.fTop: 25 unsorted.y(): 25 +sorted.fTop: 5 sorted.y(): 5 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_fTop">fTop</a> <a href="#SkIRect_top">top</a> <a href="#SkIRect_x">x</a> <a href="#SkRect_y">SkRect::y()</a> + +--- + +<a name="SkIRect_width"></a> +## width + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +int width() const +</pre> + +Returns span on the x-axis. This does not check if <a href="#IRect">IRect</a> is sorted, or if +result fits in 32-bit signed integer; result may be negative. + +### Return Value + +<a href="#SkIRect_fRight">fRight</a> minus <a href="#SkIRect_fLeft">fLeft</a> + +### Example + +<div><fiddle-embed name="4acfbe051805940210c8916a94794142"> + +#### Example Output + +~~~~ +unsorted width: -5 +large width: -5 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_height">height</a> <a href="#SkRect_width">SkRect::width()</a> + +--- + +<a name="SkIRect_height"></a> +## height + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +int height() const +</pre> + +Returns span on the y-axis. This does not check if <a href="#IRect">IRect</a> is sorted, or if +result fits in 32-bit signed integer; result may be negative. + +### Return Value + +<a href="#SkIRect_fBottom">fBottom</a> minus <a href="#SkIRect_fTop">fTop</a> + +### Example + +<div><fiddle-embed name="0175bae87fafcd9433ae661574695586"> + +#### Example Output + +~~~~ +unsorted height: -5 +large height: -5 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_width">width</a> <a href="#SkRect_height">SkRect::height()</a> + +--- + +<a name="SkIRect_size"></a> +## size + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkISize size() const +</pre> + +Returns spans on the x-axis and y-axis. This does not check if <a href="#IRect">IRect</a> is sorted, +or if result fits in 32-bit signed integer; result may be negative. + +### Return Value + +<a href="#Size">ISize</a> (<a href="#SkIRect_width">width</a>, <a href="#SkIRect_height">height</a>) + +### Example + +<div><fiddle-embed name="8b3224641cb3053a7b8a5798b6cd1cf6"> + +#### Example Output + +~~~~ +original rect: 20, 30, 40, 50 size: 20, 20 +offset rect: 40, 50, 60, 70 size: 20, 20 +outset rect: 20, 30, 80, 90 size: 60, 60 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_height">height</a> <a href="#SkIRect_width">width</a> <a href="#SkIRect_MakeSize">MakeSize</a> + +--- + +<a name="SkIRect_centerX"></a> +## centerX + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +int centerX() const +</pre> + +Returns average of <a href="#SkIRect_left">left</a> edge and <a href="#SkIRect_right">right</a> edge. Result does not change if <a href="SkRect_Reference#Rect">Rect</a> +is sorted. Result may be incorrect if <a href="SkRect_Reference#Rect">Rect</a> is far from the origin. + +Result is rounded down. + +### Return Value + +midpoint in <a href="#SkIRect_x">x</a> + +### Example + +<div><fiddle-embed name="549b840a9ceaaf7cb4e604f9f3d7108d"><div>Dividing by two rounds towards zero. <a href="#SkIRect_centerX">centerX</a> uses a bit shift and rounds down.</div> + +#### Example Output + +~~~~ +left: 20 right: 41 centerX: 30 div2: 30 +left: -20 right: -41 centerX: -31 div2: -30 +left: -10 right: 11 centerX: 0 div2: 0 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_centerY">centerY</a> <a href="#SkRect_centerX">SkRect::centerX</a> + +--- + +<a name="SkIRect_centerY"></a> +## centerY + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +int centerY() const +</pre> + +Returns average of <a href="#SkIRect_top">top</a> edge and <a href="#SkIRect_bottom">bottom</a> edge. Result does not change if <a href="SkRect_Reference#Rect">Rect</a> +is sorted. Result may be incorrect if <a href="SkRect_Reference#Rect">Rect</a> is far from the origin. + +Result is rounded down. + +### Return Value + +midpoint in <a href="#SkIRect_y">y</a> + +### Example + +<div><fiddle-embed name="687d833b042fb018f8948764e73a37b1"> + +#### Example Output + +~~~~ +left: 1073741824 right: 1073741826 centerX: -1073741823 safe mid x: 1073741825 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_centerX">centerX</a> <a href="#SkRect_centerY">SkRect::centerY</a> + +--- + +<a name="SkIRect_isEmpty"></a> +## isEmpty + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool isEmpty() const +</pre> + +Returns true if <a href="#SkIRect_fLeft">fLeft</a> is equal to or greater than <a href="#SkIRect_fRight">fRight</a>, or if <a href="#SkIRect_fTop">fTop</a> is equal +to or greater than <a href="#SkIRect_fBottom">fBottom</a>. Call <a href="#SkIRect_sort">sort</a> to reverse rectangles with negative +<a href="#SkIRect_width">width</a> or <a href="#SkIRect_height">height</a>. + +### Return Value + +true if <a href="#SkIRect_width">width</a> or <a href="#SkIRect_height">height</a> are zero or negative + +### Example + +<div><fiddle-embed name="edaad064b6de249b7a7c768dfa000adc"> + +#### Example Output + +~~~~ +rect: {20, 40, 10, 50} is empty +sorted: {10, 40, 20, 50} is not empty +rect: {20, 40, 20, 50} is empty +sorted: {20, 40, 20, 50} is empty +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_EmptyIRect">EmptyIRect</a> <a href="#SkIRect_MakeEmpty">MakeEmpty</a> <a href="#SkIRect_sort">sort</a> <a href="#SkRect_isEmpty">SkRect::isEmpty</a> + +--- + +<a name="SkIRect_isLargest"></a> +## isLargest + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool isLargest() const +</pre> + +Returns true if <a href="#IRect">IRect</a> encloses largest possible area. + +### Return Value + +true if equal to (<a href="undocumented#SK_MinS32">SK MinS32</a>, <a href="undocumented#SK_MinS32">SK MinS32</a>, <a href="undocumented#SK_MaxS32">SK MaxS32</a>, <a href="undocumented#SK_MaxS32">SK MaxS32</a>) + +### Example + +<div><fiddle-embed name="477e0a7f0aa8aec1d94e1e117041a335"><div>Note that the <a href="#SkIRect_width">width</a> is not negative, yet it cannot be represented as a 32-bit +signed integer.</div> + +#### Example Output + +~~~~ +large is largest: true +large width -2 +large is empty: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_MakeLargest">MakeLargest</a> <a href="#SkRect_isLargest">SkRect::isLargest</a> + +--- + +<a name="SkIRect_equal_operator"></a> +## operator== + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +friend bool operator==(const SkIRect& a, const SkIRect& b) +</pre> + +Returns true if all members in <a href="#SkIRect_equal_operator_a">a</a>: <a href="#SkIRect_fLeft">fLeft</a>, <a href="#SkIRect_fTop">fTop</a>, <a href="#SkIRect_fRight">fRight</a>, and <a href="#SkIRect_fBottom">fBottom</a>; are +identical to corresponding members in <a href="#SkIRect_equal_operator_b">b</a>. + +### Parameters + +<table> <tr> <td><a name="SkIRect_equal_operator_a"> <code><strong>a </strong></code> </a></td> <td> +<a href="#IRect">IRect</a> to compare</td> + </tr> <tr> <td><a name="SkIRect_equal_operator_b"> <code><strong>b </strong></code> </a></td> <td> +<a href="#IRect">IRect</a> to compare</td> + </tr> +</table> + +### Return Value + +true if members are equal + +### Example + +<div><fiddle-embed name="bd8f028d9051062816c9116fea4237b2"> + +#### Example Output + +~~~~ +test == sorted +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_not_equal_operator">operator!=(const SkIRect& a, const SkIRect& b)</a> + +--- + +<a name="SkIRect_not_equal_operator"></a> +## operator!= + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +friend bool operator!=(const SkIRect& a, const SkIRect& b) +</pre> + +Returns true if any member in <a href="#SkIRect_not_equal_operator_a">a</a>: <a href="#SkIRect_fLeft">fLeft</a>, <a href="#SkIRect_fTop">fTop</a>, <a href="#SkIRect_fRight">fRight</a>, and <a href="#SkIRect_fBottom">fBottom</a>; is not +identical to the corresponding member in <a href="#SkIRect_not_equal_operator_b">b</a>. + +### Parameters + +<table> <tr> <td><a name="SkIRect_not_equal_operator_a"> <code><strong>a </strong></code> </a></td> <td> +<a href="#IRect">IRect</a> to compare</td> + </tr> <tr> <td><a name="SkIRect_not_equal_operator_b"> <code><strong>b </strong></code> </a></td> <td> +<a href="#IRect">IRect</a> to compare</td> + </tr> +</table> + +### Return Value + +true if members are not equal + +### Example + +<div><fiddle-embed name="6c4acd8aa203f632b7d85cae672abf4d"> + +#### Example Output + +~~~~ +test != sorted +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_equal_operator">operator==(const SkIRect& a, const SkIRect& b)</a> + +--- + +<a name="SkIRect_is16Bit"></a> +## is16Bit + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool is16Bit() const +</pre> + +Returns true if all members: <a href="#SkIRect_fLeft">fLeft</a>, <a href="#SkIRect_fTop">fTop</a>, <a href="#SkIRect_fRight">fRight</a>, and <a href="#SkIRect_fBottom">fBottom</a>; values are +equal to or larger than -32768 and equal to or smaller than 32767. + +### Return Value + +true if members fit in 16-bit word + +### Example + +<div><fiddle-embed name="103e8d463e68e87e0f8f9454a7d3441c"> + +#### Example Output + +~~~~ +{-32768, -32768, 32767, 32767} fits in 16 bits +{-32768, -32768, 32768, 32768} does not fit in 16 bits +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="undocumented#SkTFitsIn">SkTFitsIn</a> + +--- + +<a name="SkIRect_setEmpty"></a> +## setEmpty + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void setEmpty() +</pre> + +Sets <a href="#IRect">IRect</a> to (0, 0, 0, 0). + +Many other rectangles are empty; if <a href="#SkIRect_left">left</a> is equal to or greater than <a href="#SkIRect_right">right</a>, +or if <a href="#SkIRect_top">top</a> is equal to or greater than <a href="#SkIRect_bottom">bottom</a>. Setting all members to zero +is a convenience, but does not designate a special empty rectangle. + +### Example + +<div><fiddle-embed name="94039c3cc9e911c8ab2993d56fd06210"> + +#### Example Output + +~~~~ +rect: {3, 4, 1, 2} is empty +rect: {0, 0, 0, 0} is empty +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_MakeEmpty">MakeEmpty</a> <a href="#SkRect_setEmpty">SkRect::setEmpty</a> + +--- + +<a name="SkIRect_set"></a> +## set + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void set(int32_t left, int32_t top, int32_t right, int32_t bottom) +</pre> + +Sets <a href="#IRect">IRect</a> to (<a href="#SkIRect_left">left</a>, <a href="#SkIRect_top">top</a>, <a href="#SkIRect_right">right</a>, <a href="#SkIRect_bottom">bottom</a>). +<a href="#SkIRect_left">left</a> and <a href="#SkIRect_right">right</a> are not sorted; <a href="#SkIRect_left">left</a> is not necessarily less than <a href="#SkIRect_right">right</a>. +<a href="#SkIRect_top">top</a> and <a href="#SkIRect_bottom">bottom</a> are not sorted; <a href="#SkIRect_top">top</a> is not necessarily less than <a href="#SkIRect_bottom">bottom</a>. + +### Parameters + +<table> <tr> <td><a name="SkIRect_set_left"> <code><strong>left </strong></code> </a></td> <td> +assigned to <a href="#SkIRect_fLeft">fLeft</a></td> + </tr> <tr> <td><a name="SkIRect_set_top"> <code><strong>top </strong></code> </a></td> <td> +assigned to <a href="#SkIRect_fTop">fTop</a></td> + </tr> <tr> <td><a name="SkIRect_set_right"> <code><strong>right </strong></code> </a></td> <td> +assigned to <a href="#SkIRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkIRect_set_bottom"> <code><strong>bottom </strong></code> </a></td> <td> +assigned to <a href="#SkIRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="1912c37076b7f3bf6aebfa167e971bec"> + +#### Example Output + +~~~~ +rect1: {3, 4, 1, 2} +rect2: {3, 4, 1, 2} +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_setLTRB">setLTRB</a> <a href="#SkIRect_setXYWH">setXYWH</a> <a href="#SkRect_set">SkRect::set</a> + +--- + +<a name="SkIRect_setLTRB"></a> +## setLTRB + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom) +</pre> + +Sets <a href="#IRect">IRect</a> to (<a href="#SkIRect_left">left</a>, <a href="#SkIRect_top">top</a>, <a href="#SkIRect_right">right</a>, <a href="#SkIRect_bottom">bottom</a>). +<a href="#SkIRect_left">left</a> and <a href="#SkIRect_right">right</a> are not sorted; <a href="#SkIRect_left">left</a> is not necessarily less than <a href="#SkIRect_right">right</a>. +<a href="#SkIRect_top">top</a> and <a href="#SkIRect_bottom">bottom</a> are not sorted; <a href="#SkIRect_top">top</a> is not necessarily less than <a href="#SkIRect_bottom">bottom</a>. + +### Parameters + +<table> <tr> <td><a name="SkIRect_setLTRB_left"> <code><strong>left </strong></code> </a></td> <td> +stored in <a href="#SkIRect_fLeft">fLeft</a></td> + </tr> <tr> <td><a name="SkIRect_setLTRB_top"> <code><strong>top </strong></code> </a></td> <td> +stored in <a href="#SkIRect_fTop">fTop</a></td> + </tr> <tr> <td><a name="SkIRect_setLTRB_right"> <code><strong>right </strong></code> </a></td> <td> +stored in <a href="#SkIRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkIRect_setLTRB_bottom"> <code><strong>bottom </strong></code> </a></td> <td> +stored in <a href="#SkIRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="ead6bdcf2ae77ec19a1c5a96f5b31af8"> + +#### Example Output + +~~~~ +rect1: {3, 4, 1, 2} +rect2: {3, 4, 1, 2} +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_set">set</a> <a href="#SkIRect_setXYWH">setXYWH</a> <a href="#SkRect_setLTRB">SkRect::setLTRB</a> + +--- + +<a name="SkIRect_setXYWH"></a> +## setXYWH + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void setXYWH(int32_t x, int32_t y, int32_t width, int32_t height) +</pre> + +Sets <a href="#IRect">IRect</a> to(<a href="#SkIRect_x">x</a>, <a href="#SkIRect_y">y</a>, <a href="#SkIRect_x">x</a> + w, <a href="#SkIRect_y">y</a> + h). +Does not validate input; +w or h may be negative. + +### Parameters + +<table> <tr> <td><a name="SkIRect_setXYWH_x"> <code><strong>x </strong></code> </a></td> <td> +stored in <a href="#SkIRect_fLeft">fLeft</a></td> + </tr> <tr> <td><a name="SkIRect_setXYWH_y"> <code><strong>y </strong></code> </a></td> <td> +stored in <a href="#SkIRect_fTop">fTop</a></td> + </tr> <tr> <td><a name="SkIRect_setXYWH_width"> <code><strong>width </strong></code> </a></td> <td> +added to <a href="#SkIRect_x">x</a> and stored in <a href="#SkIRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkIRect_setXYWH_height"> <code><strong>height </strong></code> </a></td> <td> +added to <a href="#SkIRect_y">y</a> and stored in <a href="#SkIRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="0e1db8c86678c004e504f47641b44b17"> + +#### Example Output + +~~~~ +rect: 5, 35, -10, 60 isEmpty: true +rect: -10, 35, 5, 60 isEmpty: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_MakeXYWH">MakeXYWH</a> <a href="#SkIRect_setLTRB">setLTRB</a> <a href="#SkIRect_set">set</a> <a href="#SkRect_setXYWH">SkRect::setXYWH</a> + +--- + +<a name="SkIRect_setLargest"></a> +## setLargest + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void setLargest() +</pre> + +Sets rectangle <a href="#SkIRect_left">left</a> and <a href="#SkIRect_top">top</a> to most negative value, and sets +<a href="#SkIRect_right">right</a> and <a href="#SkIRect_bottom">bottom</a> to most positive value. + +### Example + +<div><fiddle-embed name="d5d67c6f09a14d06f1ee988cb56525b5"> + +#### Example Output + +~~~~ +MakeLargest isLargest: true +MakeLargest isEmpty: false +outset isLargest: false +outset isEmpty: true +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_MakeLargest">MakeLargest</a> <a href="#SkIRect_isLargest">isLargest</a> <a href="#SkIRect_setLargestInverted">setLargestInverted</a> <a href="undocumented#SK_MinS32">SK MinS32</a> <a href="undocumented#SK_MaxS32">SK MaxS32</a> + +--- + +<a name="SkIRect_setLargestInverted"></a> +## setLargestInverted + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void setLargestInverted() +</pre> + +Sets rectangle <a href="#SkIRect_left">left</a> and <a href="#SkIRect_top">top</a> to most positive value, and sets +<a href="#SkIRect_right">right</a> and <a href="#SkIRect_bottom">bottom</a> to most negative value. This is used internally to +flag that a condition is met, but otherwise has no special purpose. + +### See Also + +<a href="#SkIRect_setEmpty">setEmpty</a> <a href="#SkIRect_setLargest">setLargest</a> + +--- + +<a name="SkIRect_makeOffset"></a> +## makeOffset + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkIRect makeOffset(int32_t dx, int32_t dy) const +</pre> + +Returns <a href="#IRect">IRect</a> <a href="#SkIRect_offset">offset</a> by (<a href="#SkIRect_makeOffset_dx">dx</a>, <a href="#SkIRect_makeOffset_dy">dy</a>). + +If <a href="#SkIRect_makeOffset_dx">dx</a> is negative, <a href="#IRect">IRect</a> returned is moved to the <a href="#SkIRect_left">left</a>. +If <a href="#SkIRect_makeOffset_dx">dx</a> is positive, <a href="#IRect">IRect</a> returned is moved to the <a href="#SkIRect_right">right</a>. +If <a href="#SkIRect_makeOffset_dy">dy</a> is negative, <a href="#IRect">IRect</a> returned is moved upward. +If <a href="#SkIRect_makeOffset_dy">dy</a> is positive, <a href="#IRect">IRect</a> returned is moved downward. + +### Parameters + +<table> <tr> <td><a name="SkIRect_makeOffset_dx"> <code><strong>dx </strong></code> </a></td> <td> +<a href="#SkIRect_offset">offset</a> added to <a href="#SkIRect_fLeft">fLeft</a> and <a href="#SkIRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkIRect_makeOffset_dy"> <code><strong>dy </strong></code> </a></td> <td> +<a href="#SkIRect_offset">offset</a> added to <a href="#SkIRect_fTop">fTop</a> and <a href="#SkIRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Return Value + +<a href="SkRect_Reference#Rect">Rect</a> <a href="#SkIRect_offset">offset</a> in <a href="#SkIRect_x">x</a> or <a href="#SkIRect_y">y</a>, with original <a href="#SkIRect_width">width</a> and <a href="#SkIRect_height">height</a> + +### Example + +<div><fiddle-embed name="737c747df07ddf392c05970440de0927"> + +#### Example Output + +~~~~ +rect: 10, 50, 20, 60 isEmpty: false +rect: 25, 82, 35, 92 isEmpty: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_offset">offset</a> <a href="#SkIRect_makeInset">makeInset</a> <a href="#SkIRect_makeOutset">makeOutset</a> <a href="#SkRect_makeOffset">SkRect::makeOffset</a> + +--- + +<a name="SkIRect_makeInset"></a> +## makeInset + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkIRect makeInset(int32_t dx, int32_t dy) const +</pre> + +Returns <a href="#IRect">IRect</a>, <a href="#SkIRect_inset">inset</a> by (<a href="#SkIRect_makeInset_dx">dx</a>, <a href="#SkIRect_makeInset_dy">dy</a>). + +If <a href="#SkIRect_makeInset_dx">dx</a> is negative, <a href="#IRect">IRect</a> returned is wider. +If <a href="#SkIRect_makeInset_dx">dx</a> is positive, <a href="#IRect">IRect</a> returned is narrower. +If <a href="#SkIRect_makeInset_dy">dy</a> is negative, <a href="#IRect">IRect</a> returned is taller. +If <a href="#SkIRect_makeInset_dy">dy</a> is positive, <a href="#IRect">IRect</a> returned is shorter. + +### Parameters + +<table> <tr> <td><a name="SkIRect_makeInset_dx"> <code><strong>dx </strong></code> </a></td> <td> +<a href="#SkIRect_offset">offset</a> added to <a href="#SkIRect_fLeft">fLeft</a> and subtracted from <a href="#SkIRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkIRect_makeInset_dy"> <code><strong>dy </strong></code> </a></td> <td> +<a href="#SkIRect_offset">offset</a> added to <a href="#SkIRect_fTop">fTop</a> and subtracted from <a href="#SkIRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Return Value + +<a href="SkRect_Reference#Rect">Rect</a> <a href="#SkIRect_inset">inset</a> symetrically <a href="#SkIRect_left">left</a> and <a href="#SkIRect_right">right</a>, <a href="#SkIRect_top">top</a> and <a href="#SkIRect_bottom">bottom</a> + +### Example + +<div><fiddle-embed name="1db94b2c76e0a7a71856532335fa56b6"> + +#### Example Output + +~~~~ +rect: 10, 50, 20, 60 isEmpty: false +rect: 25, 82, 5, 28 isEmpty: true +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_inset">inset</a> <a href="#SkIRect_makeOffset">makeOffset</a> <a href="#SkIRect_makeOutset">makeOutset</a> <a href="#SkRect_makeInset">SkRect::makeInset</a> + +--- + +<a name="SkIRect_makeOutset"></a> +## makeOutset + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkIRect makeOutset(int32_t dx, int32_t dy) const +</pre> + +Returns <a href="#IRect">IRect</a>, <a href="#SkIRect_outset">outset</a> by (<a href="#SkIRect_makeOutset_dx">dx</a>, <a href="#SkIRect_makeOutset_dy">dy</a>). + +If <a href="#SkIRect_makeOutset_dx">dx</a> is negative, <a href="#IRect">IRect</a> returned is narrower. +If <a href="#SkIRect_makeOutset_dx">dx</a> is positive, <a href="#IRect">IRect</a> returned is wider. +If <a href="#SkIRect_makeOutset_dy">dy</a> is negative, <a href="#IRect">IRect</a> returned is shorter. +If <a href="#SkIRect_makeOutset_dy">dy</a> is positive, <a href="#IRect">IRect</a> returned is taller. + +### Parameters + +<table> <tr> <td><a name="SkIRect_makeOutset_dx"> <code><strong>dx </strong></code> </a></td> <td> +<a href="#SkIRect_offset">offset</a> subtracted to <a href="#SkIRect_fLeft">fLeft</a> and added from <a href="#SkIRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkIRect_makeOutset_dy"> <code><strong>dy </strong></code> </a></td> <td> +<a href="#SkIRect_offset">offset</a> subtracted to <a href="#SkIRect_fTop">fTop</a> and added from <a href="#SkIRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Return Value + +<a href="SkRect_Reference#Rect">Rect</a> <a href="#SkIRect_outset">outset</a> symetrically <a href="#SkIRect_left">left</a> and <a href="#SkIRect_right">right</a>, <a href="#SkIRect_top">top</a> and <a href="#SkIRect_bottom">bottom</a> + +### Example + +<div><fiddle-embed name="240e2953e3455c08f6d89255feff8416"> + +#### Example Output + +~~~~ +rect: 10, 50, 20, 60 isEmpty: false +rect: -5, 18, 35, 92 isEmpty: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_outset">outset</a> <a href="#SkIRect_makeOffset">makeOffset</a> <a href="#SkIRect_makeInset">makeInset</a> <a href="#SkRect_makeOutset">SkRect::makeOutset</a> + +--- + +<a name="SkIRect_offset"></a> +## offset + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void offset(int32_t dx, int32_t dy) +</pre> + +Offsets <a href="#IRect">IRect</a> by adding <a href="#SkIRect_offset_dx">dx</a> to <a href="#SkIRect_fLeft">fLeft</a>, <a href="#SkIRect_fRight">fRight</a>; and by adding <a href="#SkIRect_offset_dy">dy</a> to <a href="#SkIRect_fTop">fTop</a>, <a href="#SkIRect_fBottom">fBottom</a>. + +If <a href="#SkIRect_offset_dx">dx</a> is negative, moves <a href="#IRect">IRect</a> returned to the <a href="#SkIRect_left">left</a>. +If <a href="#SkIRect_offset_dx">dx</a> is positive, moves <a href="#IRect">IRect</a> returned to the <a href="#SkIRect_right">right</a>. +If <a href="#SkIRect_offset_dy">dy</a> is negative, moves <a href="#IRect">IRect</a> returned upward. +If <a href="#SkIRect_offset_dy">dy</a> is positive, moves <a href="#IRect">IRect</a> returned downward. + +### Parameters + +<table> <tr> <td><a name="SkIRect_offset_dx"> <code><strong>dx </strong></code> </a></td> <td> +<a href="#SkIRect_offset">offset</a> added to <a href="#SkIRect_fLeft">fLeft</a> and <a href="#SkIRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkIRect_offset_dy"> <code><strong>dy </strong></code> </a></td> <td> +<a href="#SkIRect_offset">offset</a> added to <a href="#SkIRect_fTop">fTop</a> and <a href="#SkIRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="77e633b2174ffae923c038b303418b50"> + +#### Example Output + +~~~~ +rect: 15, 27, 55, 86 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_offsetTo">offsetTo</a> <a href="#SkIRect_makeOffset">makeOffset</a> <a href="#SkRect_offset">SkRect::offset</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void offset(const SkIPoint& delta) +</pre> + +Offsets <a href="#IRect">IRect</a> by adding <a href="#SkIRect_offset_2_delta">delta</a>.fX to <a href="#SkIRect_fLeft">fLeft</a>, <a href="#SkIRect_fRight">fRight</a>; and by adding <a href="#SkIRect_offset_2_delta">delta</a>.fY to +<a href="#SkIRect_fTop">fTop</a>, <a href="#SkIRect_fBottom">fBottom</a>. + +If <a href="#SkIRect_offset_2_delta">delta</a>.fX is negative, moves <a href="#IRect">IRect</a> returned to the <a href="#SkIRect_left">left</a>. +If <a href="#SkIRect_offset_2_delta">delta</a>.fX is positive, moves <a href="#IRect">IRect</a> returned to the <a href="#SkIRect_right">right</a>. +If <a href="#SkIRect_offset_2_delta">delta</a>.fY is negative, moves <a href="#IRect">IRect</a> returned upward. +If <a href="#SkIRect_offset_2_delta">delta</a>.fY is positive, moves <a href="#IRect">IRect</a> returned downward. + +### Parameters + +<table> <tr> <td><a name="SkIRect_offset_2_delta"> <code><strong>delta </strong></code> </a></td> <td> +<a href="#SkIRect_offset">offset</a> added to <a href="#IRect">IRect</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="31a4c575499e76def651eb65994876f0"> + +#### Example Output + +~~~~ +rect: 15, 27, 55, 86 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_offsetTo">offsetTo</a> <a href="#SkIRect_makeOffset">makeOffset</a> <a href="#SkRect_offset">SkRect::offset</a> + +--- + +<a name="SkIRect_offsetTo"></a> +## offsetTo + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void offsetTo(int32_t newX, int32_t newY) +</pre> + +Offsets <a href="#IRect">IRect</a> so that <a href="#SkIRect_fLeft">fLeft</a> equals <a href="#SkIRect_offsetTo_newX">newX</a>, and <a href="#SkIRect_fTop">fTop</a> equals <a href="#SkIRect_offsetTo_newY">newY</a>. <a href="#SkIRect_width">width</a> and <a href="#SkIRect_height">height</a> +are unchanged. + +### Parameters + +<table> <tr> <td><a name="SkIRect_offsetTo_newX"> <code><strong>newX </strong></code> </a></td> <td> +stored in <a href="#SkIRect_fLeft">fLeft</a>, preserving <a href="#SkIRect_width">width</a></td> + </tr> <tr> <td><a name="SkIRect_offsetTo_newY"> <code><strong>newY </strong></code> </a></td> <td> +stored in <a href="#SkIRect_fTop">fTop</a>, preserving <a href="#SkIRect_height">height</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="a2734ff23b35653956a3002e5c29ff91"> + +#### Example Output + +~~~~ +rect: 15, 27, 55, 86 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_offset">offset</a> <a href="#SkIRect_makeOffset">makeOffset</a> <a href="#SkIRect_setXYWH">setXYWH</a> <a href="#SkRect_offsetTo">SkRect::offsetTo</a> + +--- + +<a name="SkIRect_inset"></a> +## inset + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void inset(int32_t dx, int32_t dy) +</pre> + +Insets <a href="#IRect">IRect</a> by (<a href="#SkIRect_inset_dx">dx</a>,<a href="#SkIRect_inset_dy">dy</a>). + +If <a href="#SkIRect_inset_dx">dx</a> is positive, makes <a href="#IRect">IRect</a> narrower. +If <a href="#SkIRect_inset_dx">dx</a> is negative, makes <a href="#IRect">IRect</a> wider. +If <a href="#SkIRect_inset_dy">dy</a> is positive, makes <a href="#IRect">IRect</a> shorter. +If <a href="#SkIRect_inset_dy">dy</a> is negative, makes <a href="#IRect">IRect</a> taller. + +### Parameters + +<table> <tr> <td><a name="SkIRect_inset_dx"> <code><strong>dx </strong></code> </a></td> <td> +<a href="#SkIRect_offset">offset</a> added to <a href="#SkIRect_fLeft">fLeft</a> and subtracted from <a href="#SkIRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkIRect_inset_dy"> <code><strong>dy </strong></code> </a></td> <td> +<a href="#SkIRect_offset">offset</a> added to <a href="#SkIRect_fTop">fTop</a> and subtracted from <a href="#SkIRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="9debaded1aa8bdf5077a4de0b3015b8f"> + +#### Example Output + +~~~~ +rect: 15, 27, 45, 60 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_outset">outset</a> <a href="#SkIRect_makeInset">makeInset</a> <a href="#SkRect_inset">SkRect::inset</a> + +--- + +<a name="SkIRect_outset"></a> +## outset + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void outset(int32_t dx, int32_t dy) +</pre> + +Outsets <a href="#IRect">IRect</a> by (<a href="#SkIRect_outset_dx">dx</a>, <a href="#SkIRect_outset_dy">dy</a>). + +If <a href="#SkIRect_outset_dx">dx</a> is positive, makes <a href="SkRect_Reference#Rect">Rect</a> wider. +If <a href="#SkIRect_outset_dx">dx</a> is negative, makes <a href="SkRect_Reference#Rect">Rect</a> narrower. +If <a href="#SkIRect_outset_dy">dy</a> is positive, makes <a href="SkRect_Reference#Rect">Rect</a> taller. +If <a href="#SkIRect_outset_dy">dy</a> is negative, makes <a href="SkRect_Reference#Rect">Rect</a> shorter. + +### Parameters + +<table> <tr> <td><a name="SkIRect_outset_dx"> <code><strong>dx </strong></code> </a></td> <td> +subtracted to <a href="#SkIRect_fLeft">fLeft</a> and added from <a href="#SkIRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkIRect_outset_dy"> <code><strong>dy </strong></code> </a></td> <td> +subtracted to <a href="#SkIRect_fTop">fTop</a> and added from <a href="#SkIRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="3fc62ca29428195f33a3a02b3eb74e4f"> + +#### Example Output + +~~~~ +rect: 5, 1, 55, 86 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_inset">inset</a> <a href="#SkIRect_makeOutset">makeOutset</a> <a href="#SkRect_outset">SkRect::outset</a> + +--- + +<a name="SkIRect_quickReject"></a> +## quickReject + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool quickReject(int l, int t, int r, int b) const +</pre> + +Constructs <a href="#IRect">IRect</a> (<a href="#SkIRect_quickReject_l">l</a>, <a href="#SkIRect_quickReject_t">t</a>, <a href="#SkIRect_quickReject_r">r</a>, <a href="#SkIRect_quickReject_b">b</a>) and returns true if constructed <a href="#IRect">IRect</a> does not +<a href="#SkIRect_intersect">intersect</a> <a href="#IRect">IRect</a>. Does not check to see if construction or <a href="#IRect">IRect</a> is empty. + +Is implemented with short circuit logic so that true can be returned after +a single compare. + +### Parameters + +<table> <tr> <td><a name="SkIRect_quickReject_l"> <code><strong>l </strong></code> </a></td> <td> +<a href="#SkIRect_x">x</a> minimum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkIRect_quickReject_t"> <code><strong>t </strong></code> </a></td> <td> +<a href="#SkIRect_y">y</a> minimum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkIRect_quickReject_r"> <code><strong>r </strong></code> </a></td> <td> +<a href="#SkIRect_x">x</a> maximum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkIRect_quickReject_b"> <code><strong>b </strong></code> </a></td> <td> +<a href="#SkIRect_y">y</a> maximum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> +</table> + +### Return Value + +true if construction and <a href="#IRect">IRect</a> have no area in common + +### Example + +<div><fiddle-embed name="f07146508efc516559d73853e6dadc78"><div><a href="#SkIRect_quickReject">quickReject</a> is the complement of <a href="#SkIRect_Intersects">Intersects</a>.</div> + +#### Example Output + +~~~~ +rect (7, 11, 13, 17) test(13, 11, 15, 17) quickReject true; intersects false +rect (7, 11, 13, 17) test(7, 7, 13, 11) quickReject true; intersects false +rect (7, 11, 13, 17) test(12, 16, 14, 18) quickReject false; intersects true +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_Intersects">Intersects</a> + +--- + +<a name="SkIRect_contains"></a> +## contains + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool contains(int32_t x, int32_t y) const +</pre> + +Returns true if<a href="#SkIRect_fLeft">fLeft</a> <= <a href="#SkIRect_x">x</a> < <a href="#SkIRect_fRight">fRight</a> && <a href="#SkIRect_fTop">fTop</a> <= <a href="#SkIRect_y">y</a> < <a href="#SkIRect_fBottom">fBottom</a>. + +Returns false if <a href="SkRect_Reference#Rect">Rect</a> is empty. + +Considers input to describe constructed <a href="#IRect">IRect</a> (<a href="#SkIRect_x">x</a>, <a href="#SkIRect_y">y</a>, <a href="#SkIRect_x">x</a> + 1, <a href="#SkIRect_y">y</a> + 1) and +returns true if constructed area is completely enclosed by <a href="#IRect">IRect</a> area. + +### Parameters + +<table> <tr> <td><a name="SkIRect_contains_x"> <code><strong>x </strong></code> </a></td> <td> +test <a href="undocumented#Point">Point</a> x-coordinate</td> + </tr> <tr> <td><a name="SkIRect_contains_y"> <code><strong>y </strong></code> </a></td> <td> +test <a href="undocumented#Point">Point</a> y-coordinate</td> + </tr> +</table> + +### Return Value + +true if (<a href="#SkIRect_x">x</a>, <a href="#SkIRect_y">y</a>) is inside <a href="#IRect">IRect</a> + +### Example + +<div><fiddle-embed name="a7958a4e0668f5cf805a8e78eb57f51d"> + +#### Example Output + +~~~~ +rect: (30, 50, 40, 60) contains (30, 50) +rect: (30, 50, 40, 60) does not contain (40, 50) +rect: (30, 50, 40, 60) does not contain (30, 60) +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_containsNoEmptyCheck">containsNoEmptyCheck</a> <a href="#SkRect_contains">SkRect::contains</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool contains(int32_t left, int32_t top, int32_t right, int32_t bottom) const +</pre> + +Constructs <a href="SkRect_Reference#Rect">Rect</a> to <a href="#SkIRect_intersect">intersect</a> from (<a href="#SkIRect_left">left</a>, <a href="#SkIRect_top">top</a>, <a href="#SkIRect_right">right</a>, <a href="#SkIRect_bottom">bottom</a>). Does not <a href="#SkIRect_sort">sort</a> +construction. + +Returns true if <a href="SkRect_Reference#Rect">Rect</a> <a href="#SkIRect_contains">contains</a> construction. +Returns false if <a href="SkRect_Reference#Rect">Rect</a> is empty or construction is empty. + +### Parameters + +<table> <tr> <td><a name="SkIRect_contains_2_left"> <code><strong>left </strong></code> </a></td> <td> +<a href="#SkIRect_x">x</a> minimum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkIRect_contains_2_top"> <code><strong>top </strong></code> </a></td> <td> +<a href="#SkIRect_y">y</a> minimum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkIRect_contains_2_right"> <code><strong>right </strong></code> </a></td> <td> +<a href="#SkIRect_x">x</a> maximum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkIRect_contains_2_bottom"> <code><strong>bottom </strong></code> </a></td> <td> +<a href="#SkIRect_y">y</a> maximum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> +</table> + +### Return Value + +true if all sides of <a href="#IRect">IRect</a> are outside construction + +### Example + +<div><fiddle-embed name="eae55f284818d9965ec5834747d14a48"> + +#### Example Output + +~~~~ +rect: (30, 50, 40, 60) contains (30, 50, 31, 51) +rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50) +rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60) +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_containsNoEmptyCheck">containsNoEmptyCheck</a> <a href="#SkRect_contains">SkRect::contains</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool contains(const SkIRect& r) const +</pre> + +Returns true if <a href="SkRect_Reference#Rect">Rect</a> <a href="#SkIRect_contains">contains</a> <a href="#SkIRect_contains_3_r">r</a>. +Returns false if <a href="SkRect_Reference#Rect">Rect</a> is empty or <a href="#SkIRect_contains_3_r">r</a> is empty. + +<a href="SkRect_Reference#Rect">Rect</a> <a href="#SkIRect_contains">contains</a> <a href="#SkIRect_contains_3_r">r</a> when <a href="SkRect_Reference#Rect">Rect</a> area completely includes <a href="#SkIRect_contains_3_r">r</a> area. + +### Parameters + +<table> <tr> <td><a name="SkIRect_contains_3_r"> <code><strong>r </strong></code> </a></td> <td> +<a href="#IRect">IRect</a> contained</td> + </tr> +</table> + +### Return Value + +true if all sides of <a href="#IRect">IRect</a> are outside <a href="#SkIRect_contains_3_r">r</a> + +### Example + +<div><fiddle-embed name="ee0185db622602b4eb19583c2f42c734"> + +#### Example Output + +~~~~ +rect: (30, 50, 40, 60) contains (30, 50, 31, 51) +rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50) +rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60) +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_containsNoEmptyCheck">containsNoEmptyCheck</a> <a href="#SkRect_contains">SkRect::contains</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool contains(const SkRect& r) const +</pre> + +Returns true if <a href="SkRect_Reference#Rect">Rect</a> <a href="#SkIRect_contains">contains</a> <a href="#SkIRect_contains_4_r">r</a>. +Returns false if <a href="SkRect_Reference#Rect">Rect</a> is empty or <a href="#SkIRect_contains_4_r">r</a> is empty. + +<a href="SkRect_Reference#Rect">Rect</a> <a href="#SkIRect_contains">contains</a> <a href="#SkIRect_contains_4_r">r</a> when <a href="SkRect_Reference#Rect">Rect</a> area completely includes <a href="#SkIRect_contains_4_r">r</a> area. + +### Parameters + +<table> <tr> <td><a name="SkIRect_contains_4_r"> <code><strong>r </strong></code> </a></td> <td> +<a href="SkRect_Reference#Rect">Rect</a> contained</td> + </tr> +</table> + +### Return Value + +true if all sides of <a href="#IRect">IRect</a> are outside <a href="#SkIRect_contains_4_r">r</a> + +### Example + +<div><fiddle-embed name="acbd79ffb304f332e4b38ef18e19663e"> + +#### Example Output + +~~~~ +rect: (30, 50, 40, 60) contains (30, 50, 31, 51) +rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50) +rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60) +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_containsNoEmptyCheck">containsNoEmptyCheck</a> <a href="#SkRect_contains">SkRect::contains</a> + +--- + +<a name="SkIRect_containsNoEmptyCheck"></a> +## containsNoEmptyCheck + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool containsNoEmptyCheck(int32_t left, int32_t top, int32_t right, + int32_t bottom) const +</pre> + +Constructs <a href="#IRect">IRect</a> from (<a href="#SkIRect_left">left</a>, <a href="#SkIRect_top">top</a>, <a href="#SkIRect_right">right</a>, <a href="#SkIRect_bottom">bottom</a>). Does not <a href="#SkIRect_sort">sort</a> +construction. + +Returns true if <a href="SkRect_Reference#Rect">Rect</a> <a href="#SkIRect_contains">contains</a> construction. +Asserts if <a href="#IRect">IRect</a> is empty or construction is empty, and if <a href="undocumented#SK_DEBUG">SK DEBUG</a> is defined. + +Return is undefined if <a href="SkRect_Reference#Rect">Rect</a> is empty or construction is empty. + +### Parameters + +<table> <tr> <td><a name="SkIRect_containsNoEmptyCheck_left"> <code><strong>left </strong></code> </a></td> <td> +<a href="#SkIRect_x">x</a> minimum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkIRect_containsNoEmptyCheck_top"> <code><strong>top </strong></code> </a></td> <td> +<a href="#SkIRect_y">y</a> minimum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkIRect_containsNoEmptyCheck_right"> <code><strong>right </strong></code> </a></td> <td> +<a href="#SkIRect_x">x</a> maximum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkIRect_containsNoEmptyCheck_bottom"> <code><strong>bottom </strong></code> </a></td> <td> +<a href="#SkIRect_y">y</a> maximum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> +</table> + +### Return Value + +true if all sides of <a href="#IRect">IRect</a> are outside construction + +### Example + +<div><fiddle-embed name="fef2a36bee224e92500199fa9d3cbb8b"> + +#### Example Output + +~~~~ +rect: (30, 50, 40, 60) contains (30, 50, 31, 51) +rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50) +rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60) +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_contains">contains</a> <a href="#SkRect_contains">SkRect::contains</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool containsNoEmptyCheck(const SkIRect& r) const +</pre> + +Returns true if <a href="SkRect_Reference#Rect">Rect</a> <a href="#SkIRect_contains">contains</a> construction. +Asserts if <a href="#IRect">IRect</a> is empty or construction is empty, and if <a href="undocumented#SK_DEBUG">SK DEBUG</a> is defined. + +Return is undefined if <a href="SkRect_Reference#Rect">Rect</a> is empty or construction is empty. + +### Parameters + +<table> <tr> <td><a name="SkIRect_containsNoEmptyCheck_2_r"> <code><strong>r </strong></code> </a></td> <td> +<a href="SkRect_Reference#Rect">Rect</a> contained</td> + </tr> +</table> + +### Return Value + +true if all sides of <a href="#IRect">IRect</a> are outside <a href="#SkIRect_containsNoEmptyCheck_2_r">r</a> + +### Example + +<div><fiddle-embed name="8f91f58001d9c10420eb146fbc169af4"> + +#### Example Output + +~~~~ +rect: (30, 50, 40, 60) contains (30, 50, 31, 51) +rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50) +rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60) +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_contains">contains</a> <a href="#SkRect_contains">SkRect::contains</a> + +--- + +# <a name="Intersection"></a> Intersection +IRects <a href="#SkIRect_intersect">intersect</a> when they enclose a common area. To <a href="#SkIRect_intersect">intersect</a>, each of the pair +must describe area; <a href="#SkIRect_fLeft">fLeft</a> is less than <a href="#SkIRect_fRight">fRight</a>, and <a href="#SkIRect_fTop">fTop</a> is less than <a href="#SkIRect_fBottom">fBottom</a>; +empty() returns false. The intersection of <a href="#IRect">IRect</a> a and <a href="#IRect">IRect</a> b can be described by: +(max(a.fLeft, b.fLeft), max(a.fTop, b.fTop), +min(a.fRight, b.fRight), min(a.fBottom, b.fBottom))The intersection is only meaningful if the resulting <a href="#IRect">IRect</a> is not empty and +describes an area: <a href="#SkIRect_fLeft">fLeft</a> is less than <a href="#SkIRect_fRight">fRight</a>, and <a href="#SkIRect_fTop">fTop</a> is less than <a href="#SkIRect_fBottom">fBottom</a>. + +<a name="SkIRect_intersect"></a> +## intersect + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool intersect(const SkIRect& r) +</pre> + +Returns true if <a href="#IRect">IRect</a> intersects <a href="#SkIRect_intersect_r">r</a>, and sets <a href="#IRect">IRect</a> to intersection. +Returns false if <a href="#IRect">IRect</a> does not <a href="#SkIRect_intersect">intersect</a> <a href="#SkIRect_intersect_r">r</a>, and leaves <a href="#IRect">IRect</a> unchanged. + +Returns false if either <a href="#SkIRect_intersect_r">r</a> or <a href="#IRect">IRect</a> is empty, leaving <a href="#IRect">IRect</a> unchanged. + +### Parameters + +<table> <tr> <td><a name="SkIRect_intersect_r"> <code><strong>r </strong></code> </a></td> <td> +limit of result</td> + </tr> +</table> + +### Return Value + +true if <a href="#SkIRect_intersect_r">r</a> and <a href="SkRect_Reference#Rect">Rect</a> have area in common + +### Example + +<div><fiddle-embed name="2be1302480e54a767e25cbeed5d41b41"><div>Two <a href="undocumented#SkDebugf">SkDebugf</a> calls are required. If the calls are combined, their arguments +may not be evaluated in <a href="#SkIRect_left">left</a> to <a href="#SkIRect_right">right</a> order: the printed intersection may +be before or after the call to <a href="#SkIRect_intersect">intersect</a>.</div> + +#### Example Output + +~~~~ +intersection: 30, 60, 50, 80 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_Intersects">Intersects</a> <a href="#SkIRect_intersectNoEmptyCheck">intersectNoEmptyCheck</a> <a href="#SkIRect_join">join</a> <a href="#SkRect_intersect">SkRect::intersect</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& a, const SkIRect& b) +</pre> + +Returns true if <a href="#SkIRect_intersect_2_a">a</a> intersects <a href="#SkIRect_intersect_2_b">b</a>, and sets <a href="#IRect">IRect</a> to intersection. +Returns false if <a href="#SkIRect_intersect_2_a">a</a> does not <a href="#SkIRect_intersect">intersect</a> <a href="#SkIRect_intersect_2_b">b</a>, and leaves <a href="#IRect">IRect</a> unchanged. + +Returns false if either <a href="#SkIRect_intersect_2_a">a</a> or <a href="#SkIRect_intersect_2_b">b</a> is empty, leaving <a href="#IRect">IRect</a> unchanged. + +### Parameters + +<table> <tr> <td><a name="SkIRect_intersect_2_a"> <code><strong>a </strong></code> </a></td> <td> +<a href="#IRect">IRect</a> to <a href="#SkIRect_intersect">intersect</a></td> + </tr> <tr> <td><a name="SkIRect_intersect_2_b"> <code><strong>b </strong></code> </a></td> <td> +<a href="#IRect">IRect</a> to <a href="#SkIRect_intersect">intersect</a></td> + </tr> +</table> + +### Return Value + +true if <a href="#SkIRect_intersect_2_a">a</a> and <a href="#SkIRect_intersect_2_b">b</a> have area in common + +### Example + +<div><fiddle-embed name="b2db0573aacf99ca52776c5522459d02"> + +#### Example Output + +~~~~ +intersection: 30, 60, 50, 80 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_Intersects">Intersects</a> <a href="#SkIRect_intersectNoEmptyCheck">intersectNoEmptyCheck</a> <a href="#SkIRect_join">join</a> <a href="#SkRect_intersect">SkRect::intersect</a> + +--- + +<a name="SkIRect_intersectNoEmptyCheck"></a> +## intersectNoEmptyCheck + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool SK_WARN_UNUSED_RESULT intersectNoEmptyCheck(const SkIRect& a, + const SkIRect& b) +</pre> + +Returns true if <a href="#SkIRect_intersectNoEmptyCheck_a">a</a> intersects <a href="#SkIRect_intersectNoEmptyCheck_b">b</a>, and sets <a href="#IRect">IRect</a> to intersection. +Returns false if <a href="#SkIRect_intersectNoEmptyCheck_a">a</a> does not <a href="#SkIRect_intersect">intersect</a> <a href="#SkIRect_intersectNoEmptyCheck_b">b</a>, and leaves <a href="#IRect">IRect</a> unchanged. + +Asserts if either <a href="#SkIRect_intersectNoEmptyCheck_a">a</a> or <a href="#SkIRect_intersectNoEmptyCheck_b">b</a> is empty, and if <a href="undocumented#SK_DEBUG">SK DEBUG</a> is defined. + +### Parameters + +<table> <tr> <td><a name="SkIRect_intersectNoEmptyCheck_a"> <code><strong>a </strong></code> </a></td> <td> +<a href="#IRect">IRect</a> to <a href="#SkIRect_intersect">intersect</a></td> + </tr> <tr> <td><a name="SkIRect_intersectNoEmptyCheck_b"> <code><strong>b </strong></code> </a></td> <td> +<a href="#IRect">IRect</a> to <a href="#SkIRect_intersect">intersect</a></td> + </tr> +</table> + +### Return Value + +true if <a href="#SkIRect_intersectNoEmptyCheck_a">a</a> and <a href="#SkIRect_intersectNoEmptyCheck_b">b</a> have area in common + +### Example + +<div><fiddle-embed name="2b3e26ccba1cba3d961645f0824621ac"> + +#### Example Output + +~~~~ +intersection: 30, 60, 50, 80 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_Intersects">Intersects</a> <a href="#SkIRect_intersect">intersect</a> <a href="#SkIRect_join">join</a> <a href="#SkRect_intersect">SkRect::intersect</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool intersect(int32_t left, int32_t top, int32_t right, int32_t bottom) +</pre> + +Constructs <a href="#IRect">IRect</a> to <a href="#SkIRect_intersect">intersect</a> from (<a href="#SkIRect_left">left</a>, <a href="#SkIRect_top">top</a>, <a href="#SkIRect_right">right</a>, <a href="#SkIRect_bottom">bottom</a>). Does not <a href="#SkIRect_sort">sort</a> +construction. + +Returns true if <a href="#IRect">IRect</a> intersects construction, and sets <a href="#IRect">IRect</a> to intersection. +Returns false if <a href="#IRect">IRect</a> does not <a href="#SkIRect_intersect">intersect</a> construction, and leaves <a href="#IRect">IRect</a> unchanged. + +Returns false if either construction or <a href="#IRect">IRect</a> is empty, leaving <a href="#IRect">IRect</a> unchanged. + +### Parameters + +<table> <tr> <td><a name="SkIRect_intersect_3_left"> <code><strong>left </strong></code> </a></td> <td> +<a href="#SkIRect_x">x</a> minimum of constructed <a href="#IRect">IRect</a></td> + </tr> <tr> <td><a name="SkIRect_intersect_3_top"> <code><strong>top </strong></code> </a></td> <td> +<a href="#SkIRect_y">y</a> minimum of constructed <a href="#IRect">IRect</a></td> + </tr> <tr> <td><a name="SkIRect_intersect_3_right"> <code><strong>right </strong></code> </a></td> <td> +<a href="#SkIRect_x">x</a> maximum of constructed <a href="#IRect">IRect</a></td> + </tr> <tr> <td><a name="SkIRect_intersect_3_bottom"> <code><strong>bottom </strong></code> </a></td> <td> +<a href="#SkIRect_y">y</a> maximum of constructed <a href="#IRect">IRect</a></td> + </tr> +</table> + +### Return Value + +true if construction and <a href="#IRect">IRect</a> have area in common + +### Example + +<div><fiddle-embed name="4e6f580a3906c08a5faee524f7e72334"><div>Two <a href="undocumented#SkDebugf">SkDebugf</a> calls are required. If the calls are combined, their arguments +may not be evaluated in <a href="#SkIRect_left">left</a> to <a href="#SkIRect_right">right</a> order: the printed intersection may +be before or after the call to <a href="#SkIRect_intersect">intersect</a>.</div> + +#### Example Output + +~~~~ +intersection: 30, 60, 50, 80 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_intersectNoEmptyCheck">intersectNoEmptyCheck</a> <a href="#SkIRect_Intersects">Intersects</a> <a href="#SkIRect_join">join</a> <a href="#SkRect_intersect">SkRect::intersect</a> + +--- + +<a name="SkIRect_Intersects"></a> +## Intersects + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static bool Intersects(const SkIRect& a, const SkIRect& b) +</pre> + +Returns true if <a href="#SkIRect_Intersects_a">a</a> intersects <a href="#SkIRect_Intersects_b">b</a>. +Returns false if either <a href="#SkIRect_Intersects_a">a</a> or <a href="#SkIRect_Intersects_b">b</a> is empty, or do not <a href="#SkIRect_intersect">intersect</a>. + +### Parameters + +<table> <tr> <td><a name="SkIRect_Intersects_a"> <code><strong>a </strong></code> </a></td> <td> +<a href="#IRect">IRect</a> to <a href="#SkIRect_intersect">intersect</a></td> + </tr> <tr> <td><a name="SkIRect_Intersects_b"> <code><strong>b </strong></code> </a></td> <td> +<a href="#IRect">IRect</a> to <a href="#SkIRect_intersect">intersect</a></td> + </tr> +</table> + +### Return Value + +true if <a href="#SkIRect_Intersects_a">a</a> and <a href="#SkIRect_Intersects_b">b</a> have area in common + +### Example + +<div><fiddle-embed name="0c67cf8981389efc7108369fb9b7976b"> + +#### Example Output + +~~~~ +intersection +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_IntersectsNoEmptyCheck">IntersectsNoEmptyCheck</a> <a href="#SkIRect_intersect">intersect</a> <a href="#SkRect_intersect">SkRect::intersect</a> + +--- + +<a name="SkIRect_IntersectsNoEmptyCheck"></a> +## IntersectsNoEmptyCheck + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static bool IntersectsNoEmptyCheck(const SkIRect& a, const SkIRect& b) +</pre> + +Returns true if <a href="#SkIRect_IntersectsNoEmptyCheck_a">a</a> intersects <a href="#SkIRect_IntersectsNoEmptyCheck_b">b</a>. +Asserts if either <a href="#SkIRect_IntersectsNoEmptyCheck_a">a</a> or <a href="#SkIRect_IntersectsNoEmptyCheck_b">b</a> is empty, and if <a href="undocumented#SK_DEBUG">SK DEBUG</a> is defined. + +### Parameters + +<table> <tr> <td><a name="SkIRect_IntersectsNoEmptyCheck_a"> <code><strong>a </strong></code> </a></td> <td> +<a href="#IRect">IRect</a> to <a href="#SkIRect_intersect">intersect</a></td> + </tr> <tr> <td><a name="SkIRect_IntersectsNoEmptyCheck_b"> <code><strong>b </strong></code> </a></td> <td> +<a href="#IRect">IRect</a> to <a href="#SkIRect_intersect">intersect</a></td> + </tr> +</table> + +### Return Value + +true if <a href="#SkIRect_IntersectsNoEmptyCheck_a">a</a> and <a href="#SkIRect_IntersectsNoEmptyCheck_b">b</a> have area in common + +### Example + +<div><fiddle-embed name="dba234d15162fb5b26e1a96529ca6a2a"> + +#### Example Output + +~~~~ +intersection +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_Intersects">Intersects</a> <a href="#SkIRect_intersect">intersect</a> <a href="#SkRect_intersect">SkRect::intersect</a> + +--- + +<a name="SkIRect_join"></a> +## join + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void join(int32_t left, int32_t top, int32_t right, int32_t bottom) +</pre> + +Constructs <a href="SkRect_Reference#Rect">Rect</a> to <a href="#SkIRect_intersect">intersect</a> from (<a href="#SkIRect_left">left</a>, <a href="#SkIRect_top">top</a>, <a href="#SkIRect_right">right</a>, <a href="#SkIRect_bottom">bottom</a>). Does not <a href="#SkIRect_sort">sort</a> +construction. + +Sets <a href="SkRect_Reference#Rect">Rect</a> to the union of itself and the construction. + +Has no effect if construction is empty. Otherwise, if <a href="SkRect_Reference#Rect">Rect</a> is empty, sets +<a href="SkRect_Reference#Rect">Rect</a> to construction. + +### Parameters + +<table> <tr> <td><a name="SkIRect_join_left"> <code><strong>left </strong></code> </a></td> <td> +<a href="#SkIRect_x">x</a> minimum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkIRect_join_top"> <code><strong>top </strong></code> </a></td> <td> +<a href="#SkIRect_y">y</a> minimum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkIRect_join_right"> <code><strong>right </strong></code> </a></td> <td> +<a href="#SkIRect_x">x</a> maximum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkIRect_join_bottom"> <code><strong>bottom </strong></code> </a></td> <td> +<a href="#SkIRect_y">y</a> maximum of constructed <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="c00ef06289d21db70340e465690e0e08"> + +#### Example Output + +~~~~ +join: 10, 20, 55, 65 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_set">set</a> <a href="#SkRect_join">SkRect::join</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void join(const SkIRect& r) +</pre> + +Sets <a href="SkRect_Reference#Rect">Rect</a> to the union of itself and <a href="#SkIRect_join_2_r">r</a>. + +Has no effect if <a href="#SkIRect_join_2_r">r</a> is empty. Otherwise, if <a href="SkRect_Reference#Rect">Rect</a> is empty, sets <a href="SkRect_Reference#Rect">Rect</a> to <a href="#SkIRect_join_2_r">r</a>. + +### Parameters + +<table> <tr> <td><a name="SkIRect_join_2_r"> <code><strong>r </strong></code> </a></td> <td> +expansion <a href="SkRect_Reference#Rect">Rect</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="75fd81c1d3512e63890d085593018876"> + +#### Example Output + +~~~~ +join: 10, 20, 55, 65 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_set">set</a> <a href="#SkRect_join">SkRect::join</a> + +--- + +<a name="SkIRect_sort"></a> +## sort + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void sort() +</pre> + +Swaps <a href="#SkIRect_fLeft">fLeft</a> and <a href="#SkIRect_fRight">fRight</a> if <a href="#SkIRect_fLeft">fLeft</a> is greater than <a href="#SkIRect_fRight">fRight</a>; and swaps +<a href="#SkIRect_fTop">fTop</a> and <a href="#SkIRect_fBottom">fBottom</a> if <a href="#SkIRect_fTop">fTop</a> is greater than <a href="#SkIRect_fBottom">fBottom</a>. Result may be empty, +and <a href="#SkIRect_width">width</a> and <a href="#SkIRect_height">height</a> will be zero or positive. + +### Example + +<div><fiddle-embed name="fa12547fcfd4c1aef3db1a1f6aae0fe4"> + +#### Example Output + +~~~~ +rect: 30, 50, 20, 10 +sorted: 20, 10, 30, 50 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_makeSorted">makeSorted</a> <a href="#SkRect_sort">SkRect::sort</a> + +--- + +<a name="SkIRect_makeSorted"></a> +## makeSorted + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkIRect makeSorted() const +</pre> + +Returns <a href="SkRect_Reference#Rect">Rect</a> with <a href="#SkIRect_fLeft">fLeft</a> and <a href="#SkIRect_fRight">fRight</a> swapped if <a href="#SkIRect_fLeft">fLeft</a> is greater than <a href="#SkIRect_fRight">fRight</a>; and +with <a href="#SkIRect_fTop">fTop</a> and <a href="#SkIRect_fBottom">fBottom</a> swapped if <a href="#SkIRect_fTop">fTop</a> is greater than <a href="#SkIRect_fBottom">fBottom</a>. Result may be empty; +and <a href="#SkIRect_width">width</a> and <a href="#SkIRect_height">height</a> will be zero or positive. + +### Return Value + +sorted <a href="#IRect">IRect</a> + +### Example + +<div><fiddle-embed name="de89926c374aa16427916900b89a3441"> + +#### Example Output + +~~~~ +rect: 30, 50, 20, 10 +sorted: 20, 10, 30, 50 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_sort">sort</a> <a href="#SkRect_makeSorted">SkRect::makeSorted</a> + +--- + +<a name="SkIRect_EmptyIRect"></a> +## EmptyIRect + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static const SkIRect& SK_WARN_UNUSED_RESULT EmptyIRect() +</pre> + +Returns a reference to immutable empty <a href="#IRect">IRect</a>, <a href="#SkIRect_set">set</a> to (0, 0, 0, 0). + +### Return Value + +global <a href="#IRect">IRect</a> <a href="#SkIRect_set">set</a> to all zeroes + +### Example + +<div><fiddle-embed name="65e0b9b52e907902630577941fb3ed6d"> + +#### Example Output + +~~~~ +rect: 0, 0, 0, 0 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_MakeEmpty">MakeEmpty</a> + +--- + diff --git a/site/user/api/SkPath_Reference.md b/site/user/api/SkPath_Reference.md index 8f5ad4b029..791dc17213 100644 --- a/site/user/api/SkPath_Reference.md +++ b/site/user/api/SkPath_Reference.md @@ -4227,7 +4227,7 @@ void dump(SkWStream* stream, bool forceClose, bool dumpAsHex) const Writes text representation of <a href="#Path">Path</a> to <a href="#SkPath_dump_stream">stream</a>. If <a href="#SkPath_dump_stream">stream</a> is nullptr, <a href="#SkPath_dump_2">dump</a> writes to standard output. Set <a href="#SkPath_dump_forceClose">forceClose</a> to true to get -edges used to fill <a href="#Path">Path</a>. Set <a href="#SkPath_dump_dumpAsHex">dumpAsHex</a> true to get exact binary representations +edges used to fill <a href="#Path">Path</a>. Set <a href="#SkPath_dump_dumpAsHex">dumpAsHex</a> true to generate exact binary representations of floating point numbers used in <a href="#Point_Array">Point Array</a> and <a href="#Weight">Conic Weights</a>. ### Parameters @@ -4318,8 +4318,6 @@ original <a href="#Path">Path</a>. Use instead of <a href="#SkPath_dump_2">dump</a> when submittingbug reports against <a href="undocumented#Skia">Skia</a>. -Slight value changes in <a href="#Point_Array">Point Array</a> may cause the bug to disappear. - ### Example <div><fiddle-embed name="72a92fe058e8b3be6c8a30fad7fd1266"> diff --git a/site/user/api/SkRect_Reference.md b/site/user/api/SkRect_Reference.md new file mode 100644 index 0000000000..e067bf379c --- /dev/null +++ b/site/user/api/SkRect_Reference.md @@ -0,0 +1,2998 @@ +SkRect Reference +=== + +# <a name="Rect"></a> Rect + +# <a name="SkRect"></a> Struct SkRect +<a href="#SkRect">SkRect</a> holds four <a href="undocumented#SkScalar">SkScalar</a> coordinates describing the upper and +lower bounds of a rectangle. <a href="#SkRect">SkRect</a> may be created from outer bounds or +from position, <a href="#SkRect_width">width</a>, and <a href="#SkRect_height">height</a>. <a href="#SkRect">SkRect</a> describes an area; if its <a href="#SkRect_right">right</a> +is less than or equal to its <a href="#SkRect_left">left</a>, or if its <a href="#SkRect_bottom">bottom</a> is less than or equal to +its <a href="#SkRect_top">top</a>, it is considered empty. + +<a href="#SkRect">SkRect</a> can be constructed from int values to avoid compiler warnings that +integer input cannot convert to <a href="undocumented#SkScalar">SkScalar</a> without loss of precision. + +# <a name="Overview"></a> Overview + +## <a name="Subtopics"></a> Subtopics + +| topics | description | +| --- | --- | + +## <a name="Operators"></a> Operators + +| description | function | +| --- | --- | +| friend bool <a href="#SkRect_not_equal_operator">operator!=(const SkRect& a, const SkRect& b)</a> | Returns true if member bits are unequal. | +| friend bool <a href="#SkRect_equal_operator">operator==(const SkRect& a, const SkRect& b)</a> | Returns true if member bits are equal. | + +## <a name="Member_Functions"></a> Member Functions + +| description | function | +| --- | --- | +| <a href="#SkRect_Intersects">Intersects</a> | Returns true if areas overlap. | +| <a href="#SkRect_Make">Make</a> | Constructs from <a href="#Size">ISize</a> returning (0, 0, <a href="#SkRect_width">width</a>, <a href="#SkRect_height">height</a>). | +| <a href="#SkRect_MakeEmpty">MakeEmpty</a> | Constructs from bounds of (0, 0, 0, 0). | +| <a href="#SkRect_MakeFromIRect">MakeFromIRect</a> | Deprecated. | +| <a href="#SkRect_MakeIWH">MakeIWH</a> | Constructs from int input returning (0, 0, <a href="#SkRect_width">width</a>, <a href="#SkRect_height">height</a>). | +| <a href="#SkRect_MakeLTRB">MakeLTRB</a> | Constructs from <a href="undocumented#SkScalar">SkScalar</a> <a href="#SkRect_left">left</a>, <a href="#SkRect_top">top</a>, <a href="#SkRect_right">right</a>, <a href="#SkRect_bottom">bottom</a>. | +| <a href="#SkRect_MakeLargest">MakeLargest</a> | Constructs (<a href="undocumented#SK_ScalarMin">SK ScalarMin</a>, <a href="undocumented#SK_ScalarMin">SK ScalarMin</a>, <a href="undocumented#SK_ScalarMax">SK ScalarMax</a>, <a href="undocumented#SK_ScalarMax">SK ScalarMax</a>). | +| <a href="#SkRect_MakeSize">MakeSize</a> | Constructs from <a href="undocumented#Size">Size</a> returning (0, 0, <a href="#SkRect_width">width</a>, <a href="#SkRect_height">height</a>). | +| <a href="#SkRect_MakeWH">MakeWH</a> | Constructs from <a href="undocumented#SkScalar">SkScalar</a> input returning (0, 0, <a href="#SkRect_width">width</a>, <a href="#SkRect_height">height</a>). | +| <a href="#SkRect_MakeXYWH">MakeXYWH</a> | Constructs from <a href="undocumented#SkScalar">SkScalar</a> input returning (<a href="#SkRect_x">x</a>, <a href="#SkRect_y">y</a>, <a href="#SkRect_width">width</a>, <a href="#SkRect_height">height</a>). | +| <a href="#SkRect_asScalars">asScalars</a> | Returns pointer to members as array. | +| <a href="#SkRect_bottom">bottom</a> | Returns larger bounds in <a href="#SkRect_y">y</a>, if sorted. | +| <a href="#SkRect_centerX">centerX</a> | Returns midpoint in <a href="#SkRect_x">x</a>. | +| <a href="#SkRect_centerY">centerY</a> | Returns midpoint in <a href="#SkRect_y">y</a>. | +| <a href="#SkRect_contains">contains</a> | Returns true if points are equal or inside. | +| <a href="#SkRect_dump_2">dump</a> | Sends text representation using floats to standard output. | +| <a href="#SkRect_dumpHex">dumpHex</a> | Sends text representation using hexadecimal to standard output. | +| <a href="#SkRect_growToInclude">growToInclude</a> | Sets to union of bounds and one or more <a href="#Point">Points</a>. | +| <a href="#SkRect_height">height</a> | Returns span in <a href="#SkRect_y">y</a>. | +| <a href="#SkRect_inset">inset</a> | Moves the sides symmetrically about the center. | +| <a href="#SkRect_intersect">intersect</a> | Sets to shared area; returns true if not empty. | +| <a href="#SkRect_intersects">intersects</a> | Returns true if areas overlap. | +| <a href="#SkRect_isEmpty">isEmpty</a> | Returns true if <a href="#SkRect_width">width</a> or <a href="#SkRect_height">height</a> are zero or negative. | +| <a href="#SkRect_isFinite">isFinite</a> | Returns true if no member is infinite or <a href="undocumented#NaN">NaN</a>. | +| <a href="#SkRect_isLargest">isLargest</a> | Returns equal to (<a href="undocumented#SK_ScalarMin">SK ScalarMin</a>, <a href="undocumented#SK_ScalarMin">SK ScalarMin</a>, <a href="undocumented#SK_ScalarMax">SK ScalarMax</a>, <a href="undocumented#SK_ScalarMax">SK ScalarMax</a>). | +| <a href="#SkRect_isSorted">isSorted</a> | Returns true if <a href="#SkRect_width">width</a> or <a href="#SkRect_height">height</a> are zero or positive. | +| <a href="#SkRect_iset">iset</a> | Sets to int input (<a href="#SkRect_left">left</a>, <a href="#SkRect_top">top</a>, <a href="#SkRect_right">right</a>, <a href="#SkRect_bottom">bottom</a>). | +| <a href="#SkRect_isetWH">isetWH</a> | Sets to int input (0, 0, <a href="#SkRect_width">width</a>, <a href="#SkRect_height">height</a>). | +| <a href="#SkRect_join">join</a> | Sets to union of bounds. | +| <a href="#SkRect_joinNonEmptyArg">joinNonEmptyArg</a> | Sets to union of bounds, asserting that argument is not empty. | +| <a href="#SkRect_joinPossiblyEmptyRect">joinPossiblyEmptyRect</a> | Sets to union of bounds. Skips empty check for both. | +| <a href="#SkRect_left">left</a> | Returns smaller bounds in <a href="#SkRect_x">x</a>, if sorted. | +| <a href="#SkRect_makeInset">makeInset</a> | Constructs from sides moved symmetrically about the center. | +| <a href="#SkRect_makeOffset">makeOffset</a> | Constructs from translated sides. | +| <a href="#SkRect_makeOutset">makeOutset</a> | Constructs from sides moved symmetrically about the center. | +| <a href="#SkRect_makeSorted">makeSorted</a> | Constructs, ordering sides from smaller to larger. | +| <a href="#SkRect_offset">offset</a> | Translates sides without changing <a href="#SkRect_width">width</a> and <a href="#SkRect_height">height</a>. | +| <a href="#SkRect_offsetTo">offsetTo</a> | Translates to (<a href="#SkRect_x">x</a>, <a href="#SkRect_y">y</a>) without changing <a href="#SkRect_width">width</a> and <a href="#SkRect_height">height</a>. | +| <a href="#SkRect_outset">outset</a> | Moves the sides symmetrically about the center. | +| <a href="#SkRect_right">right</a> | Returns larger bounds in <a href="#SkRect_x">x</a>, if sorted. | +| <a href="#SkRect_round_2">round</a> | Sets members to nearest integer value. | +| <a href="#SkRect_roundIn">roundIn</a> | Sets members to nearest integer value towards opposite. | +| <a href="#SkRect_roundOut">roundOut</a> | Sets members to nearest integer value away from opposite. | +| <a href="#SkRect_set">set</a> | Sets to <a href="undocumented#SkScalar">SkScalar</a> input (<a href="#SkRect_left">left</a>, <a href="#SkRect_top">top</a>, <a href="#SkRect_right">right</a>, <a href="#SkRect_bottom">bottom</a>) and others. | +| <a href="#SkRect_setBounds">setBounds</a> | Sets to upper and lower limits of <a href="undocumented#Point">Point</a> array. | +| <a href="#SkRect_setBoundsCheck">setBoundsCheck</a> | Sets to upper and lower limits of <a href="undocumented#Point">Point</a> array. | +| <a href="#SkRect_setEmpty">setEmpty</a> | Sets to (0, 0, 0, 0). | +| <a href="#SkRect_setLTRB">setLTRB</a> | Sets to <a href="undocumented#SkScalar">SkScalar</a> input (<a href="#SkRect_left">left</a>, <a href="#SkRect_top">top</a>, <a href="#SkRect_right">right</a>, <a href="#SkRect_bottom">bottom</a>). | +| <a href="#SkRect_setLargest">setLargest</a> | Sets to (<a href="undocumented#SK_ScalarMin">SK ScalarMin</a>, <a href="undocumented#SK_ScalarMin">SK ScalarMin</a>, <a href="undocumented#SK_ScalarMax">SK ScalarMax</a>, <a href="undocumented#SK_ScalarMax">SK ScalarMax</a>). | +| <a href="#SkRect_setLargestInverted">setLargestInverted</a> | Sets to (<a href="undocumented#SK_ScalarMax">SK ScalarMax</a>, <a href="undocumented#SK_ScalarMax">SK ScalarMax</a>, <a href="undocumented#SK_ScalarMin">SK ScalarMin</a>, <a href="undocumented#SK_ScalarMin">SK ScalarMin</a>). | +| <a href="#SkRect_setWH">setWH</a> | Sets to <a href="undocumented#SkScalar">SkScalar</a> input (0, 0, <a href="#SkRect_width">width</a>, <a href="#SkRect_height">height</a>). | +| <a href="#SkRect_setXYWH">setXYWH</a> | Sets to <a href="undocumented#SkScalar">SkScalar</a> input (<a href="#SkRect_x">x</a>, <a href="#SkRect_y">y</a>, <a href="#SkRect_width">width</a>, <a href="#SkRect_height">height</a>). | +| <a href="#SkRect_sort">sort</a> | Orders sides from smaller to larger. | +| <a href="#SkRect_toQuad">toQuad</a> | Returns four corners as <a href="undocumented#Point">Point</a>. | +| <a href="#SkRect_top">top</a> | Returns smaller bounds in <a href="#SkRect_y">y</a>, if sorted. | +| <a href="#SkRect_width">width</a> | Returns span in <a href="#SkRect_x">x</a>. | +| <a href="#SkRect_x">x</a> | Returns bounds <a href="#SkRect_left">left</a>. | +| <a href="#SkRect_y">y</a> | Returns bounds <a href="#SkRect_top">top</a>. | + +<a name="SkRect_fLeft"> <code><strong>SkScalar fLeft</strong></code> </a> + +May contain any value, including infinities and <a href="undocumented#NaN">NaN</a>. The smaller of the +horizontal values when sorted. When equal to or greater than <a href="#SkRect_fRight">fRight</a>, <a href="#Rect">Rect</a> is empty. + +<a name="SkRect_fTop"> <code><strong>SkScalar fTop</strong></code> </a> + +May contain any value, including infinities and <a href="undocumented#NaN">NaN</a>. The smaller of the +vertical values when sorted. When equal to or greater than <a href="#SkRect_fBottom">fBottom</a>, <a href="#Rect">Rect</a> is empty. + +<a name="SkRect_fRight"> <code><strong>SkScalar fRight</strong></code> </a> + +May contain any value, including infinities and <a href="undocumented#NaN">NaN</a>. The larger of the +horizontal values when sorted. When equal to or less than <a href="#SkRect_fLeft">fLeft</a>, <a href="#Rect">Rect</a> is empty. + +<a name="SkRect_fBottom"> <code><strong>SkScalar fBottom</strong></code> </a> + +May contain any value, including infinities and <a href="undocumented#NaN">NaN</a>. The larger of the +vertical values when sorted. When equal to or less than <a href="#SkRect_fTop">fTop</a>, <a href="#Rect">Rect</a> is empty. + +<a name="SkRect_MakeEmpty"></a> +## MakeEmpty + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static constexpr SkRect SK_WARN_UNUSED_RESULT MakeEmpty() +</pre> + +Returns constructed <a href="#Rect">Rect</a> <a href="#SkRect_set">set</a> to (0, 0, 0, 0). +Many other rectangles are empty; if <a href="#SkRect_left">left</a> is equal to or greater than <a href="#SkRect_right">right</a>, +or if <a href="#SkRect_top">top</a> is equal to or greater than <a href="#SkRect_bottom">bottom</a>. Setting all members to zero +is a convenience, but does not designate a special empty rectangle. + +### Return Value + +bounds (0, 0, 0, 0) + +### Example + +<div><fiddle-embed name="2e262d0ac4b8ef51695e0525fc3ecdf6"> + +#### Example Output + +~~~~ +MakeEmpty isEmpty: true +offset rect isEmpty: true +inset rect isEmpty: true +outset rect isEmpty: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_isEmpty">isEmpty</a> <a href="#SkRect_setEmpty">setEmpty</a> <a href="#SkRect_setLargestInverted">setLargestInverted</a> <a href="#SkIRect_MakeEmpty">SkIRect::MakeEmpty</a> + +--- + +<a name="SkRect_MakeLargest"></a> +## MakeLargest + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static SkRect SK_WARN_UNUSED_RESULT MakeLargest() +</pre> + +Returns constructed <a href="#Rect">Rect</a> setting <a href="#SkRect_left">left</a> and <a href="#SkRect_top">top</a> to most negative finite value, and +setting <a href="#SkRect_right">right</a> and <a href="#SkRect_bottom">bottom</a> to most positive finite value. + +### Return Value + +bounds (<a href="undocumented#SK_ScalarMin">SK ScalarMin</a>, <a href="undocumented#SK_ScalarMin">SK ScalarMin</a>, <a href="undocumented#SK_ScalarMax">SK ScalarMax</a>, <a href="undocumented#SK_ScalarMax">SK ScalarMax</a>) + +### Example + +<div><fiddle-embed name="42774381948ce88ec19b5c0d16a84bd7"> + +#### Example Output + +~~~~ +MakeLargest isLargest: true +MakeLargest isFinite: true +outset a little isLargest: true +outset a little isFinite: true +outset a little more isLargest: false +outset a little more isFinite: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_isLargest">isLargest</a> <a href="#SkRect_setLargest">setLargest</a> <a href="#SkIRect_MakeLargest">SkIRect::MakeLargest</a> + +--- + +<a name="SkRect_MakeWH"></a> +## MakeWH + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static SkRect SK_WARN_UNUSED_RESULT MakeWH(SkScalar w, SkScalar h) +</pre> + +Returns constructed <a href="#Rect">Rect</a> <a href="#SkRect_set">set</a> to <a href="undocumented#SkScalar">SkScalar</a> values (0, 0, <a href="#SkRect_MakeWH_w">w</a>, <a href="#SkRect_MakeWH_h">h</a>). Does not +validate input; <a href="#SkRect_MakeWH_w">w</a> or <a href="#SkRect_MakeWH_h">h</a> may be negative. + +Passing integer values may generate a compiler warning since <a href="#Rect">Rect</a> cannot +represent 32-bit integers exactly. Use <a href="SkIRect_Reference#SkIRect">SkIRect</a> for an exact integer rectangle. + +### Parameters + +<table> <tr> <td><a name="SkRect_MakeWH_w"> <code><strong>w </strong></code> </a></td> <td> +<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkRect_width">width</a> of constructed <a href="#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkRect_MakeWH_h"> <code><strong>h </strong></code> </a></td> <td> +<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkRect_height">height</a> of constructed <a href="#Rect">Rect</a></td> + </tr> +</table> + +### Return Value + +bounds (0, 0, <a href="#SkRect_MakeWH_w">w</a>, <a href="#SkRect_MakeWH_h">h</a>) + +### Example + +<div><fiddle-embed name="8009d30f431e01f8aea4808e9017d9bf"> + +#### Example Output + +~~~~ +all equal +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_MakeSize">MakeSize</a> <a href="#SkRect_MakeXYWH">MakeXYWH</a> <a href="#SkRect_MakeIWH">MakeIWH</a> <a href="#SkRect_setWH">setWH</a> <a href="#SkIRect_MakeWH">SkIRect::MakeWH</a> + +--- + +<a name="SkRect_MakeIWH"></a> +## MakeIWH + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static SkRect SK_WARN_UNUSED_RESULT MakeIWH(int w, int h) +</pre> + +Returns constructed <a href="#Rect">Rect</a> <a href="#SkRect_set">set</a> to integer values (0, 0, <a href="#SkRect_MakeIWH_w">w</a>, <a href="#SkRect_MakeIWH_h">h</a>). Does not validate +input; <a href="#SkRect_MakeIWH_w">w</a> or <a href="#SkRect_MakeIWH_h">h</a> may be negative. + +Use to avoid a compiler warning that input may lose precision when stored. +Use <a href="SkIRect_Reference#SkIRect">SkIRect</a> for an exact integer rectangle. + +### Parameters + +<table> <tr> <td><a name="SkRect_MakeIWH_w"> <code><strong>w </strong></code> </a></td> <td> +integer <a href="#SkRect_width">width</a> of constructed <a href="#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkRect_MakeIWH_h"> <code><strong>h </strong></code> </a></td> <td> +integer <a href="#SkRect_height">height</a> of constructed <a href="#Rect">Rect</a></td> + </tr> +</table> + +### Return Value + +bounds (0, 0, <a href="#SkRect_MakeIWH_w">w</a>, <a href="#SkRect_MakeIWH_h">h</a>) + +### Example + +<div><fiddle-embed name="faa660ac19eaddc3f3eab57a0bddfdcb"> + +#### Example Output + +~~~~ +i_rect width: 25 f_rect width:25 +i_rect width: 125000111 f_rect width:125000112 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_MakeXYWH">MakeXYWH</a> <a href="#SkRect_MakeWH">MakeWH</a> <a href="#SkRect_isetWH">isetWH</a> <a href="#SkIRect_MakeWH">SkIRect::MakeWH</a> + +--- + +<a name="SkRect_MakeSize"></a> +## MakeSize + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static SkRect SK_WARN_UNUSED_RESULT MakeSize(const SkSize& size) +</pre> + +Returns constructed <a href="#Rect">Rect</a> <a href="#SkRect_set">set</a> to (0, 0, <a href="#SkRect_MakeSize_size">size</a>.<a href="#SkRect_width">width</a>, <a href="#SkRect_MakeSize_size">size</a>.<a href="#SkRect_height">height</a>). Does not +validate input; <a href="#SkRect_MakeSize_size">size</a>.<a href="#SkRect_width">width</a> or <a href="#SkRect_MakeSize_size">size</a>.<a href="#SkRect_height">height</a> may be negative. + +### Parameters + +<table> <tr> <td><a name="SkRect_MakeSize_size"> <code><strong>size </strong></code> </a></td> <td> +<a href="undocumented#SkScalar">SkScalar</a> values for <a href="#Rect">Rect</a> <a href="#SkRect_width">width</a> and <a href="#SkRect_height">height</a></td> + </tr> +</table> + +### Return Value + +bounds (0, 0, <a href="#SkRect_MakeSize_size">size</a>.<a href="#SkRect_width">width</a>, <a href="#SkRect_MakeSize_size">size</a>.<a href="#SkRect_height">height</a>) + +### Example + +<div><fiddle-embed name="ab2c1a55016c8de9172b77fdf69e00a2"> + +#### Example Output + +~~~~ +rect width: 25.5 height: 35.5 +floor width: 25 height: 35 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_MakeWH">MakeWH</a> <a href="#SkRect_MakeXYWH">MakeXYWH</a> <a href="#SkRect_MakeIWH">MakeIWH</a> <a href="#SkRect_setWH">setWH</a> <a href="#SkIRect_MakeWH">SkIRect::MakeWH</a> + +--- + +<a name="SkRect_MakeLTRB"></a> +## MakeLTRB + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static constexpr SkRect SK_WARN_UNUSED_RESULT MakeLTRB(SkScalar l, SkScalar t, + SkScalar r, SkScalar b) +</pre> + +Returns constructed <a href="#Rect">Rect</a> <a href="#SkRect_set">set</a> to (<a href="#SkRect_MakeLTRB_l">l</a>, <a href="#SkRect_MakeLTRB_t">t</a>, <a href="#SkRect_MakeLTRB_r">r</a>, <a href="#SkRect_MakeLTRB_b">b</a>). Does not <a href="#SkRect_sort">sort</a> input; <a href="#Rect">Rect</a> may +result in <a href="#SkRect_fLeft">fLeft</a> greater than <a href="#SkRect_fRight">fRight</a>, or <a href="#SkRect_fTop">fTop</a> greater than <a href="#SkRect_fBottom">fBottom</a>. + +### Parameters + +<table> <tr> <td><a name="SkRect_MakeLTRB_l"> <code><strong>l </strong></code> </a></td> <td> +<a href="undocumented#SkScalar">SkScalar</a> stored in <a href="#SkRect_fLeft">fLeft</a></td> + </tr> <tr> <td><a name="SkRect_MakeLTRB_t"> <code><strong>t </strong></code> </a></td> <td> +<a href="undocumented#SkScalar">SkScalar</a> stored in <a href="#SkRect_fTop">fTop</a></td> + </tr> <tr> <td><a name="SkRect_MakeLTRB_r"> <code><strong>r </strong></code> </a></td> <td> +<a href="undocumented#SkScalar">SkScalar</a> stored in <a href="#SkRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkRect_MakeLTRB_b"> <code><strong>b </strong></code> </a></td> <td> +<a href="undocumented#SkScalar">SkScalar</a> stored in <a href="#SkRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Return Value + +bounds (<a href="#SkRect_MakeLTRB_l">l</a>, <a href="#SkRect_MakeLTRB_t">t</a>, <a href="#SkRect_MakeLTRB_r">r</a>, <a href="#SkRect_MakeLTRB_b">b</a>) + +### Example + +<div><fiddle-embed name="158b8dd9d02d65a5ae5ab7d1595a5b4c"> + +#### Example Output + +~~~~ +rect: 5, 35, 15, 25 isEmpty: true +rect: 5, 25, 15, 35 isEmpty: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_MakeXYWH">MakeXYWH</a> <a href="#SkIRect_MakeLTRB">SkIRect::MakeLTRB</a> + +--- + +<a name="SkRect_MakeXYWH"></a> +## MakeXYWH + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static SkRect SK_WARN_UNUSED_RESULT MakeXYWH(SkScalar x, SkScalar y, SkScalar w, + SkScalar h) +</pre> + +Returns constructed <a href="#Rect">Rect</a> <a href="#SkRect_set">set</a> to(<a href="#SkRect_x">x</a>, <a href="#SkRect_y">y</a>, <a href="#SkRect_x">x</a> + <a href="#SkRect_MakeXYWH_w">w</a>, <a href="#SkRect_y">y</a> + <a href="#SkRect_MakeXYWH_h">h</a>). +Does not validate input; +<a href="#SkRect_MakeXYWH_w">w</a> or <a href="#SkRect_MakeXYWH_h">h</a> may be negative. + +### Parameters + +<table> <tr> <td><a name="SkRect_MakeXYWH_x"> <code><strong>x </strong></code> </a></td> <td> +stored in <a href="#SkRect_fLeft">fLeft</a></td> + </tr> <tr> <td><a name="SkRect_MakeXYWH_y"> <code><strong>y </strong></code> </a></td> <td> +stored in <a href="#SkRect_fTop">fTop</a></td> + </tr> <tr> <td><a name="SkRect_MakeXYWH_w"> <code><strong>w </strong></code> </a></td> <td> +added to <a href="#SkRect_x">x</a> and stored in <a href="#SkRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkRect_MakeXYWH_h"> <code><strong>h </strong></code> </a></td> <td> +added to <a href="#SkRect_y">y</a> and stored in <a href="#SkRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Return Value + +bounds (<a href="#SkRect_x">x</a>, <a href="#SkRect_y">y</a>, <a href="#SkRect_x">x</a> + <a href="#SkRect_MakeXYWH_w">w</a>, <a href="#SkRect_y">y</a> + <a href="#SkRect_MakeXYWH_h">h</a>) + +### Example + +<div><fiddle-embed name="38e464dba13be11ac21e210fbf3b5afc"> + +#### Example Output + +~~~~ +rect: 5, 35, -10, 60 isEmpty: true +rect: -10, 35, 5, 60 isEmpty: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_MakeLTRB">MakeLTRB</a> <a href="#SkIRect_MakeXYWH">SkIRect::MakeXYWH</a> + +--- + +<a name="SkRect_MakeFromIRect"></a> +## MakeFromIRect + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static SkRect SK_WARN_UNUSED_RESULT MakeFromIRect(const SkIRect& irect) +</pre> + +Deprecated. + +### Parameters + +<table> <tr> <td><a name="SkRect_MakeFromIRect_irect"> <code><strong>irect </strong></code> </a></td> <td> +integer rect</td> + </tr> +</table> + +### Return Value + +<a href="#SkRect_MakeFromIRect_irect">irect</a> as <a href="#SkRect">SkRect</a> + +### See Also + +<a href="#SkRect_Make">Make</a> + +--- + +<a name="SkRect_Make"></a> +## Make + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static SkRect Make(const SkISize& size) +</pre> + +Returns constructed <a href="SkIRect_Reference#IRect">IRect</a> <a href="#SkRect_set">set</a> to (0, 0, <a href="#SkRect_Make_size">size</a>.<a href="#SkRect_width">width</a>, <a href="#SkRect_Make_size">size</a>.<a href="#SkRect_height">height</a>). +Does not validate input; <a href="#SkRect_Make_size">size</a>.<a href="#SkRect_width">width</a> or <a href="#SkRect_Make_size">size</a>.<a href="#SkRect_height">height</a> may be negative. + +### Parameters + +<table> <tr> <td><a name="SkRect_Make_size"> <code><strong>size </strong></code> </a></td> <td> +integer values for <a href="#Rect">Rect</a> <a href="#SkRect_width">width</a> and <a href="#SkRect_height">height</a></td> + </tr> +</table> + +### Return Value + +bounds (0, 0, <a href="#SkRect_Make_size">size</a>.<a href="#SkRect_width">width</a>, <a href="#SkRect_Make_size">size</a>.<a href="#SkRect_height">height</a>) + +### Example + +<div><fiddle-embed name="e866f5e4f6ac52e89acadf48e54ac8e0"> + +#### Example Output + +~~~~ +rect1 == rect2 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_MakeWH">MakeWH</a> <a href="#SkRect_MakeXYWH">MakeXYWH</a> <a href="#SkRect_MakeIWH">SkRect::MakeIWH</a> <a href="#SkIRect_MakeSize">SkIRect::MakeSize</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static SkRect SK_WARN_UNUSED_RESULT Make(const SkIRect& irect) +</pre> + +Returns constructed <a href="SkIRect_Reference#IRect">IRect</a> <a href="#SkRect_set">set</a> to <a href="#SkRect_Make_2_irect">irect</a>, promoting integers to <a href="#Scalar">Scalar</a>. +Does not validate input; <a href="#SkRect_fLeft">fLeft</a> may be greater than <a href="#SkRect_fRight">fRight</a>, <a href="#SkRect_fTop">fTop</a> may be greater +than <a href="#SkRect_fBottom">fBottom</a>. + +### Parameters + +<table> <tr> <td><a name="SkRect_Make_2_irect"> <code><strong>irect </strong></code> </a></td> <td> +integer unsorted bounds</td> + </tr> +</table> + +### Return Value + +<a href="#SkRect_Make_2_irect">irect</a> members converted to <a href="undocumented#SkScalar">SkScalar</a> + +### Example + +<div><fiddle-embed name="dd801faa1e60a0fe9e0657674461e063"></fiddle-embed></div> + +### See Also + +<a href="#SkRect_MakeLTRB">MakeLTRB</a> + +--- + +<a name="SkRect_isEmpty"></a> +## isEmpty + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool isEmpty() const +</pre> + +Returns true if <a href="#SkRect_fLeft">fLeft</a> is equal to or greater than <a href="#SkRect_fRight">fRight</a>, or if <a href="#SkRect_fTop">fTop</a> is equal +to or greater than <a href="#SkRect_fBottom">fBottom</a>. Call <a href="#SkRect_sort">sort</a> to reverse rectangles with negative +<a href="#SkRect_width">width</a> or <a href="#SkRect_height">height</a>. + +### Return Value + +true if <a href="#SkRect_width">width</a> or <a href="#SkRect_height">height</a> are zero or negative + +### Example + +<div><fiddle-embed name="1d7b924d6ca2a6aef09684a8a632439c"> + +#### Example Output + +~~~~ +rect: {20, 40, 10, 50} is empty +sorted: {10, 40, 20, 50} is not empty +rect: {20, 40, 20, 50} is empty +sorted: {20, 40, 20, 50} is empty +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_MakeEmpty">MakeEmpty</a> <a href="#SkRect_sort">sort</a> <a href="#SkIRect_isEmpty">SkIRect::isEmpty</a> + +--- + +<a name="SkRect_isSorted"></a> +## isSorted + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool isSorted() const +</pre> + +Returns true if <a href="#SkRect_fLeft">fLeft</a> is equal to or less than <a href="#SkRect_fRight">fRight</a>, or if <a href="#SkRect_fTop">fTop</a> is equal +to or less than <a href="#SkRect_fBottom">fBottom</a>. Call <a href="#SkRect_sort">sort</a> to reverse rectangles with negative +<a href="#SkRect_width">width</a> or <a href="#SkRect_height">height</a>. + +### Return Value + +true if <a href="#SkRect_width">width</a> or <a href="#SkRect_height">height</a> are zero or positive + +### Example + +<div><fiddle-embed name="c7065a83b220a96f903dbbb65906fe7b"> + +#### Example Output + +~~~~ +rect: {20, 40, 10, 50} is not sorted +sorted: {10, 40, 20, 50} is sorted +rect: {20, 40, 20, 50} is sorted +sorted: {20, 40, 20, 50} is sorted +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_sort">sort</a> <a href="#SkRect_makeSorted">makeSorted</a> <a href="#SkRect_isEmpty">isEmpty</a> + +--- + +<a name="SkRect_isLargest"></a> +## isLargest + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool isLargest() const +</pre> + +Returns true if <a href="#Rect">Rect</a> encloses largest possible area. + +### Return Value + +true if equal to (<a href="undocumented#SK_ScalarMin">SK ScalarMin</a>, <a href="undocumented#SK_ScalarMin">SK ScalarMin</a>, <a href="undocumented#SK_ScalarMax">SK ScalarMax</a>, <a href="undocumented#SK_ScalarMax">SK ScalarMax</a>) + +### Example + +<div><fiddle-embed name="30ef8865ff1ba8789ee1d3be92734ad8"><div>Note that the <a href="#SkRect_width">width</a> cannot be represented as a 32-bit finite value.</div> + +#### Example Output + +~~~~ +large is largest: true +large width inf +large is empty: false +large is sorted: true +large is finite: true +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_MakeLargest">MakeLargest</a> <a href="#SkIRect_isLargest">SkIRect::isLargest</a> + +--- + +<a name="SkRect_isFinite"></a> +## isFinite + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool isFinite() const +</pre> + +Returns true if all values in the rectangle are finite: <a href="undocumented#SK_ScalarMin">SK ScalarMin</a> or larger, +and <a href="undocumented#SK_ScalarMax">SK ScalarMax</a> or smaller. + +### Return Value + +true if no member is infinite or <a href="undocumented#NaN">NaN</a> + +### Example + +<div><fiddle-embed name="7365c6553b830e6535cea0ce0d07be19"> + +#### Example Output + +~~~~ +largest is finite: true +large width inf +widest is finite: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="undocumented#SkScalarIsFinite">SkScalarIsFinite</a> <a href="undocumented#SkScalarIsNaN">SkScalarIsNaN</a> + +--- + +<a name="SkRect_x"></a> +## x + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkScalar x() const +</pre> + +Returns <a href="#SkRect_left">left</a> edge of <a href="#Rect">Rect</a>, if sorted. Call <a href="#SkRect_isSorted">isSorted</a> to see if <a href="#Rect">Rect</a> is valid. +Call <a href="#SkRect_sort">sort</a> to reverse <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fRight">fRight</a> if needed. + +### Return Value + +<a href="#SkRect_fLeft">fLeft</a> + +### Example + +<div><fiddle-embed name="23c77a35ac54a439a2989f840aa5cb99"> + +#### Example Output + +~~~~ +unsorted.fLeft: 15 unsorted.x(): 15 +sorted.fLeft: 10 sorted.x(): 10 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_fLeft">fLeft</a> <a href="#SkRect_left">left</a> <a href="#SkRect_y">y</a> <a href="#SkIRect_x">SkIRect::x()</a> + +--- + +<a name="SkRect_y"></a> +## y + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkScalar y() const +</pre> + +Returns <a href="#SkRect_top">top</a> edge of <a href="#Rect">Rect</a>, if sorted. Call <a href="#SkRect_isEmpty">isEmpty</a> to see if <a href="#Rect">Rect</a> may be invalid, +and <a href="#SkRect_sort">sort</a> to reverse <a href="#SkRect_fTop">fTop</a> and <a href="#SkRect_fBottom">fBottom</a> if needed. + +### Return Value + +<a href="#SkRect_fTop">fTop</a> + +### Example + +<div><fiddle-embed name="c653d9017983d2a047b1fee6a481d82b"> + +#### Example Output + +~~~~ +unsorted.fTop: 25 unsorted.y(): 25 +sorted.fTop: 5 sorted.y(): 5 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_fTop">fTop</a> <a href="#SkRect_top">top</a> <a href="#SkRect_x">x</a> <a href="#SkIRect_y">SkIRect::y()</a> + +--- + +<a name="SkRect_left"></a> +## left + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkScalar left() const +</pre> + +Returns <a href="#SkRect_left">left</a> edge of <a href="#Rect">Rect</a>, if sorted. Call <a href="#SkRect_isSorted">isSorted</a> to see if <a href="#Rect">Rect</a> is valid. +Call <a href="#SkRect_sort">sort</a> to reverse <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fRight">fRight</a> if needed. + +### Return Value + +<a href="#SkRect_fLeft">fLeft</a> + +### Example + +<div><fiddle-embed name="900dc96c3549795a87036d6458c4fde6"> + +#### Example Output + +~~~~ +unsorted.fLeft: 15 unsorted.left(): 15 +sorted.fLeft: 10 sorted.left(): 10 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_fLeft">fLeft</a> <a href="#SkRect_x">x</a> <a href="#SkIRect_left">SkIRect::left()</a> + +--- + +<a name="SkRect_top"></a> +## top + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkScalar top() const +</pre> + +Returns <a href="#SkRect_top">top</a> edge of <a href="#Rect">Rect</a>, if sorted. Call <a href="#SkRect_isEmpty">isEmpty</a> to see if <a href="#Rect">Rect</a> may be invalid, +and <a href="#SkRect_sort">sort</a> to reverse <a href="#SkRect_fTop">fTop</a> and <a href="#SkRect_fBottom">fBottom</a> if needed. + +### Return Value + +<a href="#SkRect_fTop">fTop</a> + +### Example + +<div><fiddle-embed name="3cfc24b011aef1ca8ccb57c05711620c"> + +#### Example Output + +~~~~ +unsorted.fTop: 25 unsorted.top(): 25 +sorted.fTop: 5 sorted.top(): 5 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_fTop">fTop</a> <a href="#SkRect_y">y</a> <a href="#SkIRect_top">SkIRect::top()</a> + +--- + +<a name="SkRect_right"></a> +## right + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkScalar right() const +</pre> + +Returns <a href="#SkRect_right">right</a> edge of <a href="#Rect">Rect</a>, if sorted. Call <a href="#SkRect_isSorted">isSorted</a> to see if <a href="#Rect">Rect</a> is valid. +Call <a href="#SkRect_sort">sort</a> to reverse <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fRight">fRight</a> if needed. + +### Return Value + +<a href="#SkRect_fRight">fRight</a> + +### Example + +<div><fiddle-embed name="ca3de7e5e292b3ad3633b1c39a31d3ab"> + +#### Example Output + +~~~~ +unsorted.fRight: 10 unsorted.right(): 10 +sorted.fRight: 15 sorted.right(): 15 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_fRight">fRight</a> <a href="#SkIRect_right">SkIRect::right()</a> + +--- + +<a name="SkRect_bottom"></a> +## bottom + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkScalar bottom() const +</pre> + +Returns <a href="#SkRect_bottom">bottom</a> edge of <a href="#Rect">Rect</a>, if sorted. Call <a href="#SkRect_isEmpty">isEmpty</a> to see if <a href="#Rect">Rect</a> may be invalid, +and <a href="#SkRect_sort">sort</a> to reverse <a href="#SkRect_fTop">fTop</a> and <a href="#SkRect_fBottom">fBottom</a> if needed. + +### Return Value + +<a href="#SkRect_fBottom">fBottom</a> + +### Example + +<div><fiddle-embed name="a98993a66616ae406d8bdc54adfb1411"> + +#### Example Output + +~~~~ +unsorted.fBottom: 5 unsorted.bottom(): 5 +sorted.fBottom: 25 sorted.bottom(): 25 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_fBottom">fBottom</a> <a href="#SkIRect_bottom">SkIRect::bottom()</a> + +--- + +<a name="SkRect_width"></a> +## width + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkScalar width() const +</pre> + +Returns span on the x-axis. This does not check if <a href="#Rect">Rect</a> is sorted, or if +result fits in 32-bit float; result may be negative or infinity. + +### Return Value + +<a href="#SkRect_fRight">fRight</a> minus <a href="#SkRect_fLeft">fLeft</a> + +### Example + +<div><fiddle-embed name="11f8f0efe6291019fee0ac17844f6c1a"><div>Compare with <a href="#SkIRect_width">SkIRect::width()</a> example.</div> + +#### Example Output + +~~~~ +unsorted width: -5 +large width: 4294967296 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_height">height</a> <a href="#SkIRect_width">SkIRect::width()</a> + +--- + +<a name="SkRect_height"></a> +## height + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkScalar height() const +</pre> + +Returns span on the y-axis. This does not check if <a href="SkIRect_Reference#IRect">IRect</a> is sorted, or if +result fits in 32-bit float; result may be negative or infinity. + +### Return Value + +<a href="#SkRect_fBottom">fBottom</a> minus <a href="#SkRect_fTop">fTop</a> + +### Example + +<div><fiddle-embed name="39429e45f05240218ecd511443ab3e44"><div>Compare with <a href="#SkIRect_height">SkIRect::height()</a> example.</div> + +#### Example Output + +~~~~ +unsorted height: -5 +large height: 4294967296 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_width">width</a> <a href="#SkIRect_height">SkIRect::height()</a> + +--- + +<a name="SkRect_centerX"></a> +## centerX + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkScalar centerX() const +</pre> + +Returns average of <a href="#SkRect_left">left</a> edge and <a href="#SkRect_right">right</a> edge. Result does not change if <a href="#Rect">Rect</a> +is sorted. Result may overflow to infinity if <a href="#Rect">Rect</a> is far from the origin. + +### Return Value + +midpoint in <a href="#SkRect_x">x</a> + +### Example + +<div><fiddle-embed name="d8439ba8d23a424fa032fb97147fd2d2"> + +#### Example Output + +~~~~ +left: 20 right: 41 centerX: 30.5 +left: 20 right: 41 centerX: 30.5 +left: -20 right: -41 centerX: -30.5 +left: -41 right: -20 centerX: -30.5 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_centerY">centerY</a> <a href="#SkIRect_centerX">SkIRect::centerX</a> + +--- + +<a name="SkRect_centerY"></a> +## centerY + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkScalar centerY() const +</pre> + +Returns average of <a href="#SkRect_top">top</a> edge and <a href="#SkRect_bottom">bottom</a> edge. Result does not change if <a href="#Rect">Rect</a> +is sorted. Result may overflow to infinity if <a href="#Rect">Rect</a> is far from the origin. + +### Return Value + +midpoint in <a href="#SkRect_y">y</a> + +### Example + +<div><fiddle-embed name="ebeeafafeb8fe39d5ffc9115b02c2340"> + +#### Example Output + +~~~~ +left: 2e+38 right: 3e+38 centerX: inf safe mid x: 2.5e+38 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_centerX">centerX</a> <a href="#SkIRect_centerY">SkIRect::centerY</a> + +--- + +<a name="SkRect_equal_operator"></a> +## operator== + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +friend bool operator==(const SkRect& a, const SkRect& b) +</pre> + +Returns true if all members in <a href="#SkRect_equal_operator_a">a</a>: <a href="#SkRect_fLeft">fLeft</a>, <a href="#SkRect_fTop">fTop</a>, <a href="#SkRect_fRight">fRight</a>, and <a href="#SkRect_fBottom">fBottom</a>; are +equal to the corresponding members in <a href="#SkRect_equal_operator_b">b</a>. + +<a href="#SkRect_equal_operator_a">a</a> and <a href="#SkRect_equal_operator_b">b</a> are not equal if either contain <a href="undocumented#NaN">NaN</a>. <a href="#SkRect_equal_operator_a">a</a> and <a href="#SkRect_equal_operator_b">b</a> are equal if members +contain zeroes <a href="#SkRect_width">width</a> different signs. + +### Parameters + +<table> <tr> <td><a name="SkRect_equal_operator_a"> <code><strong>a </strong></code> </a></td> <td> +<a href="#Rect">Rect</a> to compare</td> + </tr> <tr> <td><a name="SkRect_equal_operator_b"> <code><strong>b </strong></code> </a></td> <td> +<a href="#Rect">Rect</a> to compare</td> + </tr> +</table> + +### Return Value + +true if members are equal + +### Example + +<div><fiddle-embed name="c6c5b40cad7c3a839fdf576b380391a6"> + +#### Example Output + +~~~~ +tests are equal +{0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal +{0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal +{0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_not_equal_operator">operator!=(const SkRect& a, const SkRect& b)</a> + +--- + +<a name="SkRect_not_equal_operator"></a> +## operator!= + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +friend bool operator!=(const SkRect& a, const SkRect& b) +</pre> + +Returns true if any in <a href="#SkRect_not_equal_operator_a">a</a>: <a href="#SkRect_fLeft">fLeft</a>, <a href="#SkRect_fTop">fTop</a>, <a href="#SkRect_fRight">fRight</a>, and <a href="#SkRect_fBottom">fBottom</a>; does not +equal the corresponding members in <a href="#SkRect_not_equal_operator_b">b</a>. + +<a href="#SkRect_not_equal_operator_a">a</a> and <a href="#SkRect_not_equal_operator_b">b</a> are not equal if either contain <a href="undocumented#NaN">NaN</a>. <a href="#SkRect_not_equal_operator_a">a</a> and <a href="#SkRect_not_equal_operator_b">b</a> are equal if members +contain zeroes <a href="#SkRect_width">width</a> different signs. + +### Parameters + +<table> <tr> <td><a name="SkRect_not_equal_operator_a"> <code><strong>a </strong></code> </a></td> <td> +<a href="#Rect">Rect</a> to compare</td> + </tr> <tr> <td><a name="SkRect_not_equal_operator_b"> <code><strong>b </strong></code> </a></td> <td> +<a href="#Rect">Rect</a> to compare</td> + </tr> +</table> + +### Return Value + +true if members are not equal + +### Example + +<div><fiddle-embed name="286072f8c27ff15be9eb945fa38dc9f7"> + +#### Example Output + +~~~~ +test with NaN is not equal to itself +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_equal_operator">operator==(const SkRect& a, const SkRect& b)</a> + +--- + +<a name="SkRect_toQuad"></a> +## toQuad + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void toQuad(SkPoint quad[4]) const +</pre> + +Returns four points in <a href="#SkRect_toQuad_quad">quad</a> that enclose <a href="#Rect">Rect</a> ordered as: top-left, top-right, +bottom-right, bottom-left. + +### Parameters + +<table> <tr> <td><a name="SkRect_toQuad_quad"> <code><strong>quad </strong></code> </a></td> <td> +storage for corners of <a href="#Rect">Rect</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="59a6e7d202ac17ab80ec21b233e51f59"> + +#### Example Output + +~~~~ +rect: {1, 2, 3, 4} +corners: {1, 2} {3, 2} {3, 4} {1, 4} +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkPath_addRect">SkPath::addRect</a> + +--- + +<a name="SkRect_setEmpty"></a> +## setEmpty + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void setEmpty() +</pre> + +Sets <a href="#Rect">Rect</a> to (0, 0, 0, 0). + +Many other rectangles are empty; if <a href="#SkRect_left">left</a> is equal to or greater than <a href="#SkRect_right">right</a>, +or if <a href="#SkRect_top">top</a> is equal to or greater than <a href="#SkRect_bottom">bottom</a>. Setting all members to zero +is a convenience, but does not designate a special empty rectangle. + +### Example + +<div><fiddle-embed name="2cf67542d45ef5d7a7efb673b651ff54"> + +#### Example Output + +~~~~ +rect: {3, 4, 1, 2} is empty +rect: {0, 0, 0, 0} is empty +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_MakeEmpty">MakeEmpty</a> <a href="#SkIRect_setEmpty">SkIRect::setEmpty</a> + +--- + +<a name="SkRect_set"></a> +## set + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void set(const SkIRect& src) +</pre> + +Sets <a href="#Rect">Rect</a> to <a href="#SkRect_set_src">src</a>, promoting <a href="#SkRect_set_src">src</a> members from integer to <a href="#Scalar">Scalar</a>. +Very large values in <a href="#SkRect_set_src">src</a> may lose precision. + +### Parameters + +<table> <tr> <td><a name="SkRect_set_src"> <code><strong>src </strong></code> </a></td> <td> +integer <a href="#Rect">Rect</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="a10ad8d97062bc3f40942f47e5108917"> + +#### Example Output + +~~~~ +i_rect: {3, 4, 1, 2} +f_rect: {3, 4, 1, 2} +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_setLTRB">setLTRB</a> <a href="undocumented#SkIntToScalar">SkIntToScalar</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void set(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) +</pre> + +Sets <a href="#Rect">Rect</a> to (<a href="#SkRect_left">left</a>, <a href="#SkRect_top">top</a>, <a href="#SkRect_right">right</a>, <a href="#SkRect_bottom">bottom</a>). +<a href="#SkRect_left">left</a> and <a href="#SkRect_right">right</a> are not sorted; <a href="#SkRect_left">left</a> is not necessarily less than <a href="#SkRect_right">right</a>. +<a href="#SkRect_top">top</a> and <a href="#SkRect_bottom">bottom</a> are not sorted; <a href="#SkRect_top">top</a> is not necessarily less than <a href="#SkRect_bottom">bottom</a>. + +### Parameters + +<table> <tr> <td><a name="SkRect_set_2_left"> <code><strong>left </strong></code> </a></td> <td> +stored in <a href="#SkRect_fLeft">fLeft</a></td> + </tr> <tr> <td><a name="SkRect_set_2_top"> <code><strong>top </strong></code> </a></td> <td> +stored in <a href="#SkRect_fTop">fTop</a></td> + </tr> <tr> <td><a name="SkRect_set_2_right"> <code><strong>right </strong></code> </a></td> <td> +stored in <a href="#SkRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkRect_set_2_bottom"> <code><strong>bottom </strong></code> </a></td> <td> +stored in <a href="#SkRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="9b29ea460d69b4d47323fd9e3e17721e"> + +#### Example Output + +~~~~ +rect1: {3, 4, 1, 2} +rect2: {3, 4, 1, 2} +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_setLTRB">setLTRB</a> <a href="#SkRect_setXYWH">setXYWH</a> <a href="#SkIRect_set">SkIRect::set</a> + +--- + +<a name="SkRect_setLTRB"></a> +## setLTRB + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void setLTRB(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) +</pre> + +Sets <a href="#Rect">Rect</a> to (<a href="#SkRect_left">left</a>, <a href="#SkRect_top">top</a>, <a href="#SkRect_right">right</a>, <a href="#SkRect_bottom">bottom</a>). +<a href="#SkRect_left">left</a> and <a href="#SkRect_right">right</a> are not sorted; <a href="#SkRect_left">left</a> is not necessarily less than <a href="#SkRect_right">right</a>. +<a href="#SkRect_top">top</a> and <a href="#SkRect_bottom">bottom</a> are not sorted; <a href="#SkRect_top">top</a> is not necessarily less than <a href="#SkRect_bottom">bottom</a>. + +### Parameters + +<table> <tr> <td><a name="SkRect_setLTRB_left"> <code><strong>left </strong></code> </a></td> <td> +stored in <a href="#SkRect_fLeft">fLeft</a></td> + </tr> <tr> <td><a name="SkRect_setLTRB_top"> <code><strong>top </strong></code> </a></td> <td> +stored in <a href="#SkRect_fTop">fTop</a></td> + </tr> <tr> <td><a name="SkRect_setLTRB_right"> <code><strong>right </strong></code> </a></td> <td> +stored in <a href="#SkRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkRect_setLTRB_bottom"> <code><strong>bottom </strong></code> </a></td> <td> +stored in <a href="#SkRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="70692838793454c8e045d6eaf7edcbff"> + +#### Example Output + +~~~~ +rect1: {3, 4, 1, 2} +rect2: {3, 4, 1, 2} +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_set">set</a> <a href="#SkRect_setXYWH">setXYWH</a> <a href="#SkIRect_set">SkIRect::set</a> + +--- + +<a name="SkRect_iset"></a> +## iset + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void iset(int left, int top, int right, int bottom) +</pre> + +Sets <a href="#Rect">Rect</a> to (<a href="#SkRect_left">left</a>, <a href="#SkRect_top">top</a>, <a href="#SkRect_right">right</a>, <a href="#SkRect_bottom">bottom</a>). +All parameters are promoted from integer to <a href="#Scalar">Scalar</a>. +<a href="#SkRect_left">left</a> and <a href="#SkRect_right">right</a> are not sorted; <a href="#SkRect_left">left</a> is not necessarily less than <a href="#SkRect_right">right</a>. +<a href="#SkRect_top">top</a> and <a href="#SkRect_bottom">bottom</a> are not sorted; <a href="#SkRect_top">top</a> is not necessarily less than <a href="#SkRect_bottom">bottom</a>. + +### Parameters + +<table> <tr> <td><a name="SkRect_iset_left"> <code><strong>left </strong></code> </a></td> <td> +promoted to <a href="undocumented#SkScalar">SkScalar</a> and stored in <a href="#SkRect_fLeft">fLeft</a></td> + </tr> <tr> <td><a name="SkRect_iset_top"> <code><strong>top </strong></code> </a></td> <td> +promoted to <a href="undocumented#SkScalar">SkScalar</a> and stored in <a href="#SkRect_fTop">fTop</a></td> + </tr> <tr> <td><a name="SkRect_iset_right"> <code><strong>right </strong></code> </a></td> <td> +promoted to <a href="undocumented#SkScalar">SkScalar</a> and stored in <a href="#SkRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkRect_iset_bottom"> <code><strong>bottom </strong></code> </a></td> <td> +promoted to <a href="undocumented#SkScalar">SkScalar</a> and stored in <a href="#SkRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="18532f1aa90b76364fb8d7ea072f1892"> + +#### Example Output + +~~~~ +rect1: {3, 4, 1, 2} +rect2: {3, 4, 1, 2} +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_set">set</a> <a href="#SkRect_setLTRB">setLTRB</a> <a href="#SkIRect_set">SkIRect::set</a> <a href="undocumented#SkIntToScalar">SkIntToScalar</a> + +--- + +<a name="SkRect_isetWH"></a> +## isetWH + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void isetWH(int width, int height) +</pre> + +Sets <a href="#Rect">Rect</a> to (0, 0, <a href="#SkRect_width">width</a>, <a href="#SkRect_height">height</a>). +<a href="#SkRect_width">width</a> and <a href="#SkRect_height">height</a> may be zero or negative. <a href="#SkRect_width">width</a> and <a href="#SkRect_height">height</a> are promoted from +integer to <a href="undocumented#SkScalar">SkScalar</a>, large values may lose precision. + +### Parameters + +<table> <tr> <td><a name="SkRect_isetWH_width"> <code><strong>width </strong></code> </a></td> <td> +promoted to <a href="undocumented#SkScalar">SkScalar</a> and stored in <a href="#SkRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkRect_isetWH_height"> <code><strong>height </strong></code> </a></td> <td> +promoted to <a href="undocumented#SkScalar">SkScalar</a> and stored in <a href="#SkRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="ee6000080fc7123214ea404018cf9176"> + +#### Example Output + +~~~~ +rect1: {0, 0, 1, 2} +rect2: {0, 0, 1, 2} +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_MakeWH">MakeWH</a> <a href="#SkRect_MakeXYWH">MakeXYWH</a> <a href="#SkRect_iset">iset</a> <a href="SkIRect_Reference#SkIRect">SkIRect</a>:<a href="#SkRect_MakeWH">MakeWH</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void set(const SkPoint pts[], int count) +</pre> + +Sets to bounds of <a href="undocumented#Point">Point</a> array with <a href="#SkRect_set_3_count">count</a> entries. If <a href="#SkRect_set_3_count">count</a> is zero or smaller, +or if <a href="undocumented#Point">Point</a> array <a href="#SkRect_contains">contains</a> an infinity or <a href="undocumented#NaN">NaN</a>, sets <a href="#Rect">Rect</a> to (0, 0, 0, 0). + +Result is either empty or sorted: <a href="#SkRect_fLeft">fLeft</a> is less than or equal to <a href="#SkRect_fRight">fRight</a>, and +<a href="#SkRect_fTop">fTop</a> is less than or equal to <a href="#SkRect_fBottom">fBottom</a>. + +### Parameters + +<table> <tr> <td><a name="SkRect_set_3_pts"> <code><strong>pts </strong></code> </a></td> <td> +<a href="undocumented#Point">Point</a> array</td> + </tr> <tr> <td><a name="SkRect_set_3_count"> <code><strong>count </strong></code> </a></td> <td> +entries in array</td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="94295fa5197e21256171b99b4023dd48"> + +#### Example Output + +~~~~ +count: 0 rect: 0, 0, 0, 0 +added: 3, 4 count: 1 rect: 3, 4, 3, 4 +added: 1, 2 count: 2 rect: 1, 2, 3, 4 +added: 5, 6 count: 3 rect: 1, 2, 5, 6 +added: nan, 8 count: 4 rect: 0, 0, 0, 0 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_setBounds">setBounds</a> <a href="#SkRect_setBoundsCheck">setBoundsCheck</a> <a href="#SkPath_addPoly">SkPath::addPoly</a> + +--- + +<a name="SkRect_setBounds"></a> +## setBounds + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void setBounds(const SkPoint pts[], int count) +</pre> + +Sets to bounds of <a href="undocumented#Point">Point</a> array with <a href="#SkRect_setBounds_count">count</a> entries. If <a href="#SkRect_setBounds_count">count</a> is zero or smaller, +or if <a href="undocumented#Point">Point</a> array <a href="#SkRect_contains">contains</a> an infinity or <a href="undocumented#NaN">NaN</a>, sets to (0, 0, 0, 0). + +Result is either empty or sorted: <a href="#SkRect_fLeft">fLeft</a> is less than or equal to <a href="#SkRect_fRight">fRight</a>, and +<a href="#SkRect_fTop">fTop</a> is less than or equal to <a href="#SkRect_fBottom">fBottom</a>. + +### Parameters + +<table> <tr> <td><a name="SkRect_setBounds_pts"> <code><strong>pts </strong></code> </a></td> <td> +<a href="undocumented#Point">Point</a> array</td> + </tr> <tr> <td><a name="SkRect_setBounds_count"> <code><strong>count </strong></code> </a></td> <td> +entries in array</td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="cf0da15f48aa54fd1889e7f913601710"> + +#### Example Output + +~~~~ +count: 0 rect: 0, 0, 0, 0 +added: 3, 4 count: 1 rect: 3, 4, 3, 4 +added: 1, 2 count: 2 rect: 1, 2, 3, 4 +added: 5, 6 count: 3 rect: 1, 2, 5, 6 +added: nan, 8 count: 4 rect: 0, 0, 0, 0 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_set">set</a> <a href="#SkRect_setBoundsCheck">setBoundsCheck</a> <a href="#SkPath_addPoly">SkPath::addPoly</a> + +--- + +<a name="SkRect_setBoundsCheck"></a> +## setBoundsCheck + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool setBoundsCheck(const SkPoint pts[], int count) +</pre> + +Sets to bounds of <a href="undocumented#Point">Point</a> array with <a href="#SkRect_setBoundsCheck_count">count</a> entries. Returns false if <a href="#SkRect_setBoundsCheck_count">count</a> is +zero or smaller, or if <a href="undocumented#Point">Point</a> array <a href="#SkRect_contains">contains</a> an infinity or <a href="undocumented#NaN">NaN</a>; in these cases +sets <a href="#Rect">Rect</a> to (0, 0, 0, 0). + +Result is either empty or sorted: <a href="#SkRect_fLeft">fLeft</a> is less than or equal to <a href="#SkRect_fRight">fRight</a>, and +<a href="#SkRect_fTop">fTop</a> is less than or equal to <a href="#SkRect_fBottom">fBottom</a>. + +### Parameters + +<table> <tr> <td><a name="SkRect_setBoundsCheck_pts"> <code><strong>pts </strong></code> </a></td> <td> +<a href="undocumented#Point">Point</a> array</td> + </tr> <tr> <td><a name="SkRect_setBoundsCheck_count"> <code><strong>count </strong></code> </a></td> <td> +entries in array</td> + </tr> +</table> + +### Return Value + +true if all <a href="undocumented#Point">Point</a> values are finite + +### Example + +<div><fiddle-embed name="83d879b92683b15f9daaf0c9e71c5b35"> + +#### Example Output + +~~~~ +count: 0 rect: 0, 0, 0, 0 success: true +added: 3, 4 count: 1 rect: 3, 4, 3, 4 success: true +added: 1, 2 count: 2 rect: 1, 2, 3, 4 success: true +added: 5, 6 count: 3 rect: 1, 2, 5, 6 success: true +added: nan, 8 count: 4 rect: 0, 0, 0, 0 success: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_set">set</a> <a href="#SkRect_setBounds">setBounds</a> <a href="#SkPath_addPoly">SkPath::addPoly</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void set(const SkPoint& p0, const SkPoint& p1) +</pre> + +Sets bounds to the smallest <a href="#Rect">Rect</a> enclosing <a href="#Point">Points</a> <a href="#SkRect_set_4_p0">p0</a> and <a href="#SkRect_set_4_p1">p1</a>. The result is +sorted and may be empty. Does not check to see if values are finite. + +### Parameters + +<table> <tr> <td><a name="SkRect_set_4_p0"> <code><strong>p0 </strong></code> </a></td> <td> +corner to include</td> + </tr> <tr> <td><a name="SkRect_set_4_p1"> <code><strong>p1 </strong></code> </a></td> <td> +corner to include</td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="ee72450381f768f3869153cdbeccdc3e"><div><a href="#SkRect_set_4_p0">p0</a> and <a href="#SkRect_set_4_p1">p1</a> may be swapped and have the same effect unless one <a href="#SkRect_contains">contains</a> <a href="undocumented#NaN">NaN</a>.</div></fiddle-embed></div> + +### See Also + +<a href="#SkRect_setBounds">setBounds</a> <a href="#SkRect_setBoundsCheck">setBoundsCheck</a> + +--- + +<a name="SkRect_setXYWH"></a> +## setXYWH + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void setXYWH(SkScalar x, SkScalar y, SkScalar width, SkScalar height) +</pre> + +Sets <a href="#Rect">Rect</a> to(<a href="#SkRect_x">x</a>, <a href="#SkRect_y">y</a>, <a href="#SkRect_x">x</a> + w, <a href="#SkRect_y">y</a> + h). +Does not validate input; +w or h may be negative. + +### Parameters + +<table> <tr> <td><a name="SkRect_setXYWH_x"> <code><strong>x </strong></code> </a></td> <td> +stored in <a href="#SkRect_fLeft">fLeft</a></td> + </tr> <tr> <td><a name="SkRect_setXYWH_y"> <code><strong>y </strong></code> </a></td> <td> +stored in <a href="#SkRect_fTop">fTop</a></td> + </tr> <tr> <td><a name="SkRect_setXYWH_width"> <code><strong>width </strong></code> </a></td> <td> +added to <a href="#SkRect_x">x</a> and stored in <a href="#SkRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkRect_setXYWH_height"> <code><strong>height </strong></code> </a></td> <td> +added to <a href="#SkRect_y">y</a> and stored in <a href="#SkRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="373cce4c61b9da0384b735b838765163"> + +#### Example Output + +~~~~ +rect: 5, 35, -10, 60 isEmpty: true +rect: -10, 35, 5, 60 isEmpty: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_MakeXYWH">MakeXYWH</a> <a href="#SkRect_setLTRB">setLTRB</a> <a href="#SkRect_set">set</a> <a href="#SkIRect_setXYWH">SkIRect::setXYWH</a> + +--- + +<a name="SkRect_setWH"></a> +## setWH + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void setWH(SkScalar width, SkScalar height) +</pre> + +Sets <a href="#Rect">Rect</a> to (0, 0, w, h). Does not validate input; +w or h may be negative. + +### Parameters + +<table> <tr> <td><a name="SkRect_setWH_width"> <code><strong>width </strong></code> </a></td> <td> +stored in <a href="#SkRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkRect_setWH_height"> <code><strong>height </strong></code> </a></td> <td> +stored in <a href="#SkRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="9cb5fee17802fa49341f3707bdf5d235"> + +#### Example Output + +~~~~ +rect: 0, 0, -15, 25 isEmpty: true +rect: -15, 0, 0, 25 isEmpty: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_MakeWH">MakeWH</a> <a href="#SkRect_setXYWH">setXYWH</a> <a href="#SkRect_isetWH">isetWH</a> + +--- + +<a name="SkRect_setLargest"></a> +## setLargest + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void setLargest() +</pre> + +Sets rectangle <a href="#SkRect_left">left</a> and <a href="#SkRect_top">top</a> to most negative finite value, and sets +<a href="#SkRect_right">right</a> and <a href="#SkRect_bottom">bottom</a> to most positive finite value. + +### Example + +<div><fiddle-embed name="7a07b1914ade5c38cce6be417bc8aa4b"> + +#### Example Output + +~~~~ +MakeLargest isLargest: true +MakeLargest isFinite: true +outset a little isLargest: true +outset a little isFinite: true +outset a little more isLargest: false +outset a little more isFinite: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_MakeLargest">MakeLargest</a> <a href="#SkRect_isLargest">isLargest</a> <a href="#SkRect_setLargestInverted">setLargestInverted</a> <a href="undocumented#SK_ScalarMin">SK ScalarMin</a> <a href="undocumented#SK_ScalarMax">SK ScalarMax</a> + +--- + +<a name="SkRect_setLargestInverted"></a> +## setLargestInverted + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void setLargestInverted() +</pre> + +Sets rectangle <a href="#SkRect_left">left</a> and <a href="#SkRect_top">top</a> to most positive finite value, and sets +<a href="#SkRect_right">right</a> and <a href="#SkRect_bottom">bottom</a> to most negative finite value. + +Use to initial <a href="#Rect">Rect</a> before one or more calls to <a href="#SkRect_growToInclude">growToInclude</a>. + +### Example + +<div><fiddle-embed name="394442eedd4f01e42c5a4905e832dd0c"> + +#### Example Output + +~~~~ +original rect: 3.40282e+38, 3.40282e+38, -3.40282e+38, -3.40282e+38 isEmpty: true +grown rect: 42, 24, 42, 24 isEmpty: true +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_growToInclude">growToInclude</a> <a href="#SkRect_setEmpty">setEmpty</a> <a href="#SkRect_setLargest">setLargest</a> + +--- + +<a name="SkRect_makeOffset"></a> +## makeOffset + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkRect makeOffset(SkScalar dx, SkScalar dy) const +</pre> + +Returns <a href="#Rect">Rect</a> <a href="#SkRect_offset">offset</a> by (<a href="#SkRect_makeOffset_dx">dx</a>, <a href="#SkRect_makeOffset_dy">dy</a>). + +If <a href="#SkRect_makeOffset_dx">dx</a> is negative, <a href="#Rect">Rect</a> returned is moved to the <a href="#SkRect_left">left</a>. +If <a href="#SkRect_makeOffset_dx">dx</a> is positive, <a href="#Rect">Rect</a> returned is moved to the <a href="#SkRect_right">right</a>. +If <a href="#SkRect_makeOffset_dy">dy</a> is negative, <a href="#Rect">Rect</a> returned is moved upward. +If <a href="#SkRect_makeOffset_dy">dy</a> is positive, <a href="#Rect">Rect</a> returned is moved downward. + +### Parameters + +<table> <tr> <td><a name="SkRect_makeOffset_dx"> <code><strong>dx </strong></code> </a></td> <td> +added to <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkRect_makeOffset_dy"> <code><strong>dy </strong></code> </a></td> <td> +added to <a href="#SkRect_fTop">fTop</a> and <a href="#SkRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Return Value + +<a href="#Rect">Rect</a> <a href="#SkRect_offset">offset</a> in <a href="#SkRect_x">x</a> or <a href="#SkRect_y">y</a>, with original <a href="#SkRect_width">width</a> and <a href="#SkRect_height">height</a> + +### Example + +<div><fiddle-embed name="98841ab0a932f99cccd8e6a34d94ba05"> + +#### Example Output + +~~~~ +rect: 10, 50, 20, 60 isEmpty: false +rect: 25, 82, 35, 92 isEmpty: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_offset">offset</a> <a href="#SkRect_makeInset">makeInset</a> <a href="#SkRect_makeOutset">makeOutset</a> <a href="#SkIRect_makeOffset">SkIRect::makeOffset</a> + +--- + +<a name="SkRect_makeInset"></a> +## makeInset + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkRect makeInset(SkScalar dx, SkScalar dy) const +</pre> + +Returns <a href="#Rect">Rect</a>, <a href="#SkRect_inset">inset</a> by (<a href="#SkRect_makeInset_dx">dx</a>, <a href="#SkRect_makeInset_dy">dy</a>). + +If <a href="#SkRect_makeInset_dx">dx</a> is negative, <a href="#Rect">Rect</a> returned is wider. +If <a href="#SkRect_makeInset_dx">dx</a> is positive, <a href="#Rect">Rect</a> returned is narrower. +If <a href="#SkRect_makeInset_dy">dy</a> is negative, <a href="#Rect">Rect</a> returned is taller. +If <a href="#SkRect_makeInset_dy">dy</a> is positive, <a href="#Rect">Rect</a> returned is shorter. + +### Parameters + +<table> <tr> <td><a name="SkRect_makeInset_dx"> <code><strong>dx </strong></code> </a></td> <td> +added to <a href="#SkRect_fLeft">fLeft</a> and subtracted from <a href="#SkRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkRect_makeInset_dy"> <code><strong>dy </strong></code> </a></td> <td> +added to <a href="#SkRect_fTop">fTop</a> and subtracted from <a href="#SkRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Return Value + +<a href="#Rect">Rect</a> <a href="#SkRect_inset">inset</a> symetrically <a href="#SkRect_left">left</a> and <a href="#SkRect_right">right</a>, <a href="#SkRect_top">top</a> and <a href="#SkRect_bottom">bottom</a> + +### Example + +<div><fiddle-embed name="b8d32ab2f7ea3d4d5fb5a4ea2156f1c5"> + +#### Example Output + +~~~~ +rect: 10, 50, 20, 60 isEmpty: false +rect: 25, 82, 5, 28 isEmpty: true +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_inset">inset</a> <a href="#SkRect_makeOffset">makeOffset</a> <a href="#SkRect_makeOutset">makeOutset</a> <a href="#SkIRect_makeInset">SkIRect::makeInset</a> + +--- + +<a name="SkRect_makeOutset"></a> +## makeOutset + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkRect makeOutset(SkScalar dx, SkScalar dy) const +</pre> + +Returns <a href="#Rect">Rect</a>, <a href="#SkRect_outset">outset</a> by (<a href="#SkRect_makeOutset_dx">dx</a>, <a href="#SkRect_makeOutset_dy">dy</a>). + +If <a href="#SkRect_makeOutset_dx">dx</a> is negative, <a href="#Rect">Rect</a> returned is narrower. +If <a href="#SkRect_makeOutset_dx">dx</a> is positive, <a href="#Rect">Rect</a> returned is wider. +If <a href="#SkRect_makeOutset_dy">dy</a> is negative, <a href="#Rect">Rect</a> returned is shorter. +If <a href="#SkRect_makeOutset_dy">dy</a> is positive, <a href="#Rect">Rect</a> returned is taller. + +### Parameters + +<table> <tr> <td><a name="SkRect_makeOutset_dx"> <code><strong>dx </strong></code> </a></td> <td> +subtracted to <a href="#SkRect_fLeft">fLeft</a> and added from <a href="#SkRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkRect_makeOutset_dy"> <code><strong>dy </strong></code> </a></td> <td> +subtracted to <a href="#SkRect_fTop">fTop</a> and added from <a href="#SkRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Return Value + +<a href="#Rect">Rect</a> <a href="#SkRect_outset">outset</a> symetrically <a href="#SkRect_left">left</a> and <a href="#SkRect_right">right</a>, <a href="#SkRect_top">top</a> and <a href="#SkRect_bottom">bottom</a> + +### Example + +<div><fiddle-embed name="87176fc60914cbca9c6a20998a033c24"> + +#### Example Output + +~~~~ +rect: 10, 50, 20, 60 isEmpty: false +rect: -5, 18, 35, 92 isEmpty: false +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_outset">outset</a> <a href="#SkRect_makeOffset">makeOffset</a> <a href="#SkRect_makeInset">makeInset</a> <a href="#SkIRect_makeOutset">SkIRect::makeOutset</a> + +--- + +<a name="SkRect_offset"></a> +## offset + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void offset(SkScalar dx, SkScalar dy) +</pre> + +Offsets <a href="#Rect">Rect</a> by adding <a href="#SkRect_offset_dx">dx</a> to <a href="#SkRect_fLeft">fLeft</a>, <a href="#SkRect_fRight">fRight</a>; and by adding <a href="#SkRect_offset_dy">dy</a> to <a href="#SkRect_fTop">fTop</a>, <a href="#SkRect_fBottom">fBottom</a>. + +If <a href="#SkRect_offset_dx">dx</a> is negative, moves <a href="#Rect">Rect</a> to the <a href="#SkRect_left">left</a>. +If <a href="#SkRect_offset_dx">dx</a> is positive, moves <a href="#Rect">Rect</a> to the <a href="#SkRect_right">right</a>. +If <a href="#SkRect_offset_dy">dy</a> is negative, moves <a href="#Rect">Rect</a> upward. +If <a href="#SkRect_offset_dy">dy</a> is positive, moves <a href="#Rect">Rect</a> downward. + +### Parameters + +<table> <tr> <td><a name="SkRect_offset_dx"> <code><strong>dx </strong></code> </a></td> <td> +<a href="#SkRect_offset">offset</a> added to <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkRect_offset_dy"> <code><strong>dy </strong></code> </a></td> <td> +<a href="#SkRect_offset">offset</a> added to <a href="#SkRect_fTop">fTop</a> and <a href="#SkRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="04eb33f0fd376f2942ca5f1c7f6cbcfc"> + +#### Example Output + +~~~~ +rect: 15, 27, 55, 86 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_offsetTo">offsetTo</a> <a href="#SkRect_makeOffset">makeOffset</a> <a href="#SkIRect_offset">SkIRect::offset</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void offset(const SkPoint& delta) +</pre> + +Offsets <a href="#Rect">Rect</a> by adding <a href="#SkRect_offset_2_delta">delta</a>.fX to <a href="#SkRect_fLeft">fLeft</a>, <a href="#SkRect_fRight">fRight</a>; and by adding <a href="#SkRect_offset_2_delta">delta</a>.fY to +<a href="#SkRect_fTop">fTop</a>, <a href="#SkRect_fBottom">fBottom</a>. + +If <a href="#SkRect_offset_2_delta">delta</a>.fX is negative, moves <a href="#Rect">Rect</a> to the <a href="#SkRect_left">left</a>. +If <a href="#SkRect_offset_2_delta">delta</a>.fX is positive, moves <a href="#Rect">Rect</a> to the <a href="#SkRect_right">right</a>. +If <a href="#SkRect_offset_2_delta">delta</a>.fY is negative, moves <a href="#Rect">Rect</a> upward. +If <a href="#SkRect_offset_2_delta">delta</a>.fY is positive, moves <a href="#Rect">Rect</a> downward. + +### Parameters + +<table> <tr> <td><a name="SkRect_offset_2_delta"> <code><strong>delta </strong></code> </a></td> <td> +added to <a href="#Rect">Rect</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="b24cf65561c98c1858a06c39f10fb797"> + +#### Example Output + +~~~~ +rect: 15, 27, 55, 86 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_offsetTo">offsetTo</a> <a href="#SkRect_makeOffset">makeOffset</a> <a href="#SkIRect_offset">SkIRect::offset</a> + +--- + +<a name="SkRect_offsetTo"></a> +## offsetTo + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void offsetTo(SkScalar newX, SkScalar newY) +</pre> + +Offsets <a href="#Rect">Rect</a> so that <a href="#SkRect_fLeft">fLeft</a> equals <a href="#SkRect_offsetTo_newX">newX</a>, and <a href="#SkRect_fTop">fTop</a> equals <a href="#SkRect_offsetTo_newY">newY</a>. <a href="#SkRect_width">width</a> and <a href="#SkRect_height">height</a> +are unchanged. + +### Parameters + +<table> <tr> <td><a name="SkRect_offsetTo_newX"> <code><strong>newX </strong></code> </a></td> <td> +stored in <a href="#SkRect_fLeft">fLeft</a>, preserving <a href="#SkRect_width">width</a></td> + </tr> <tr> <td><a name="SkRect_offsetTo_newY"> <code><strong>newY </strong></code> </a></td> <td> +stored in <a href="#SkRect_fTop">fTop</a>, preserving <a href="#SkRect_height">height</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="bedb04b7b3e1af3e8039f9cffe66989e"> + +#### Example Output + +~~~~ +rect: 15, 27, 55, 86 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_offset">offset</a> <a href="#SkRect_makeOffset">makeOffset</a> <a href="#SkRect_setXYWH">setXYWH</a> <a href="#SkIRect_offsetTo">SkIRect::offsetTo</a> + +--- + +<a name="SkRect_inset"></a> +## inset + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void inset(SkScalar dx, SkScalar dy) +</pre> + +Insets <a href="#Rect">Rect</a> by (<a href="#SkRect_inset_dx">dx</a>, <a href="#SkRect_inset_dy">dy</a>). + +If <a href="#SkRect_inset_dx">dx</a> is positive, makes <a href="#Rect">Rect</a> narrower. +If <a href="#SkRect_inset_dx">dx</a> is negative, makes <a href="#Rect">Rect</a> wider. +If <a href="#SkRect_inset_dy">dy</a> is positive, makes <a href="#Rect">Rect</a> shorter. +If <a href="#SkRect_inset_dy">dy</a> is negative, makes <a href="#Rect">Rect</a> taller. + +### Parameters + +<table> <tr> <td><a name="SkRect_inset_dx"> <code><strong>dx </strong></code> </a></td> <td> +added to <a href="#SkRect_fLeft">fLeft</a> and subtracted from <a href="#SkRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkRect_inset_dy"> <code><strong>dy </strong></code> </a></td> <td> +added to <a href="#SkRect_fTop">fTop</a> and subtracted from <a href="#SkRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="dae21340941dc6e4d048816dfd9f204c"> + +#### Example Output + +~~~~ +rect: 15, 27, 45, 60 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_outset">outset</a> <a href="#SkRect_makeInset">makeInset</a> <a href="#SkIRect_inset">SkIRect::inset</a> + +--- + +<a name="SkRect_outset"></a> +## outset + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void outset(SkScalar dx, SkScalar dy) +</pre> + +Outsets <a href="#Rect">Rect</a> by (<a href="#SkRect_outset_dx">dx</a>, <a href="#SkRect_outset_dy">dy</a>). + +If <a href="#SkRect_outset_dx">dx</a> is positive, makes <a href="#Rect">Rect</a> wider. +If <a href="#SkRect_outset_dx">dx</a> is negative, makes <a href="#Rect">Rect</a> narrower. +If <a href="#SkRect_outset_dy">dy</a> is positive, makes <a href="#Rect">Rect</a> taller. +If <a href="#SkRect_outset_dy">dy</a> is negative, makes <a href="#Rect">Rect</a> shorter. + +### Parameters + +<table> <tr> <td><a name="SkRect_outset_dx"> <code><strong>dx </strong></code> </a></td> <td> +subtracted to <a href="#SkRect_fLeft">fLeft</a> and added from <a href="#SkRect_fRight">fRight</a></td> + </tr> <tr> <td><a name="SkRect_outset_dy"> <code><strong>dy </strong></code> </a></td> <td> +subtracted to <a href="#SkRect_fTop">fTop</a> and added from <a href="#SkRect_fBottom">fBottom</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="861f873ba660af8c8bf8b0b83d829cf4"> + +#### Example Output + +~~~~ +rect: 5, 1, 55, 86 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_inset">inset</a> <a href="#SkRect_makeOutset">makeOutset</a> <a href="#SkIRect_outset">SkIRect::outset</a> + +--- + +# <a name="Intersection"></a> Intersection +<a href="#Rect">Rects</a> <a href="#SkRect_intersect">intersect</a> when they enclose a common area. To <a href="#SkRect_intersect">intersect</a>, each of the pair +must describe area; <a href="#SkRect_fLeft">fLeft</a> is less than <a href="#SkRect_fRight">fRight</a>, and <a href="#SkRect_fTop">fTop</a> is less than <a href="#SkRect_fBottom">fBottom</a>; +empty() returns false. The intersection of <a href="#Rect">Rect</a> a and <a href="#Rect">Rect</a> b can be described by: +(max(a.fLeft, b.fLeft), max(a.fTop, b.fTop), +min(a.fRight, b.fRight), min(a.fBottom, b.fBottom))The intersection is only meaningful if the resulting <a href="#Rect">Rect</a> is not empty and +describes an area: <a href="#SkRect_fLeft">fLeft</a> is less than <a href="#SkRect_fRight">fRight</a>, and <a href="#SkRect_fTop">fTop</a> is less than <a href="#SkRect_fBottom">fBottom</a>. + +<a name="SkRect_intersect"></a> +## intersect + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool intersect(const SkRect& r) +</pre> + +Returns true if <a href="#Rect">Rect</a> <a href="#SkRect_intersects">intersects</a> <a href="#SkRect_intersect_r">r</a>, and sets <a href="#Rect">Rect</a> to intersection. +Returns false if <a href="#Rect">Rect</a> does not <a href="#SkRect_intersect">intersect</a> <a href="#SkRect_intersect_r">r</a>, and leaves <a href="#Rect">Rect</a> unchanged. + +Returns false if either <a href="#SkRect_intersect_r">r</a> or <a href="#Rect">Rect</a> is empty, leaving <a href="#Rect">Rect</a> unchanged. + +### Parameters + +<table> <tr> <td><a name="SkRect_intersect_r"> <code><strong>r </strong></code> </a></td> <td> +limit of result</td> + </tr> +</table> + +### Return Value + +true if <a href="#SkRect_intersect_r">r</a> and <a href="#Rect">Rect</a> have area in common + +### Example + +<div><fiddle-embed name="70e5b3979fc8a31eda070cfed91bc271"><div>Two <a href="undocumented#SkDebugf">SkDebugf</a> calls are required. If the calls are combined, their arguments +may not be evaluated in <a href="#SkRect_left">left</a> to <a href="#SkRect_right">right</a> order: the printed intersection may +be before or after the call to <a href="#SkRect_intersect">intersect</a>.</div> + +#### Example Output + +~~~~ +intersection: 30, 60, 50, 80 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_intersects">intersects</a> <a href="#SkRect_Intersects">Intersects</a> <a href="#SkRect_join">join</a> <a href="#SkIRect_intersect">SkIRect::intersect</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool intersect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) +</pre> + +Constructs <a href="#Rect">Rect</a> to <a href="#SkRect_intersect">intersect</a> from (<a href="#SkRect_left">left</a>, <a href="#SkRect_top">top</a>, <a href="#SkRect_right">right</a>, <a href="#SkRect_bottom">bottom</a>). Does not <a href="#SkRect_sort">sort</a> +construction. + +Returns true if <a href="#Rect">Rect</a> <a href="#SkRect_intersects">intersects</a> construction, and sets <a href="#Rect">Rect</a> to intersection. +Returns false if <a href="#Rect">Rect</a> does not <a href="#SkRect_intersect">intersect</a> construction, and leaves <a href="#Rect">Rect</a> unchanged. + +Returns false if either construction or <a href="#Rect">Rect</a> is empty, leaving <a href="#Rect">Rect</a> unchanged. + +### Parameters + +<table> <tr> <td><a name="SkRect_intersect_2_left"> <code><strong>left </strong></code> </a></td> <td> +<a href="#SkRect_x">x</a> minimum of constructed <a href="#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkRect_intersect_2_top"> <code><strong>top </strong></code> </a></td> <td> +<a href="#SkRect_y">y</a> minimum of constructed <a href="#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkRect_intersect_2_right"> <code><strong>right </strong></code> </a></td> <td> +<a href="#SkRect_x">x</a> maximum of constructed <a href="#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkRect_intersect_2_bottom"> <code><strong>bottom </strong></code> </a></td> <td> +<a href="#SkRect_y">y</a> maximum of constructed <a href="#Rect">Rect</a></td> + </tr> +</table> + +### Return Value + +true if construction and <a href="#Rect">Rect</a> have area in common + +### Example + +<div><fiddle-embed name="9f06dad5e6c712f7a2c149d075e816d2"><div>Two <a href="undocumented#SkDebugf">SkDebugf</a> calls are required. If the calls are combined, their arguments +may not be evaluated in <a href="#SkRect_left">left</a> to <a href="#SkRect_right">right</a> order: the printed intersection may +be before or after the call to <a href="#SkRect_intersect">intersect</a>.</div> + +#### Example Output + +~~~~ +intersection: 30, 60, 50, 80 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_intersects">intersects</a> <a href="#SkRect_Intersects">Intersects</a> <a href="#SkRect_join">join</a> <a href="#SkIRect_intersect">SkIRect::intersect</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool SK_WARN_UNUSED_RESULT intersect(const SkRect& a, const SkRect& b) +</pre> + +Returns true if <a href="#SkRect_intersect_3_a">a</a> <a href="#SkRect_intersects">intersects</a> <a href="#SkRect_intersect_3_b">b</a>, and sets <a href="#Rect">Rect</a> to intersection. +Returns false if <a href="#SkRect_intersect_3_a">a</a> does not <a href="#SkRect_intersect">intersect</a> <a href="#SkRect_intersect_3_b">b</a>, and leaves <a href="#Rect">Rect</a> unchanged. + +Returns false if either <a href="#SkRect_intersect_3_a">a</a> or <a href="#SkRect_intersect_3_b">b</a> is empty, leaving <a href="#Rect">Rect</a> unchanged. + +### Parameters + +<table> <tr> <td><a name="SkRect_intersect_3_a"> <code><strong>a </strong></code> </a></td> <td> +<a href="#Rect">Rect</a> to <a href="#SkRect_intersect">intersect</a></td> + </tr> <tr> <td><a name="SkRect_intersect_3_b"> <code><strong>b </strong></code> </a></td> <td> +<a href="#Rect">Rect</a> to <a href="#SkRect_intersect">intersect</a></td> + </tr> +</table> + +### Return Value + +true if <a href="#SkRect_intersect_3_a">a</a> and <a href="#SkRect_intersect_3_b">b</a> have area in common + +### Example + +<div><fiddle-embed name="d610437a65dd3e952719efe605cbd0c7"> + +#### Example Output + +~~~~ +intersection: 30, 60, 50, 80 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_intersects">intersects</a> <a href="#SkRect_Intersects">Intersects</a> <a href="#SkRect_join">join</a> <a href="#SkIRect_intersect">SkIRect::intersect</a> + +--- + +<a name="SkRect_intersects"></a> +## intersects + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool intersects(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) const +</pre> + +Constructs <a href="#Rect">Rect</a> to <a href="#SkRect_intersect">intersect</a> from (<a href="#SkRect_left">left</a>, <a href="#SkRect_top">top</a>, <a href="#SkRect_right">right</a>, <a href="#SkRect_bottom">bottom</a>). Does not <a href="#SkRect_sort">sort</a> +construction. + +Returns true if <a href="#Rect">Rect</a> <a href="#SkRect_intersects">intersects</a> construction. +Returns false if either construction or <a href="#Rect">Rect</a> is empty, or do not <a href="#SkRect_intersect">intersect</a>. + +### Parameters + +<table> <tr> <td><a name="SkRect_intersects_left"> <code><strong>left </strong></code> </a></td> <td> +<a href="#SkRect_x">x</a> minimum of constructed <a href="#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkRect_intersects_top"> <code><strong>top </strong></code> </a></td> <td> +<a href="#SkRect_y">y</a> minimum of constructed <a href="#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkRect_intersects_right"> <code><strong>right </strong></code> </a></td> <td> +<a href="#SkRect_x">x</a> maximum of constructed <a href="#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkRect_intersects_bottom"> <code><strong>bottom </strong></code> </a></td> <td> +<a href="#SkRect_y">y</a> maximum of constructed <a href="#Rect">Rect</a></td> + </tr> +</table> + +### Return Value + +true if construction and <a href="#Rect">Rect</a> have area in common + +### Example + +<div><fiddle-embed name="7145dc17ebce4f54e892102f6c98e811"> + +#### Example Output + +~~~~ +intersection +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_intersect">intersect</a> <a href="#SkRect_Intersects">Intersects</a> <a href="#SkIRect_Intersects">SkIRect::Intersects</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool intersects(const SkRect& r) const +</pre> + +Returns true if <a href="#Rect">Rect</a> <a href="#SkRect_intersects">intersects</a> <a href="#SkRect_intersects_2_r">r</a>. +Returns false if either <a href="#SkRect_intersects_2_r">r</a> or <a href="#Rect">Rect</a> is empty, or do not <a href="#SkRect_intersect">intersect</a>. + +### Parameters + +<table> <tr> <td><a name="SkRect_intersects_2_r"> <code><strong>r </strong></code> </a></td> <td> +<a href="#Rect">Rect</a> to <a href="#SkRect_intersect">intersect</a></td> + </tr> +</table> + +### Return Value + +true if <a href="#SkRect_intersects_2_r">r</a> and <a href="#Rect">Rect</a> have area in common + +### Example + +<div><fiddle-embed name="ca37b4231b21eb8296cb19ba9e0c781b"> + +#### Example Output + +~~~~ +intersection +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_intersect">intersect</a> <a href="#SkRect_Intersects">Intersects</a> <a href="#SkIRect_Intersects">SkIRect::Intersects</a> + +--- + +<a name="SkRect_Intersects"></a> +## Intersects + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +static bool Intersects(const SkRect& a, const SkRect& b) +</pre> + +Returns true if <a href="#SkRect_Intersects_a">a</a> <a href="#SkRect_intersects">intersects</a> <a href="#SkRect_Intersects_b">b</a>. +Returns false if either <a href="#SkRect_Intersects_a">a</a> or <a href="#SkRect_Intersects_b">b</a> is empty, or do not <a href="#SkRect_intersect">intersect</a>. + +### Parameters + +<table> <tr> <td><a name="SkRect_Intersects_a"> <code><strong>a </strong></code> </a></td> <td> +<a href="#Rect">Rect</a> to <a href="#SkRect_intersect">intersect</a></td> + </tr> <tr> <td><a name="SkRect_Intersects_b"> <code><strong>b </strong></code> </a></td> <td> +<a href="#Rect">Rect</a> to <a href="#SkRect_intersect">intersect</a></td> + </tr> +</table> + +### Return Value + +true if <a href="#SkRect_Intersects_a">a</a> and <a href="#SkRect_Intersects_b">b</a> have area in common + +### Example + +<div><fiddle-embed name="795061764b10c9e05efb466c9cb60644"> + +#### Example Output + +~~~~ +intersection +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_intersect">intersect</a> <a href="#SkRect_intersects">intersects</a> <a href="#SkIRect_Intersects">SkIRect::Intersects</a> + +--- + +<a name="SkRect_join"></a> +## join + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void join(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) +</pre> + +Constructs <a href="#Rect">Rect</a> to <a href="#SkRect_intersect">intersect</a> from (<a href="#SkRect_left">left</a>, <a href="#SkRect_top">top</a>, <a href="#SkRect_right">right</a>, <a href="#SkRect_bottom">bottom</a>). Does not <a href="#SkRect_sort">sort</a> +construction. + +Sets <a href="#Rect">Rect</a> to the union of itself and the construction. + +Has no effect if construction is empty. Otherwise, if <a href="#Rect">Rect</a> is empty, sets +<a href="#Rect">Rect</a> to construction. + +### Parameters + +<table> <tr> <td><a name="SkRect_join_left"> <code><strong>left </strong></code> </a></td> <td> +<a href="#SkRect_x">x</a> minimum of constructed <a href="#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkRect_join_top"> <code><strong>top </strong></code> </a></td> <td> +<a href="#SkRect_y">y</a> minimum of constructed <a href="#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkRect_join_right"> <code><strong>right </strong></code> </a></td> <td> +<a href="#SkRect_x">x</a> maximum of constructed <a href="#Rect">Rect</a></td> + </tr> <tr> <td><a name="SkRect_join_bottom"> <code><strong>bottom </strong></code> </a></td> <td> +<a href="#SkRect_y">y</a> maximum of constructed <a href="#Rect">Rect</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="afa9c6b4d05bb669db07fe0b7b97e6aa"> + +#### Example Output + +~~~~ +join: 10, 20, 55, 65 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_joinNonEmptyArg">joinNonEmptyArg</a> <a href="#SkRect_joinPossiblyEmptyRect">joinPossiblyEmptyRect</a> <a href="#SkIRect_join">SkIRect::join</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void join(const SkRect& r) +</pre> + +Sets <a href="#Rect">Rect</a> to the union of itself and <a href="#SkRect_join_2_r">r</a>. + +Has no effect if <a href="#SkRect_join_2_r">r</a> is empty. Otherwise, if <a href="#Rect">Rect</a> is empty, sets +<a href="#Rect">Rect</a> to <a href="#SkRect_join_2_r">r</a>. + +### Parameters + +<table> <tr> <td><a name="SkRect_join_2_r"> <code><strong>r </strong></code> </a></td> <td> +expansion <a href="#Rect">Rect</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="26500032494cf93c5fa3423110fe82af"> + +#### Example Output + +~~~~ +join: 10, 20, 55, 65 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_joinNonEmptyArg">joinNonEmptyArg</a> <a href="#SkRect_joinPossiblyEmptyRect">joinPossiblyEmptyRect</a> <a href="#SkIRect_join">SkIRect::join</a> + +--- + +<a name="SkRect_joinNonEmptyArg"></a> +## joinNonEmptyArg + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void joinNonEmptyArg(const SkRect& r) +</pre> + +Sets <a href="#Rect">Rect</a> to the union of itself and <a href="#SkRect_joinNonEmptyArg_r">r</a>. + +Asserts if <a href="#SkRect_joinNonEmptyArg_r">r</a> is empty and <a href="undocumented#SK_DEBUG">SK DEBUG</a> is defined. +If <a href="#Rect">Rect</a> is empty, sets rect to <a href="#SkRect_joinNonEmptyArg_r">r</a>. + +May produce incorrect results if <a href="#SkRect_joinNonEmptyArg_r">r</a> is empty. + +### Parameters + +<table> <tr> <td><a name="SkRect_joinNonEmptyArg_r"> <code><strong>r </strong></code> </a></td> <td> +expansion <a href="#Rect">Rect</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="88439de2aa0911262c60c0eb506396cb"><div>Since rect is not sorted, first result is copy of toJoin.</div> + +#### Example Output + +~~~~ +rect: 50, 60, 55, 65 +sorted: 10, 0, 55, 100 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_join">join</a> <a href="#SkRect_joinPossiblyEmptyRect">joinPossiblyEmptyRect</a> <a href="#SkIRect_join">SkIRect::join</a> + +--- + +<a name="SkRect_joinPossiblyEmptyRect"></a> +## joinPossiblyEmptyRect + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void joinPossiblyEmptyRect(const SkRect& r) +</pre> + +Sets <a href="#Rect">Rect</a> to the union of itself and the construction. + +May produce incorrect results if <a href="#Rect">Rect</a> or <a href="#SkRect_joinPossiblyEmptyRect_r">r</a> is empty. + +### Parameters + +<table> <tr> <td><a name="SkRect_joinPossiblyEmptyRect_r"> <code><strong>r </strong></code> </a></td> <td> +expansion <a href="#Rect">Rect</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="a476548d0001296afd8e58c1eba1b70b"><div>Since rect is not sorted, first result is not useful.</div> + +#### Example Output + +~~~~ +rect: 10, 60, 55, 65 +sorted: 10, 0, 55, 100 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_joinNonEmptyArg">joinNonEmptyArg</a> <a href="#SkRect_join">join</a> <a href="#SkIRect_join">SkIRect::join</a> + +--- + +<a name="SkRect_growToInclude"></a> +## growToInclude + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void growToInclude(SkPoint pt) +</pre> + +Grows <a href="#Rect">Rect</a> to include (<a href="#SkRect_growToInclude_pt">pt</a>.fX, <a href="#SkRect_growToInclude_pt">pt</a>.fY), modifying it so that: +<a href="#SkRect_fLeft">fLeft</a> <= <a href="#SkRect_growToInclude_pt">pt</a>.fX <= <a href="#SkRect_fRight">fRight</a> && <a href="#SkRect_fTop">fTop</a> <= <a href="#SkRect_growToInclude_pt">pt</a>.fY <= <a href="#SkRect_fBottom">fBottom</a>. + +If <a href="#Rect">Rect</a> is initialized with <a href="#SkRect_setLargestInverted">setLargestInverted</a>, then <a href="#Rect">Rect</a> will contain bounds of +<a href="#Point">Points</a> after one or more calls. In this case, <a href="#Rect">Rect</a> is empty after first call. + +### Parameters + +<table> <tr> <td><a name="SkRect_growToInclude_pt"> <code><strong>pt </strong></code> </a></td> <td> +<a href="undocumented#Point">Point</a> to include</td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="c2855b1bc92b4e332f6edd968065e4f0"> + +#### Example Output + +~~~~ +rect: 42, 24, 42, 24 isEmpty: true +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_setLargestInverted">setLargestInverted</a> <a href="#SkRect_join">join</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void growToInclude(const SkPoint pts[], int count) +</pre> + +For each of <a href="#SkRect_growToInclude_2_count">count</a> <a href="undocumented#Point">Point</a> in <a href="#SkRect_growToInclude_2_pts">pts</a>, grows <a href="#Rect">Rect</a> to include (pt.fX, pt.fY), modifying +it so that: +<a href="#SkRect_fLeft">fLeft</a> <= pt.fX <= <a href="#SkRect_fRight">fRight</a> && <a href="#SkRect_fTop">fTop</a> <= pt.fY <= <a href="#SkRect_fBottom">fBottom</a>. + +If <a href="#Rect">Rect</a> is initialized with <a href="#SkRect_setLargestInverted">setLargestInverted</a>, then <a href="#Rect">Rect</a> will contain bounds of +<a href="#Point">Points</a> after one or more calls. In this case, <a href="#Rect">Rect</a> is empty after first call. + +### Parameters + +<table> <tr> <td><a name="SkRect_growToInclude_2_pts"> <code><strong>pts </strong></code> </a></td> <td> +<a href="undocumented#Point">Point</a> array</td> + </tr> <tr> <td><a name="SkRect_growToInclude_2_count"> <code><strong>count </strong></code> </a></td> <td> +number of points in array</td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="73082d5aea2026cae4c42ec587417df2"> + +#### Example Output + +~~~~ +rect: 30, 50, 40, 60 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_setLargestInverted">setLargestInverted</a> <a href="#SkRect_join">join</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void growToInclude(const SkPoint pts[], size_t stride, int count) +</pre> + +For each of <a href="#SkRect_growToInclude_3_count">count</a> <a href="undocumented#Point">Point</a> in <a href="#SkRect_growToInclude_3_pts">pts</a>, grows <a href="#Rect">Rect</a> to include (pt.fX, pt.fY), modifying +it so that: +<a href="#SkRect_fLeft">fLeft</a> <= pt.fX <= <a href="#SkRect_fRight">fRight</a> && <a href="#SkRect_fTop">fTop</a> <= pt.fY <= <a href="#SkRect_fBottom">fBottom</a>. +<a href="undocumented#Point">Point</a> may be followed with other data in each array element. <a href="#SkRect_growToInclude_3_stride">stride</a> is number +of bytes in element; the interval to skip to advance from one <a href="undocumented#Point">Point</a> to +the next. + +If <a href="#Rect">Rect</a> is initialized with <a href="#SkRect_setLargestInverted">setLargestInverted</a>, then <a href="#Rect">Rect</a> will contain bounds of +<a href="#Point">Points</a> after one or more calls. In this case, <a href="#Rect">Rect</a> is empty after first call. + +### Parameters + +<table> <tr> <td><a name="SkRect_growToInclude_3_pts"> <code><strong>pts </strong></code> </a></td> <td> +array of elements beginning with <a href="undocumented#Point">Point</a></td> + </tr> <tr> <td><a name="SkRect_growToInclude_3_stride"> <code><strong>stride </strong></code> </a></td> <td> +size of <a href="#SkRect_growToInclude_3_pts">pts</a> elements in 32-bit words; zero or greater</td> + </tr> <tr> <td><a name="SkRect_growToInclude_3_count"> <code><strong>count </strong></code> </a></td> <td> +number of elements in array</td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="6dbf21017c60b76cae3379fd9101342a"> + +#### Example Output + +~~~~ +#Volatile +rect: 30, 50, 40, 60 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_setLargestInverted">setLargestInverted</a> <a href="#SkRect_join">join</a> + +--- + +<a name="SkRect_contains"></a> +## contains + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool contains(const SkRect& r) const { +</pre> + +Returns true if <a href="#Rect">Rect</a> <a href="#SkRect_contains">contains</a> <a href="#SkRect_contains_r">r</a>. +Returns false if <a href="#Rect">Rect</a> is empty or <a href="#SkRect_contains_r">r</a> is empty. + +<a href="#Rect">Rect</a> <a href="#SkRect_contains">contains</a> <a href="#SkRect_contains_r">r</a> when <a href="#Rect">Rect</a> area completely includes <a href="#SkRect_contains_r">r</a> area. + +### Parameters + +<table> <tr> <td><a name="SkRect_contains_r"> <code><strong>r </strong></code> </a></td> <td> +<a href="#Rect">Rect</a> contained</td> + </tr> +</table> + +### Return Value + +true if all sides of <a href="#Rect">Rect</a> are outside <a href="#SkRect_contains_r">r</a> + +### Example + +<div><fiddle-embed name="92f9e6aa5bb76791139a24cf7d8df99e"> + +#### Example Output + +~~~~ +rect: (30, 50, 40, 60) contains (30, 50, 31, 51) +rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50) +rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60) +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_contains">SkIRect::contains</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +bool contains(const SkIRect& r) const +</pre> + +Returns true if <a href="#Rect">Rect</a> <a href="#SkRect_contains">contains</a> <a href="#SkRect_contains_2_r">r</a>. +Returns false if <a href="#Rect">Rect</a> is empty or <a href="#SkRect_contains_2_r">r</a> is empty. + +<a href="#Rect">Rect</a> <a href="#SkRect_contains">contains</a> <a href="#SkRect_contains_2_r">r</a> when <a href="#Rect">Rect</a> area completely includes <a href="#SkRect_contains_2_r">r</a> area. + +### Parameters + +<table> <tr> <td><a name="SkRect_contains_2_r"> <code><strong>r </strong></code> </a></td> <td> +<a href="SkIRect_Reference#IRect">IRect</a> contained</td> + </tr> +</table> + +### Return Value + +true if all sides of <a href="#Rect">Rect</a> are outside <a href="#SkRect_contains_2_r">r</a> + +### Example + +<div><fiddle-embed name="dd58b699551dd44026a2c6386be27d88"> + +#### Example Output + +~~~~ +rect: (30, 50, 40, 60) contains (30, 50, 31, 51) +rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50) +rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60) +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkIRect_contains">SkIRect::contains</a> + +--- + +# <a name="Round"></a> Round + +<a name="SkRect_round"></a> +## round + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void round(SkIRect* dst) const +</pre> + +Sets <a href="SkIRect_Reference#IRect">IRect</a> by adding 0.5 and discarding the fractional portion of <a href="#Rect">Rect</a> +members, using(. + +### Parameters + +<table> <tr> <td><a name="SkRect_round_dst"> <code><strong>dst </strong></code> </a></td> <td> +storage for <a href="SkIRect_Reference#IRect">IRect</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="8b9e5a9af0a9b878f76919534d88f41e"> + +#### Example Output + +~~~~ +round: 31, 51, 41, 61 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_roundIn">roundIn</a> <a href="#SkRect_roundOut">roundOut</a> <a href="undocumented#SkScalarRoundToInt">SkScalarRoundToInt</a> + +--- + +<a name="SkRect_roundOut"></a> +## roundOut + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void roundOut(SkIRect* dst) const +</pre> + +Sets <a href="SkIRect_Reference#IRect">IRect</a> by discarding the fractional portion of <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fTop">fTop</a>; and +rounding up <a href="#SkRect_fRight">fRight</a> and FBottom, using(. + +### Parameters + +<table> <tr> <td><a name="SkRect_roundOut_dst"> <code><strong>dst </strong></code> </a></td> <td> +storage for <a href="SkIRect_Reference#IRect">IRect</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="0bd13d7e6426ae7a3befa2ab151ac5fc"> + +#### Example Output + +~~~~ +round: 30, 50, 41, 61 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_roundIn">roundIn</a> <a href="#SkRect_round">round</a> <a href="undocumented#SkScalarRoundToInt">SkScalarRoundToInt</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void roundOut(SkRect* dst) const +</pre> + +Sets <a href="#Rect">Rect</a> by discarding the fractional portion of <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fTop">fTop</a>; and +rounding up <a href="#SkRect_fRight">fRight</a> and FBottom, using(. + +### Parameters + +<table> <tr> <td><a name="SkRect_roundOut_2_dst"> <code><strong>dst </strong></code> </a></td> <td> +storage for <a href="#Rect">Rect</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="e09a6a12869a8ac21e9c2af98a5bb686"> + +#### Example Output + +~~~~ +round: 30, 50, 41, 61 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_roundIn">roundIn</a> <a href="#SkRect_round">round</a> <a href="undocumented#SkScalarRoundToInt">SkScalarRoundToInt</a> + +--- + +<a name="SkRect_roundIn"></a> +## roundIn + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void roundIn(SkIRect* dst) const +</pre> + +Sets <a href="#Rect">Rect</a> by rounding up <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fTop">fTop</a>; and +discarding the fractional portion of <a href="#SkRect_fRight">fRight</a> and FBottom, using(. + +### Parameters + +<table> <tr> <td><a name="SkRect_roundIn_dst"> <code><strong>dst </strong></code> </a></td> <td> +storage for <a href="SkIRect_Reference#IRect">IRect</a></td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="abb337da8fc1891f016c61258681c64c"> + +#### Example Output + +~~~~ +round: 31, 51, 40, 60 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_roundOut">roundOut</a> <a href="#SkRect_round">round</a> <a href="undocumented#SkScalarRoundToInt">SkScalarRoundToInt</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkIRect round() const +</pre> + +Returns <a href="SkIRect_Reference#IRect">IRect</a> by adding 0.5 and discarding the fractional portion of <a href="#Rect">Rect</a> +members, using(. + +### Return Value + +rounded <a href="SkIRect_Reference#IRect">IRect</a> + +### Example + +<div><fiddle-embed name="ef7ae1dd522c235b0afe41b55a624f46"> + +#### Example Output + +~~~~ +round: 31, 51, 41, 61 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_roundOut">roundOut</a> <a href="#SkRect_roundIn">roundIn</a> <a href="undocumented#SkScalarRoundToInt">SkScalarRoundToInt</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkIRect roundOut() const +</pre> + +Sets <a href="SkIRect_Reference#IRect">IRect</a> by discarding the fractional portion of <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fTop">fTop</a>; and +rounding up <a href="#SkRect_fRight">fRight</a> and FBottom, using(. + +### Return Value + +rounded <a href="SkIRect_Reference#IRect">IRect</a> + +### Example + +<div><fiddle-embed name="05f0f65ae148f192656cd87df90f1d57"> + +#### Example Output + +~~~~ +round: 30, 50, 41, 61 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_round">round</a> <a href="#SkRect_roundIn">roundIn</a> <a href="undocumented#SkScalarRoundToInt">SkScalarRoundToInt</a> + +--- + +<a name="SkRect_sort"></a> +## sort + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void sort() +</pre> + +Swaps <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fRight">fRight</a> if <a href="#SkRect_fLeft">fLeft</a> is greater than <a href="#SkRect_fRight">fRight</a>; and swaps +<a href="#SkRect_fTop">fTop</a> and <a href="#SkRect_fBottom">fBottom</a> if <a href="#SkRect_fTop">fTop</a> is greater than <a href="#SkRect_fBottom">fBottom</a>. Result may be empty; +and <a href="#SkRect_width">width</a> and <a href="#SkRect_height">height</a> will be zero or positive. + +### Example + +<div><fiddle-embed name="e624fe398e3d770b573c09fc74c0c400"> + +#### Example Output + +~~~~ +rect: 30.5, 50.5, 20.5, 10.5 +sorted: 20.5, 10.5, 30.5, 50.5 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_makeSorted">makeSorted</a> <a href="#SkIRect_sort">SkIRect::sort</a> + +--- + +<a name="SkRect_makeSorted"></a> +## makeSorted + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkRect makeSorted() const +</pre> + +Returns <a href="#Rect">Rect</a> with <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fRight">fRight</a> swapped if <a href="#SkRect_fLeft">fLeft</a> is greater than <a href="#SkRect_fRight">fRight</a>; and +with <a href="#SkRect_fTop">fTop</a> and <a href="#SkRect_fBottom">fBottom</a> swapped if <a href="#SkRect_fTop">fTop</a> is greater than <a href="#SkRect_fBottom">fBottom</a>. Result may be empty; +and <a href="#SkRect_width">width</a> and <a href="#SkRect_height">height</a> will be zero or positive. + +### Return Value + +sorted <a href="#Rect">Rect</a> + +### Example + +<div><fiddle-embed name="f59567042b87f6b26f9bfeeb04468032"> + +#### Example Output + +~~~~ +rect: 30.5, 50.5, 20.5, 10.5 +sorted: 20.5, 10.5, 30.5, 50.5 +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_sort">sort</a> <a href="#SkIRect_makeSorted">SkIRect::makeSorted</a> + +--- + +<a name="SkRect_asScalars"></a> +## asScalars + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +const SkScalar* asScalars() const +</pre> + +Returns pointer to first <a href="#Scalar">Scalar</a> in <a href="#Rect">Rect</a>, to treat it as an array with four +entries. + +### Return Value + +pointer to <a href="#SkRect_fLeft">fLeft</a> + +### Example + +<div><fiddle-embed name="e1ea5f949d80276f3637931eae93a07c"> + +#### Example Output + +~~~~ +rect.asScalars() == &rect.fLeft +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_toQuad">toQuad</a> + +--- + +<a name="SkRect_dump"></a> +## dump + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void dump(bool asHex) const +</pre> + +Writes text representation of <a href="#Rect">Rect</a> to standard output. Set <a href="#SkRect_dump_asHex">asHex</a> to true to +generate exact binary representations of floating point numbers. + +### Parameters + +<table> <tr> <td><a name="SkRect_dump_asHex"> <code><strong>asHex </strong></code> </a></td> <td> +true if <a href="undocumented#SkScalar">SkScalar</a> values are written as hexadecimal</td> + </tr> +</table> + +### Example + +<div><fiddle-embed name="cea049ffff702a5923da41fe0ae0763b"> + +#### Example Output + +~~~~ +SkRect::MakeLTRB(20, 30, 40, 50); +SkRect::MakeLTRB(SkBits2Float(0x41a00000), /* 20.000000 */ +SkBits2Float(0x41f00000), /* 30.000000 */ +SkBits2Float(0x42200000), /* 40.000000 */ +SkBits2Float(0x42480000) /* 50.000000 */); +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_dumpHex">dumpHex</a> + +--- + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void dump() const +</pre> + +Writes text representation of <a href="#Rect">Rect</a> to standard output. The representation may be +directly compiled as <a href="undocumented#C">C</a>++ code. Floating point values are written +with limited precision; it may not be possible to reconstruct original <a href="#Rect">Rect</a> +from output. + +### Example + +<div><fiddle-embed name="9fb76971b1a104a2a59816e0392267a7"> + +#### Example Output + +~~~~ +SkRect::MakeLTRB(0.857143f, 0.666667f, 2.6f, 7); +rect is not equal to copy +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_dumpHex">dumpHex</a> + +--- + +<a name="SkRect_dumpHex"></a> +## dumpHex + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +void dumpHex() const +</pre> + +Writes text representation of <a href="#Rect">Rect</a> to standard output. The representation may be +directly compiled as <a href="undocumented#C">C</a>++ code. Floating point values are written +in hexadecimal to preserve their exact bit pattern. The output reconstructs the +original <a href="#Rect">Rect</a>. + +Use instead of <a href="#SkRect_dump_2">dump</a> when submittingbug reports against <a href="undocumented#Skia">Skia</a>. + +### Example + +<div><fiddle-embed name="824b5a3fcfd46a7e1c5f9e3c16e6bb39"> + +#### Example Output + +~~~~ +SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */ +SkBits2Float(0x3f2aaaab), /* 0.666667 */ +SkBits2Float(0x40266666), /* 2.600000 */ +SkBits2Float(0x40e00000) /* 7.000000 */); +rect is equal to copy +~~~~ + +</fiddle-embed></div> + +### See Also + +<a href="#SkRect_dump">dump</a> + +--- + diff --git a/site/user/api/undocumented.md b/site/user/api/undocumented.md index e0c27af766..721283cdd1 100644 --- a/site/user/api/undocumented.md +++ b/site/user/api/undocumented.md @@ -31,6 +31,17 @@ SkCanvas* beginPage(SkScalar width, SkScalar height, # <a name="Mip_Map"></a> Mip Map +# <a name="Debugging"></a> Debugging + +<a name="SkDebugf"></a> +## SkDebugf + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SK_API void SkDebugf(const char format[], ...) +</pre> + +--- + # <a name="Region"></a> Region # <a name="SkRegion"></a> Class SkRegion @@ -689,14 +700,46 @@ SkScalarCeilToScalar(x) --- +<a name="SkScalarIsFinite"></a> +## SkScalarIsFinite + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkScalarIsFinite(x) +</pre> + +--- + +<a name="SkScalarIsNaN"></a> +## SkScalarIsNaN + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +SkScalarIsNaN(x) +</pre> + +--- + +<a name="SkTFitsIn"></a> +## SkTFitsIn + +<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0"> +template <typename D, typename S> inline bool SkTFitsIn(S s) +</pre> + +--- + # <a name="Nine_Patch"></a> Nine Patch # <a name="Number_Types"></a> Number Types +# <a name="Scalar"></a> Scalar + ### Constants <table> <tr> + <td><a name="SK_ScalarMin"> <code><strong>SK_ScalarMin </strong></code> </a></td><td>to be written</td><td></td> + </tr> + <tr> <td><a name="SK_ScalarMax"> <code><strong>SK_ScalarMax </strong></code> </a></td><td>to be written</td><td></td> </tr> <tr> @@ -708,6 +751,12 @@ SkScalarCeilToScalar(x) <tr> <td><a name="SK_ScalarNaN"> <code><strong>SK_ScalarNaN </strong></code> </a></td><td>to be written</td><td></td> </tr> + <tr> + <td><a name="SK_MinS32"> <code><strong>SK_MinS32 </strong></code> </a></td><td>to be written</td><td></td> + </tr> + <tr> + <td><a name="SK_MaxS32"> <code><strong>SK_MaxS32 </strong></code> </a></td><td>to be written</td><td></td> + </tr> </table> # <a name="OS_X"></a> OS X diff --git a/tools/bookmaker/spellCheck.cpp b/tools/bookmaker/spellCheck.cpp index eb430f877c..6e80ee77c2 100644 --- a/tools/bookmaker/spellCheck.cpp +++ b/tools/bookmaker/spellCheck.cpp @@ -409,7 +409,7 @@ void SpellCheck::leafCheck(const char* start, const char* end) { } else { wordEnd = chPtr; } - SkASSERT(inParens >= 0); + SkASSERT(inParens >= 0 || fInStdOut); break; case '\"': inQuotes = !inQuotes; |