Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1 | #Topic IRect |
| 2 | #Alias IRect_Reference |
| 3 | |
| 4 | #Struct SkIRect |
| 5 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 6 | SkIRect holds four 32 bit integer coordinates describing the upper and |
| 7 | lower bounds of a rectangle. SkIRect may be created from outer bounds or |
| 8 | from position, width, and height. SkIRect describes an area; if its right |
| 9 | is less than or equal to its left, or if its bottom is less than or equal to |
| 10 | its top, it is considered empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 11 | |
| 12 | #Topic Overview |
| 13 | |
| 14 | #Subtopic Subtopics |
| 15 | #ToDo manually add subtopics ## |
| 16 | #Table |
| 17 | #Legend |
| 18 | # topics # description ## |
| 19 | #Legend ## |
| 20 | #Table ## |
| 21 | ## |
| 22 | |
| 23 | #Subtopic Operators |
| 24 | #Table |
| 25 | #Legend |
| 26 | # description # function ## |
| 27 | #Legend ## |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 28 | # friend bool operator!=(const SkIRect& a, const SkIRect& b) # Returns true if members are unequal. ## |
| 29 | # friend bool operator==(const SkIRect& a, const SkIRect& b) # Returns true if members are equal. ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 30 | #Table ## |
| 31 | #Subtopic ## |
| 32 | |
| 33 | #Subtopic Member_Functions |
| 34 | #Table |
| 35 | #Legend |
| 36 | # description # function ## |
| 37 | #Legend ## |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 38 | # EmptyIRect # Returns immutable bounds of (0, 0, 0, 0). ## |
| 39 | # Intersects # Returns true if areas overlap. ## |
| 40 | # IntersectsNoEmptyCheck # Returns true if areas overlap. Skips empty check. ## |
| 41 | # MakeEmpty # Returns bounds of (0, 0, 0, 0). ## |
| 42 | # MakeLTRB # Constructs from int left, top, right, bottom. ## |
| 43 | # MakeLargest # Constructs from (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32). ## |
| 44 | # MakeSize # Constructs from ISize returning (0, 0, width, height). ## |
| 45 | # MakeWH # Constructs from int input returning (0, 0, width, height). ## |
| 46 | # MakeXYWH # Constructs from int input returning (x, y, width, height). ## |
| 47 | # bottom() # Returns larger bounds in y, if sorted. ## |
| 48 | # centerX # Returns midpoint in x. ## |
| 49 | # centerY # Returns midpoint in y. ## |
| 50 | # contains() # Returns true if points are equal or inside. ## |
| 51 | # containsNoEmptyCheck # Returns true if points are equal or inside. Skips empty check. ## |
| 52 | # height() # Returns span in y. ## |
| 53 | # inset() # Moves the sides symmetrically about the center. ## |
| 54 | # intersect # Sets to shared area; returns true if not empty. ## |
| 55 | # intersectNoEmptyCheck # Sets to shared area; returns true if not empty. Skips empty check. ## |
| 56 | # is16Bit # Returns true if members fit in 16-bit word. ## |
| 57 | # isEmpty # Returns true if width or height are zero or negative. ## |
| 58 | # isLargest # Returns true if equal to (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32). ## |
| 59 | # join() # Sets to union of bounds. ## |
| 60 | # left() # Returns smaller bounds in x, if sorted. ## |
| 61 | # makeInset # Constructs from sides moved symmetrically about the center. ## |
| 62 | # makeOffset # Constructs from translated sides. ## |
| 63 | # makeOutset # Constructs from sides moved symmetrically about the center. ## |
| 64 | # makeSorted # Constructs, ordering sides from smaller to larger. ## |
| 65 | # offset() # Translates sides without changing width and height. ## |
| 66 | # offsetTo # Translates to (x, y) without changing width and height. ## |
| 67 | # outset() # Moves the sides symmetrically about the center. ## |
| 68 | # quickReject # Returns true if rectangles do not intersect. ## |
| 69 | # right() # Returns larger bounds in x, if sorted. ## |
| 70 | # set() # Sets to (left, top, right, bottom). ## |
| 71 | # setEmpty # Sets to (0, 0, 0, 0). ## |
| 72 | # setLTRB # Sets to SkScalar input (left, top, right, bottom). ## |
| 73 | # setLargest # Sets to (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32). ## |
| 74 | # setLargestInverted # Sets to (SK_MaxS32, SK_MaxS32, SK_MinS32, SK_MinS32). ## |
| 75 | # setXYWH # Sets to (x, y, width, height). ## |
| 76 | # size() # Returns ISize (width, height). ## |
| 77 | # sort() # Orders sides from smaller to larger. ## |
| 78 | # top() # Returns smaller bounds in y, if sorted. ## |
| 79 | # width() # Returns span in x. ## |
| 80 | # x() # Returns bounds left. ## |
| 81 | # y() # Returns bounds top. ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 82 | #Table ## |
| 83 | #Subtopic ## |
| 84 | |
| 85 | #Topic ## |
| 86 | |
| 87 | #Member int32_t fLeft |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 88 | May contain any value. The smaller of the horizontal values when sorted. |
| 89 | When equal to or greater than fRight, IRect is empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 90 | ## |
| 91 | |
| 92 | #Member int32_t fTop |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 93 | May contain any value. The smaller of the horizontal values when sorted. |
| 94 | When equal to or greater than fBottom, IRect is empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 95 | ## |
| 96 | |
| 97 | #Member int32_t fRight |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 98 | May contain any value. The larger of the vertical values when sorted. |
| 99 | When equal to or less than fLeft, IRect is empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 100 | ## |
| 101 | |
| 102 | #Member int32_t fBottom |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 103 | May contain any value. The larger of the vertical values when sorted. |
| 104 | When equal to or less than fTop, IRect is empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 105 | ## |
| 106 | |
| 107 | # ------------------------------------------------------------------------------ |
| 108 | |
| 109 | #Method static SkIRect SK_WARN_UNUSED_RESULT MakeEmpty() |
| 110 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 111 | Returns constructed IRect set to (0, 0, 0, 0). |
| 112 | Many other rectangles are empty; if left is equal to or greater than right, |
| 113 | or if top is equal to or greater than bottom. Setting all members to zero |
| 114 | is a convenience, but does not designate a special empty rectangle. |
| 115 | |
| 116 | #Return bounds (0, 0, 0, 0) ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 117 | |
| 118 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 119 | SkIRect rect = SkIRect::MakeEmpty();
|
| 120 | SkDebugf("MakeEmpty isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
|
| 121 | rect.offset(10, 10);
|
| 122 | SkDebugf("offset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
|
| 123 | rect.inset(10, 10);
|
| 124 | SkDebugf("inset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
|
| 125 | rect.outset(20, 20);
|
| 126 | SkDebugf("outset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
|
| 127 | #StdOut
|
| 128 | MakeEmpty isEmpty: true
|
| 129 | offset rect isEmpty: true
|
| 130 | inset rect isEmpty: true
|
| 131 | outset rect isEmpty: false
|
| 132 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 133 | ## |
| 134 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 135 | #SeeAlso EmptyIRect isEmpty setEmpty setLargestInverted SkRect::MakeEmpty |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 136 | |
| 137 | ## |
| 138 | |
| 139 | # ------------------------------------------------------------------------------ |
| 140 | |
| 141 | #Method static SkIRect SK_WARN_UNUSED_RESULT MakeLargest() |
| 142 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 143 | Returns constructed IRect setting left and top to most negative value, and |
| 144 | setting right and bottom to most positive value. |
| 145 | |
| 146 | #Return bounds (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32) ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 147 | |
| 148 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 149 | SkIRect rect = SkIRect::MakeLargest();
|
| 150 | SkDebugf("MakeLargest isLargest: %s\n", rect.isLargest() ? "true" : "false");
|
| 151 | SkDebugf("MakeLargest isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
|
| 152 | rect.outset(1, 1);
|
| 153 | SkDebugf("outset isLargest: %s\n", rect.isLargest() ? "true" : "false");
|
| 154 | SkDebugf("outset isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
|
| 155 | #StdOut
|
| 156 | MakeLargest isLargest: true
|
| 157 | MakeLargest isEmpty: false
|
| 158 | outset isLargest: false
|
| 159 | outset isEmpty: true
|
| 160 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 161 | ## |
| 162 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 163 | #SeeAlso isLargest setLargest SkRect::MakeLargest |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 164 | |
| 165 | ## |
| 166 | |
| 167 | # ------------------------------------------------------------------------------ |
| 168 | |
| 169 | #Method static SkIRect SK_WARN_UNUSED_RESULT MakeWH(int32_t w, int32_t h) |
| 170 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 171 | Returns constructed IRect set to (0, 0, w, h). Does not validate input; w or h |
| 172 | may be negative. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 173 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 174 | #Param w width of constructed Rect ## |
| 175 | #Param h height of constructed Rect ## |
| 176 | |
| 177 | #Return bounds (0, 0, w, h) ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 178 | |
| 179 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 180 | SkIRect rect1 = SkIRect::MakeWH(25, 35);
|
| 181 | SkIRect rect2 = SkIRect::MakeSize({25, 35});
|
| 182 | SkIRect rect3 = SkIRect::MakeXYWH(0, 0, 25, 35);
|
| 183 | SkIRect rect4 = SkIRect::MakeLTRB(0, 0, 25, 35);
|
| 184 | SkDebugf("all %s" "equal\n", rect1 == rect2 && rect2 == rect3 && rect3 == rect4 ?
|
| 185 | "" : "not ");
|
| 186 | #StdOut |
| 187 | all equal |
| 188 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 189 | ## |
| 190 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 191 | #SeeAlso MakeSize MakeXYWH SkRect::MakeWH SkRect::MakeIWH |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 192 | |
| 193 | ## |
| 194 | |
| 195 | # ------------------------------------------------------------------------------ |
| 196 | |
| 197 | #Method static SkIRect SK_WARN_UNUSED_RESULT MakeSize(const SkISize& size) |
| 198 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 199 | Returns constructed IRect set to (0, 0, size.width(), size.height()). |
| 200 | Does not validate input; size.width() or size.height() may be negative. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 201 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 202 | #Param size values for Rect width and height ## |
| 203 | |
| 204 | #Return bounds (0, 0, size.width(), size.height()) ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 205 | |
| 206 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 207 | SkSize size = {25.5f, 35.5f};
|
| 208 | SkIRect rect = SkIRect::MakeSize(size.toRound());
|
| 209 | SkDebugf("round width: %d height: %d\n", rect.width(), rect.height());
|
| 210 | rect = SkIRect::MakeSize(size.toFloor());
|
| 211 | SkDebugf("floor width: %d height: %d\n", rect.width(), rect.height());
|
| 212 | #StdOut |
| 213 | round width: 26 height: 36
|
| 214 | floor width: 25 height: 35 |
| 215 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 216 | ## |
| 217 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 218 | #SeeAlso MakeWH MakeXYWH SkRect::Make SkRect::MakeIWH |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 219 | |
| 220 | ## |
| 221 | |
| 222 | # ------------------------------------------------------------------------------ |
| 223 | |
| 224 | #Method static SkIRect SK_WARN_UNUSED_RESULT MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b) |
| 225 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 226 | Returns constructed IRect set to (l, t, r, b). Does not sort input; Rect may |
| 227 | result in fLeft greater than fRight, or fTop greater than fBottom. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 228 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 229 | #Param l integer stored in fLeft ## |
| 230 | #Param t integer stored in fTop ## |
| 231 | #Param r integer stored in fRight ## |
| 232 | #Param b integer stored in fBottom ## |
| 233 | |
| 234 | #Return bounds (l, t, r, b) ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 235 | |
| 236 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 237 | SkIRect rect = SkIRect::MakeLTRB(5, 35, 15, 25);
|
| 238 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
|
| 239 | rect.bottom(), rect.isEmpty() ? "true" : "false");
|
| 240 | rect.sort();
|
| 241 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
|
| 242 | rect.bottom(), rect.isEmpty() ? "true" : "false");
|
| 243 | #StdOut |
| 244 | rect: 5, 35, 15, 25 isEmpty: true
|
| 245 | rect: 5, 25, 15, 35 isEmpty: false |
| 246 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 247 | ## |
| 248 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 249 | #SeeAlso MakeXYWH SkRect::MakeLTRB |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 250 | |
| 251 | ## |
| 252 | |
| 253 | # ------------------------------------------------------------------------------ |
| 254 | |
| 255 | #Method static SkIRect SK_WARN_UNUSED_RESULT MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h) |
| 256 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 257 | Returns constructed IRect set to |
| 258 | #Formula |
| 259 | (x, y, x + w, y + h) |
| 260 | ## |
| 261 | . Does not validate input; |
| 262 | w or h may be negative. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 263 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 264 | #Param x stored in fLeft ## |
| 265 | #Param y stored in fTop ## |
| 266 | #Param w added to x and stored in fRight ## |
| 267 | #Param h added to y and stored in fBottom ## |
| 268 | |
| 269 | #Return bounds (x, y, x + w, y + h) ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 270 | |
| 271 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 272 | SkIRect rect = SkIRect::MakeXYWH(5, 35, -15, 25);
|
| 273 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
|
| 274 | rect.bottom(), rect.isEmpty() ? "true" : "false");
|
| 275 | rect.sort();
|
| 276 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
|
| 277 | rect.bottom(), rect.isEmpty() ? "true" : "false");
|
| 278 | #StdOut |
| 279 | rect: 5, 35, -10, 60 isEmpty: true
|
| 280 | rect: -10, 35, 5, 60 isEmpty: false |
| 281 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 282 | ## |
| 283 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 284 | #SeeAlso MakeLTRB SkRect::MakeXYWH |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 285 | |
| 286 | ## |
| 287 | |
| 288 | # ------------------------------------------------------------------------------ |
| 289 | |
| 290 | #Method int left() const |
| 291 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 292 | Returns left edge of IRect, if sorted. |
| 293 | Call sort() to reverse fLeft and fRight if needed. |
| 294 | |
| 295 | #Return fLeft ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 296 | |
| 297 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 298 | SkIRect unsorted = { 15, 5, 10, 25 };
|
| 299 | SkDebugf("unsorted.fLeft: %d unsorted.left(): %d\n", unsorted.fLeft, unsorted.left());
|
| 300 | SkIRect sorted = unsorted.makeSorted();
|
| 301 | SkDebugf("sorted.fLeft: %d sorted.left(): %d\n", sorted.fLeft, sorted.left());
|
| 302 | #StdOut |
| 303 | unsorted.fLeft: 15 unsorted.left(): 15
|
| 304 | sorted.fLeft: 10 sorted.left(): 10 |
| 305 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 306 | ## |
| 307 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 308 | #SeeAlso fLeft x() SkRect::left() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 309 | |
| 310 | ## |
| 311 | |
| 312 | # ------------------------------------------------------------------------------ |
| 313 | |
| 314 | #Method int top() const |
| 315 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 316 | Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid, |
| 317 | and sort() to reverse fTop and fBottom if needed. |
| 318 | |
| 319 | #Return fTop ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 320 | |
| 321 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 322 | SkIRect unsorted = { 15, 25, 10, 5 };
|
| 323 | SkDebugf("unsorted.fTop: %d unsorted.top(): %d\n", unsorted.fTop, unsorted.top());
|
| 324 | SkIRect sorted = unsorted.makeSorted();
|
| 325 | SkDebugf("sorted.fTop: %d sorted.top(): %d\n", sorted.fTop, sorted.top()); |
| 326 | #StdOut |
| 327 | unsorted.fTop: 25 unsorted.top(): 25
|
| 328 | sorted.fTop: 5 sorted.top(): 5 |
| 329 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 330 | ## |
| 331 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 332 | #SeeAlso fTop y() SkRect::top() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 333 | |
| 334 | ## |
| 335 | |
| 336 | # ------------------------------------------------------------------------------ |
| 337 | |
| 338 | #Method int right() const |
| 339 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 340 | Returns right edge of IRect, if sorted. |
| 341 | Call sort() to reverse fLeft and fRight if needed. |
| 342 | |
| 343 | #Return fRight ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 344 | |
| 345 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 346 | SkIRect unsorted = { 15, 25, 10, 5 };
|
| 347 | SkDebugf("unsorted.fRight: %d unsorted.right(): %d\n", unsorted.fRight, unsorted.right());
|
| 348 | SkIRect sorted = unsorted.makeSorted();
|
| 349 | SkDebugf("sorted.fRight: %d sorted.right(): %d\n", sorted.fRight, sorted.right());
|
| 350 | #StdOut |
| 351 | unsorted.fRight: 10 unsorted.right(): 10
|
| 352 | sorted.fRight: 15 sorted.right(): 15 |
| 353 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 354 | ## |
| 355 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 356 | #SeeAlso fRight SkRect::right() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 357 | |
| 358 | ## |
| 359 | |
| 360 | # ------------------------------------------------------------------------------ |
| 361 | |
| 362 | #Method int bottom() const |
| 363 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 364 | Returns bottom edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid, |
| 365 | and sort() to reverse fTop and fBottom if needed. |
| 366 | |
| 367 | #Return fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 368 | |
| 369 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 370 | SkIRect unsorted = { 15, 25, 10, 5 };
|
| 371 | SkDebugf("unsorted.fBottom: %d unsorted.bottom(): %d\n", unsorted.fBottom, unsorted.bottom());
|
| 372 | SkIRect sorted = unsorted.makeSorted();
|
| 373 | SkDebugf("sorted.fBottom: %d sorted.bottom(): %d\n", sorted.fBottom, sorted.bottom());
|
| 374 | #StdOut |
| 375 | unsorted.fBottom: 5 unsorted.bottom(): 5
|
| 376 | sorted.fBottom: 25 sorted.bottom(): 25 |
| 377 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 378 | ## |
| 379 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 380 | #SeeAlso fBottom SkRect::bottom() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 381 | |
| 382 | ## |
| 383 | |
| 384 | # ------------------------------------------------------------------------------ |
| 385 | |
| 386 | #Method int x() const |
| 387 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 388 | Returns left edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid, |
| 389 | and sort() to reverse fLeft and fRight if needed. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 390 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 391 | #Return fLeft ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 392 | |
| 393 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 394 | SkIRect unsorted = { 15, 5, 10, 25 };
|
| 395 | SkDebugf("unsorted.fLeft: %d unsorted.x(): %d\n", unsorted.fLeft, unsorted.x());
|
| 396 | SkIRect sorted = unsorted.makeSorted();
|
| 397 | SkDebugf("sorted.fLeft: %d sorted.x(): %d\n", sorted.fLeft, sorted.x());
|
| 398 | #StdOut |
| 399 | unsorted.fLeft: 15 unsorted.x(): 15
|
| 400 | sorted.fLeft: 10 sorted.x(): 10 |
| 401 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 402 | ## |
| 403 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 404 | #SeeAlso fLeft left() y() SkRect::x() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 405 | |
| 406 | ## |
| 407 | |
| 408 | # ------------------------------------------------------------------------------ |
| 409 | |
| 410 | #Method int y() const |
| 411 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 412 | Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid, |
| 413 | and sort() to reverse fTop and fBottom if needed. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 414 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 415 | #Return fTop ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 416 | |
| 417 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 418 | SkIRect unsorted = { 15, 25, 10, 5 };
|
| 419 | SkDebugf("unsorted.fTop: %d unsorted.y(): %d\n", unsorted.fTop, unsorted.y());
|
| 420 | SkIRect sorted = unsorted.makeSorted();
|
| 421 | SkDebugf("sorted.fTop: %d sorted.y(): %d\n", sorted.fTop, sorted.y()); |
| 422 | #StdOut |
| 423 | unsorted.fTop: 25 unsorted.y(): 25
|
| 424 | sorted.fTop: 5 sorted.y(): 5 |
| 425 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 426 | ## |
| 427 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 428 | #SeeAlso fTop top() x() SkRect::y() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 429 | |
| 430 | ## |
| 431 | |
| 432 | # ------------------------------------------------------------------------------ |
| 433 | |
| 434 | #Method int width() const |
| 435 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 436 | Returns span on the x-axis. This does not check if IRect is sorted, or if |
| 437 | result fits in 32-bit signed integer; result may be negative. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 438 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 439 | #Return fRight minus fLeft ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 440 | |
| 441 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 442 | SkIRect unsorted = { 15, 25, 10, 5 };
|
| 443 | SkDebugf("unsorted width: %d\n", unsorted.width());
|
| 444 | SkIRect large = { -2147483647, 1, 2147483644, 2 };
|
| 445 | SkDebugf("large width: %d\n", large.width());
|
| 446 | #StdOut |
| 447 | unsorted width: -5
|
| 448 | large width: -5 |
| 449 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 450 | ## |
| 451 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 452 | #SeeAlso height() SkRect::width() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 453 | |
| 454 | ## |
| 455 | |
| 456 | # ------------------------------------------------------------------------------ |
| 457 | |
| 458 | #Method int height() const |
| 459 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 460 | Returns span on the y-axis. This does not check if IRect is sorted, or if |
| 461 | result fits in 32-bit signed integer; result may be negative. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 462 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 463 | #Return fBottom minus fTop ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 464 | |
| 465 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 466 | SkIRect unsorted = { 15, 25, 10, 20 };
|
| 467 | SkDebugf("unsorted height: %d\n", unsorted.height());
|
| 468 | SkIRect large = { 1, -2147483647, 2, 2147483644 };
|
| 469 | SkDebugf("large height: %d\n", large.height());
|
| 470 | #StdOut |
| 471 | unsorted height: -5
|
| 472 | large height: -5 |
| 473 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 474 | ## |
| 475 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 476 | #SeeAlso width() SkRect::height() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 477 | |
| 478 | ## |
| 479 | |
| 480 | # ------------------------------------------------------------------------------ |
| 481 | |
| 482 | #Method SkISize size() const |
| 483 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 484 | Returns spans on the x-axis and y-axis. This does not check if IRect is sorted, |
| 485 | or if result fits in 32-bit signed integer; result may be negative. |
| 486 | |
| 487 | #Return ISize (width, height) ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 488 | |
| 489 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 490 | auto debugster = [](const char* prefix, const SkIRect& rect) -> void {
|
| 491 | SkISize size = rect.size();
|
| 492 | SkDebugf("%s ", prefix);
|
| 493 | SkDebugf("rect: %d, %d, %d, %d ", rect.left(), rect.top(), rect.right(), rect.bottom());
|
| 494 | SkDebugf("size: %d, %d\n", size.width(), size.height());
|
| 495 | };
|
| 496 | SkIRect rect = {20, 30, 40, 50};
|
| 497 | debugster("original", rect);
|
| 498 | rect.offset(20, 20);
|
| 499 | debugster(" offset", rect);
|
| 500 | rect.outset(20, 20);
|
| 501 | debugster(" outset", rect); |
| 502 | #StdOut |
| 503 | original rect: 20, 30, 40, 50 size: 20, 20
|
| 504 | offset rect: 40, 50, 60, 70 size: 20, 20
|
| 505 | outset rect: 20, 30, 80, 90 size: 60, 60 |
| 506 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 507 | ## |
| 508 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 509 | #SeeAlso height() width() MakeSize |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 510 | |
| 511 | ## |
| 512 | |
| 513 | # ------------------------------------------------------------------------------ |
| 514 | |
| 515 | #Method int centerX() const |
| 516 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 517 | Returns average of left edge and right edge. Result does not change if Rect |
| 518 | is sorted. Result may be incorrect if Rect is far from the origin. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 519 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 520 | Result is rounded down. |
| 521 | |
| 522 | #Return midpoint in x ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 523 | |
| 524 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 525 | #Description |
| 526 | Dividing by two rounds towards zero. centerX uses a bit shift and rounds down. |
| 527 | ## |
| 528 | SkIRect tests[] = {{20, 30, 41, 51}, {-20, -30, -41, -51}, {-10, -10, 11, 11}};
|
| 529 | for (auto rect : tests) {
|
| 530 | SkDebugf("left: %3d right: %3d centerX: %3d ", rect.left(), rect.right(), rect.centerX());
|
| 531 | SkDebugf("div2: %3d\n", (rect.left() + rect.right()) / 2);
|
| 532 | }
|
| 533 | #StdOut |
| 534 | left: 20 right: 41 centerX: 30 div2: 30
|
| 535 | left: -20 right: -41 centerX: -31 div2: -30
|
| 536 | left: -10 right: 11 centerX: 0 div2: 0 |
| 537 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 538 | ## |
| 539 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 540 | #SeeAlso centerY SkRect::centerX |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 541 | |
| 542 | ## |
| 543 | |
| 544 | # ------------------------------------------------------------------------------ |
| 545 | |
| 546 | #Method int centerY() const |
| 547 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 548 | Returns average of top edge and bottom edge. Result does not change if Rect |
| 549 | is sorted. Result may be incorrect if Rect is far from the origin. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 550 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 551 | Result is rounded down. |
| 552 | |
| 553 | #Return midpoint in y ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 554 | |
| 555 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 556 | SkIRect rect = { 0, 0, 2, 2 };
|
| 557 | rect.offset(0x40000000, 0x40000000);
|
| 558 | SkDebugf("left: %d right: %d centerX: %d ", rect.left(), rect.right(), rect.centerX());
|
| 559 | SkDebugf("safe mid x: %d\n", rect.left() / 2 + rect.right() / 2); |
| 560 | #StdOut |
| 561 | left: 1073741824 right: 1073741826 centerX: -1073741823 safe mid x: 1073741825 |
| 562 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 563 | ## |
| 564 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 565 | #SeeAlso centerX SkRect::centerY |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 566 | |
| 567 | ## |
| 568 | |
| 569 | # ------------------------------------------------------------------------------ |
| 570 | |
| 571 | #Method bool isEmpty() const |
| 572 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 573 | Returns true if fLeft is equal to or greater than fRight, or if fTop is equal |
| 574 | to or greater than fBottom. Call sort() to reverse rectangles with negative |
| 575 | width() or height(). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 576 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 577 | #Return true if width() or height() are zero or negative ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 578 | |
| 579 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 580 | SkIRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}};
|
| 581 | for (auto rect : tests) {
|
| 582 | SkDebugf("rect: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
|
| 583 | rect.bottom(), rect.isEmpty() ? "" : " not");
|
| 584 | rect.sort();
|
| 585 | SkDebugf("sorted: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
|
| 586 | rect.bottom(), rect.isEmpty() ? "" : " not");
|
| 587 | } |
| 588 | #StdOut
|
| 589 | rect: {20, 40, 10, 50} is empty
|
| 590 | sorted: {10, 40, 20, 50} is not empty
|
| 591 | rect: {20, 40, 20, 50} is empty
|
| 592 | sorted: {20, 40, 20, 50} is empty
|
| 593 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 594 | ## |
| 595 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 596 | #SeeAlso EmptyIRect MakeEmpty sort SkRect::isEmpty |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 597 | |
| 598 | ## |
| 599 | |
| 600 | # ------------------------------------------------------------------------------ |
| 601 | |
| 602 | #Method bool isLargest() const |
| 603 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 604 | Returns true if IRect encloses largest possible area. |
| 605 | |
| 606 | #Return true if equal to (SK_MinS32, SK_MinS32, SK_MaxS32, SK_MaxS32) ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 607 | |
| 608 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 609 | #Description |
| 610 | Note that the width is not negative, yet it cannot be represented as a 32-bit |
| 611 | signed integer. |
| 612 | ## |
| 613 | SkIRect large = SkIRect::MakeLargest();
|
| 614 | SkDebugf("large is largest: %s\n" ,large.isLargest() ? "true" : "false");
|
| 615 | SkDebugf("large width %d\n", large.width());
|
| 616 | SkDebugf("large is empty: %s\n", large.isEmpty() ? "true" : "false"); |
| 617 | #StdOut
|
| 618 | large is largest: true
|
| 619 | large width -2
|
| 620 | large is empty: false
|
| 621 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 622 | ## |
| 623 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 624 | #SeeAlso MakeLargest SkRect::isLargest |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 625 | |
| 626 | ## |
| 627 | |
| 628 | # ------------------------------------------------------------------------------ |
| 629 | |
| 630 | #Method friend bool operator==(const SkIRect& a, const SkIRect& b) |
| 631 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 632 | Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are |
| 633 | identical to corresponding members in b. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 634 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 635 | #Param a IRect to compare ## |
| 636 | #Param b IRect to compare ## |
| 637 | |
| 638 | #Return true if members are equal ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 639 | |
| 640 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 641 | SkIRect test = {0, 0, 2, 2};
|
| 642 | SkIRect sorted = test.makeSorted();
|
| 643 | SkDebugf("test %c= sorted\n", test == sorted ? '=' : '!'); |
| 644 | #StdOut
|
| 645 | test == sorted
|
| 646 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 647 | ## |
| 648 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 649 | #SeeAlso operator!=(const SkIRect& a, const SkIRect& b) |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 650 | |
| 651 | ## |
| 652 | |
| 653 | # ------------------------------------------------------------------------------ |
| 654 | |
| 655 | #Method friend bool operator!=(const SkIRect& a, const SkIRect& b) |
| 656 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 657 | Returns true if any member in a: fLeft, fTop, fRight, and fBottom; is not |
| 658 | identical to the corresponding member in b. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 659 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 660 | #Param a IRect to compare ## |
| 661 | #Param b IRect to compare ## |
| 662 | |
| 663 | #Return true if members are not equal ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 664 | |
| 665 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 666 | SkIRect test = {2, 2, 0, 0};
|
| 667 | SkIRect sorted = test.makeSorted();
|
| 668 | SkDebugf("test %c= sorted\n", test != sorted ? '!' : '=');
|
| 669 | #StdOut
|
| 670 | test != sorted
|
| 671 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 672 | ## |
| 673 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 674 | #SeeAlso operator==(const SkIRect& a, const SkIRect& b) |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 675 | |
| 676 | ## |
| 677 | |
| 678 | # ------------------------------------------------------------------------------ |
| 679 | |
| 680 | #Method bool is16Bit() const |
| 681 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 682 | Returns true if all members: fLeft, fTop, fRight, and fBottom; values are |
| 683 | equal to or larger than -32768 and equal to or smaller than 32767. |
| 684 | |
| 685 | #Return true if members fit in 16-bit word ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 686 | |
| 687 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 688 | SkIRect tests[] = {{-32768, -32768, 32767, 32767}, {-32768, -32768, 32768, 32768}};
|
| 689 | for (auto rect : tests) {
|
| 690 | SkDebugf("{%d, %d, %d, %d} %s in 16 bits\n", rect.fLeft, rect.fTop, rect.fRight,
|
| 691 | rect.fBottom, rect.is16Bit() ? "fits" : "does not fit");
|
| 692 | }
|
| 693 | #StdOut
|
| 694 | {-32768, -32768, 32767, 32767} fits in 16 bits
|
| 695 | {-32768, -32768, 32768, 32768} does not fit in 16 bits
|
| 696 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 697 | ## |
| 698 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 699 | #SeeAlso SkTFitsIn |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 700 | |
| 701 | ## |
| 702 | |
| 703 | # ------------------------------------------------------------------------------ |
| 704 | |
| 705 | #Method void setEmpty() |
| 706 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 707 | Sets IRect to (0, 0, 0, 0). |
| 708 | |
| 709 | Many other rectangles are empty; if left is equal to or greater than right, |
| 710 | or if top is equal to or greater than bottom. Setting all members to zero |
| 711 | is a convenience, but does not designate a special empty rectangle. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 712 | |
| 713 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 714 | SkIRect rect = {3, 4, 1, 2};
|
| 715 | for (int i = 0; i < 2; ++i) {
|
| 716 | SkDebugf("rect: {%d, %d, %d, %d} is %s" "empty\n", rect.fLeft, rect.fTop,
|
| 717 | rect.fRight, rect.fBottom, rect.isEmpty() ? "" : "not ");
|
| 718 | rect.setEmpty();
|
| 719 | }
|
| 720 | #StdOut
|
| 721 | rect: {3, 4, 1, 2} is empty
|
| 722 | rect: {0, 0, 0, 0} is empty
|
| 723 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 724 | ## |
| 725 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 726 | #SeeAlso MakeEmpty SkRect::setEmpty |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 727 | |
| 728 | ## |
| 729 | |
| 730 | # ------------------------------------------------------------------------------ |
| 731 | |
| 732 | #Method void set(int32_t left, int32_t top, int32_t right, int32_t bottom) |
| 733 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 734 | Sets IRect to (left, top, right, bottom). |
| 735 | left and right are not sorted; left is not necessarily less than right. |
| 736 | top and bottom are not sorted; top is not necessarily less than bottom. |
| 737 | |
| 738 | #Param left assigned to fLeft ## |
| 739 | #Param top assigned to fTop ## |
| 740 | #Param right assigned to fRight ## |
| 741 | #Param bottom assigned to fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 742 | |
| 743 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 744 | SkIRect rect1 = {3, 4, 1, 2};
|
| 745 | SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
|
| 746 | SkIRect rect2;
|
| 747 | rect2.set(3, 4, 1, 2);
|
| 748 | SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
|
| 749 | #StdOut
|
| 750 | rect1: {3, 4, 1, 2}
|
| 751 | rect2: {3, 4, 1, 2}
|
| 752 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 753 | ## |
| 754 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 755 | #SeeAlso setLTRB setXYWH SkRect::set |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 756 | |
| 757 | ## |
| 758 | |
| 759 | # ------------------------------------------------------------------------------ |
| 760 | |
| 761 | #Method void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom) |
| 762 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 763 | Sets IRect to (left, top, right, bottom). |
| 764 | left and right are not sorted; left is not necessarily less than right. |
| 765 | top and bottom are not sorted; top is not necessarily less than bottom. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 766 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 767 | #Param left stored in fLeft ## |
| 768 | #Param top stored in fTop ## |
| 769 | #Param right stored in fRight ## |
| 770 | #Param bottom stored in fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 771 | |
| 772 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 773 | SkIRect rect1 = {3, 4, 1, 2};
|
| 774 | SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
|
| 775 | SkIRect rect2;
|
| 776 | rect2.setLTRB(3, 4, 1, 2);
|
| 777 | SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
|
| 778 | #StdOut
|
| 779 | rect1: {3, 4, 1, 2}
|
| 780 | rect2: {3, 4, 1, 2}
|
| 781 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 782 | ## |
| 783 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 784 | #SeeAlso set setXYWH SkRect::setLTRB |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 785 | |
| 786 | ## |
| 787 | |
| 788 | # ------------------------------------------------------------------------------ |
| 789 | |
| 790 | #Method void setXYWH(int32_t x, int32_t y, int32_t width, int32_t height) |
| 791 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 792 | Sets IRect to |
| 793 | #Formula |
| 794 | (x, y, x + width, y + height) |
| 795 | ## |
| 796 | . Does not validate input; |
| 797 | width or height may be negative. |
| 798 | |
| 799 | #Param x stored in fLeft ## |
| 800 | #Param y stored in fTop ## |
| 801 | #Param width added to x and stored in fRight ## |
| 802 | #Param height added to y and stored in fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 803 | |
| 804 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 805 | SkIRect rect;
|
| 806 | rect.setXYWH(5, 35, -15, 25);
|
| 807 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
|
| 808 | rect.bottom(), rect.isEmpty() ? "true" : "false");
|
| 809 | rect.sort();
|
| 810 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
|
| 811 | rect.bottom(), rect.isEmpty() ? "true" : "false");
|
| 812 | #StdOut |
| 813 | rect: 5, 35, -10, 60 isEmpty: true
|
| 814 | rect: -10, 35, 5, 60 isEmpty: false |
| 815 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 816 | ## |
| 817 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 818 | #SeeAlso MakeXYWH setLTRB set SkRect::setXYWH |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 819 | |
| 820 | ## |
| 821 | |
| 822 | # ------------------------------------------------------------------------------ |
| 823 | |
| 824 | #Method void setLargest() |
| 825 | |
| 826 | Sets rectangle left and top to most negative value, and sets |
| 827 | right and bottom to most positive value. |
| 828 | |
| 829 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 830 | SkIRect rect;
|
| 831 | rect.setLargest();
|
| 832 | SkDebugf("MakeLargest isLargest: %s\n", rect.isLargest() ? "true" : "false");
|
| 833 | SkDebugf("MakeLargest isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
|
| 834 | rect.outset(1, 1);
|
| 835 | SkDebugf("outset isLargest: %s\n", rect.isLargest() ? "true" : "false");
|
| 836 | SkDebugf("outset isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
|
| 837 | #StdOut
|
| 838 | MakeLargest isLargest: true
|
| 839 | MakeLargest isEmpty: false
|
| 840 | outset isLargest: false
|
| 841 | outset isEmpty: true
|
| 842 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 843 | ## |
| 844 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 845 | #SeeAlso MakeLargest isLargest setLargestInverted SK_MinS32 SK_MaxS32 |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 846 | |
| 847 | ## |
| 848 | |
| 849 | # ------------------------------------------------------------------------------ |
| 850 | |
| 851 | #Method void setLargestInverted() |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 852 | #ToDo move this to private |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 853 | ## |
| 854 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 855 | Sets rectangle left and top to most positive value, and sets |
| 856 | right and bottom to most negative value. This is used internally to |
| 857 | flag that a condition is met, but otherwise has no special purpose. |
| 858 | |
| 859 | #NoExample |
| 860 | ## |
| 861 | |
| 862 | #SeeAlso setEmpty setLargest |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 863 | |
| 864 | ## |
| 865 | |
| 866 | # ------------------------------------------------------------------------------ |
| 867 | |
| 868 | #Method SkIRect makeOffset(int32_t dx, int32_t dy) const |
| 869 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 870 | Returns IRect offset by (dx, dy). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 871 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 872 | If dx is negative, IRect returned is moved to the left. |
| 873 | If dx is positive, IRect returned is moved to the right. |
| 874 | If dy is negative, IRect returned is moved upward. |
| 875 | If dy is positive, IRect returned is moved downward. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 876 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 877 | #Param dx offset added to fLeft and fRight ## |
| 878 | #Param dy offset added to fTop and fBottom ## |
| 879 | |
| 880 | #Return Rect offset in x or y, with original width and height ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 881 | |
| 882 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 883 | SkIRect rect = { 10, 50, 20, 60 };
|
| 884 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
|
| 885 | rect.bottom(), rect.isEmpty() ? "true" : "false");
|
| 886 | rect = rect.makeOffset(15, 32);
|
| 887 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
|
| 888 | rect.bottom(), rect.isEmpty() ? "true" : "false");
|
| 889 | #StdOut
|
| 890 | rect: 10, 50, 20, 60 isEmpty: false
|
| 891 | rect: 25, 82, 35, 92 isEmpty: false
|
| 892 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 893 | ## |
| 894 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 895 | #SeeAlso offset() makeInset makeOutset SkRect::makeOffset |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 896 | |
| 897 | ## |
| 898 | |
| 899 | # ------------------------------------------------------------------------------ |
| 900 | |
| 901 | #Method SkIRect makeInset(int32_t dx, int32_t dy) const |
| 902 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 903 | Returns IRect, inset by (dx, dy). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 904 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 905 | If dx is negative, IRect returned is wider. |
| 906 | If dx is positive, IRect returned is narrower. |
| 907 | If dy is negative, IRect returned is taller. |
| 908 | If dy is positive, IRect returned is shorter. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 909 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 910 | #Param dx offset added to fLeft and subtracted from fRight ## |
| 911 | #Param dy offset added to fTop and subtracted from fBottom ## |
| 912 | |
| 913 | #Return Rect inset symmetrically left and right, top and bottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 914 | |
| 915 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 916 | SkIRect rect = { 10, 50, 20, 60 };
|
| 917 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
|
| 918 | rect.bottom(), rect.isEmpty() ? "true" : "false");
|
| 919 | rect = rect.makeInset(15, 32);
|
| 920 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
|
| 921 | rect.bottom(), rect.isEmpty() ? "true" : "false");
|
| 922 | #StdOut
|
| 923 | rect: 10, 50, 20, 60 isEmpty: false
|
| 924 | rect: 25, 82, 5, 28 isEmpty: true
|
| 925 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 926 | ## |
| 927 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 928 | #SeeAlso inset() makeOffset makeOutset SkRect::makeInset |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 929 | |
| 930 | ## |
| 931 | |
| 932 | # ------------------------------------------------------------------------------ |
| 933 | |
| 934 | #Method SkIRect makeOutset(int32_t dx, int32_t dy) const |
| 935 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 936 | Returns IRect, outset by (dx, dy). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 937 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 938 | If dx is negative, IRect returned is narrower. |
| 939 | If dx is positive, IRect returned is wider. |
| 940 | If dy is negative, IRect returned is shorter. |
| 941 | If dy is positive, IRect returned is taller. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 942 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 943 | #Param dx offset subtracted to fLeft and added from fRight ## |
| 944 | #Param dy offset subtracted to fTop and added from fBottom ## |
| 945 | |
| 946 | #Return Rect outset symmetrically left and right, top and bottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 947 | |
| 948 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 949 | SkIRect rect = { 10, 50, 20, 60 };
|
| 950 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
|
| 951 | rect.bottom(), rect.isEmpty() ? "true" : "false");
|
| 952 | rect = rect.makeOutset(15, 32);
|
| 953 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
|
| 954 | rect.bottom(), rect.isEmpty() ? "true" : "false");
|
| 955 | #StdOut
|
| 956 | rect: 10, 50, 20, 60 isEmpty: false
|
| 957 | rect: -5, 18, 35, 92 isEmpty: false
|
| 958 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 959 | ## |
| 960 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 961 | #SeeAlso outset() makeOffset makeInset SkRect::makeOutset |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 962 | |
| 963 | ## |
| 964 | |
| 965 | # ------------------------------------------------------------------------------ |
| 966 | |
| 967 | #Method void offset(int32_t dx, int32_t dy) |
| 968 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 969 | Offsets IRect by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 970 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 971 | If dx is negative, moves IRect returned to the left. |
| 972 | If dx is positive, moves IRect returned to the right. |
| 973 | If dy is negative, moves IRect returned upward. |
| 974 | If dy is positive, moves IRect returned downward. |
| 975 | |
| 976 | #Param dx offset added to fLeft and fRight ## |
| 977 | #Param dy offset added to fTop and fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 978 | |
| 979 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 980 | SkIRect rect = { 10, 14, 50, 73 };
|
| 981 | rect.offset(5, 13);
|
| 982 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
|
| 983 | #StdOut
|
| 984 | rect: 15, 27, 55, 86
|
| 985 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 986 | ## |
| 987 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 988 | #SeeAlso offsetTo makeOffset SkRect::offset |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 989 | |
| 990 | ## |
| 991 | |
| 992 | # ------------------------------------------------------------------------------ |
| 993 | |
| 994 | #Method void offset(const SkIPoint& delta) |
| 995 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 996 | Offsets IRect by adding delta.fX to fLeft, fRight; and by adding delta.fY to |
| 997 | fTop, fBottom. |
| 998 | |
| 999 | If delta.fX is negative, moves IRect returned to the left. |
| 1000 | If delta.fX is positive, moves IRect returned to the right. |
| 1001 | If delta.fY is negative, moves IRect returned upward. |
| 1002 | If delta.fY is positive, moves IRect returned downward. |
| 1003 | |
| 1004 | #Param delta offset added to IRect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1005 | |
| 1006 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1007 | SkIRect rect = { 10, 14, 50, 73 };
|
| 1008 | rect.offset({5, 13});
|
| 1009 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
|
| 1010 | #StdOut
|
| 1011 | rect: 15, 27, 55, 86
|
| 1012 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1013 | ## |
| 1014 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1015 | #SeeAlso offsetTo makeOffset SkRect::offset |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1016 | |
| 1017 | ## |
| 1018 | |
| 1019 | # ------------------------------------------------------------------------------ |
| 1020 | |
| 1021 | #Method void offsetTo(int32_t newX, int32_t newY) |
| 1022 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1023 | Offsets IRect so that fLeft equals newX, and fTop equals newY. width and height |
| 1024 | are unchanged. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1025 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1026 | #Param newX stored in fLeft, preserving width() ## |
| 1027 | #Param newY stored in fTop, preserving height() ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1028 | |
| 1029 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1030 | SkIRect rect = { 10, 14, 50, 73 };
|
| 1031 | rect.offsetTo(15, 27);
|
| 1032 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
|
| 1033 | #StdOut
|
| 1034 | rect: 15, 27, 55, 86
|
| 1035 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1036 | ## |
| 1037 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1038 | #SeeAlso offset makeOffset setXYWH SkRect::offsetTo |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1039 | |
| 1040 | ## |
| 1041 | |
| 1042 | # ------------------------------------------------------------------------------ |
| 1043 | |
| 1044 | #Method void inset(int32_t dx, int32_t dy) |
| 1045 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1046 | Insets IRect by (dx,dy). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1047 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1048 | If dx is positive, makes IRect narrower. |
| 1049 | If dx is negative, makes IRect wider. |
| 1050 | If dy is positive, makes IRect shorter. |
| 1051 | If dy is negative, makes IRect taller. |
| 1052 | |
| 1053 | #Param dx offset added to fLeft and subtracted from fRight ## |
| 1054 | #Param dy offset added to fTop and subtracted from fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1055 | |
| 1056 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1057 | SkIRect rect = { 10, 14, 50, 73 };
|
| 1058 | rect.inset(5, 13);
|
| 1059 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
|
| 1060 | #StdOut
|
| 1061 | rect: 15, 27, 45, 60
|
| 1062 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1063 | ## |
| 1064 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1065 | #SeeAlso outset makeInset SkRect::inset |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1066 | |
| 1067 | ## |
| 1068 | |
| 1069 | # ------------------------------------------------------------------------------ |
| 1070 | |
| 1071 | #Method void outset(int32_t dx, int32_t dy) |
| 1072 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1073 | Outsets IRect by (dx, dy). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1074 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1075 | If dx is positive, makes Rect wider. |
| 1076 | If dx is negative, makes Rect narrower. |
| 1077 | If dy is positive, makes Rect taller. |
| 1078 | If dy is negative, makes Rect shorter. |
| 1079 | |
| 1080 | #Param dx subtracted to fLeft and added from fRight ## |
| 1081 | #Param dy subtracted to fTop and added from fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1082 | |
| 1083 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1084 | SkIRect rect = { 10, 14, 50, 73 };
|
| 1085 | rect.outset(5, 13);
|
| 1086 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
|
| 1087 | #StdOut
|
| 1088 | rect: 5, 1, 55, 86
|
| 1089 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1090 | ## |
| 1091 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1092 | #SeeAlso inset makeOutset SkRect::outset |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1093 | |
| 1094 | ## |
| 1095 | |
| 1096 | # ------------------------------------------------------------------------------ |
| 1097 | |
| 1098 | #Method bool quickReject(int l, int t, int r, int b) const |
| 1099 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1100 | Constructs IRect (l, t, r, b) and returns true if constructed IRect does not |
| 1101 | intersect IRect. Does not check to see if construction or IRect is empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1102 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1103 | Is implemented with short circuit logic so that true can be returned after |
| 1104 | a single compare. |
| 1105 | |
| 1106 | #Param l x minimum of constructed Rect ## |
| 1107 | #Param t y minimum of constructed Rect ## |
| 1108 | #Param r x maximum of constructed Rect ## |
| 1109 | #Param b y maximum of constructed Rect ## |
| 1110 | |
| 1111 | #Return true if construction and IRect have no area in common ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1112 | |
| 1113 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1114 | #Description |
| 1115 | quickReject is the complement of Intersects. |
| 1116 | ## |
| 1117 | const SkIRect rect = {7, 11, 13, 17};
|
| 1118 | const int32_t* r = &rect.fLeft;
|
| 1119 | const SkIRect tests[] = { {13, 11, 15, 17}, { 7, 7, 13, 11 }, { 12, 16, 14, 18 } };
|
| 1120 | for (auto& test : tests) {
|
| 1121 | const int32_t* t = &test.fLeft;
|
| 1122 | SkDebugf("rect (%d, %d, %d, %d) test(%d, %d, %d, %d) quickReject %s; intersects %s\n",
|
| 1123 | r[0], r[1], r[2], r[3], t[0], t[1], t[2], t[3],
|
| 1124 | rect.quickReject(t[0], t[1], t[2], t[3]) ? "true" : "false",
|
| 1125 | SkIRect::Intersects(rect, test) ? "true" : "false");
|
| 1126 | }
|
| 1127 | #StdOut
|
| 1128 | rect (7, 11, 13, 17) test(13, 11, 15, 17) quickReject true; intersects false
|
| 1129 | rect (7, 11, 13, 17) test(7, 7, 13, 11) quickReject true; intersects false
|
| 1130 | rect (7, 11, 13, 17) test(12, 16, 14, 18) quickReject false; intersects true
|
| 1131 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1132 | ## |
| 1133 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1134 | #SeeAlso Intersects |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1135 | |
| 1136 | ## |
| 1137 | |
| 1138 | # ------------------------------------------------------------------------------ |
| 1139 | |
| 1140 | #Method bool contains(int32_t x, int32_t y) const |
| 1141 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1142 | Returns true if |
| 1143 | #Formula |
| 1144 | fLeft <= x < fRight && fTop <= y < fBottom |
| 1145 | ## |
| 1146 | . |
| 1147 | Returns false if Rect is empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1148 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1149 | Considers input to describe constructed IRect (x, y, x + 1, y + 1) and |
| 1150 | returns true if constructed area is completely enclosed by IRect area. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1151 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1152 | #Param x test Point x-coordinate ## |
| 1153 | #Param y test Point y-coordinate ## |
| 1154 | |
| 1155 | #Return true if (x, y) is inside IRect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1156 | |
| 1157 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1158 | SkIRect rect = { 30, 50, 40, 60 };
|
| 1159 | SkIPoint pts[] = { { 30, 50}, { 40, 50}, { 30, 60} };
|
| 1160 | for (auto pt : pts) {
|
| 1161 | SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d)\n",
|
| 1162 | rect.left(), rect.top(), rect.right(), rect.bottom(),
|
| 1163 | rect.contains(pt.x(), pt.y()) ? "contains" : "does not contain", pt.x(), pt.y());
|
| 1164 | }
|
| 1165 | #StdOut
|
| 1166 | rect: (30, 50, 40, 60) contains (30, 50)
|
| 1167 | rect: (30, 50, 40, 60) does not contain (40, 50)
|
| 1168 | rect: (30, 50, 40, 60) does not contain (30, 60)
|
| 1169 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1170 | ## |
| 1171 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1172 | #SeeAlso containsNoEmptyCheck SkRect::contains |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1173 | |
| 1174 | ## |
| 1175 | |
| 1176 | # ------------------------------------------------------------------------------ |
| 1177 | |
| 1178 | #Method bool contains(int32_t left, int32_t top, int32_t right, int32_t bottom) const |
| 1179 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1180 | Constructs Rect to intersect from (left, top, right, bottom). Does not sort |
| 1181 | construction. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1182 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1183 | Returns true if Rect contains construction. |
| 1184 | Returns false if Rect is empty or construction is empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1185 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1186 | #Param left x minimum of constructed Rect ## |
| 1187 | #Param top y minimum of constructed Rect ## |
| 1188 | #Param right x maximum of constructed Rect ## |
| 1189 | #Param bottom y maximum of constructed Rect ## |
| 1190 | |
| 1191 | #Return true if all sides of IRect are outside construction ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1192 | |
| 1193 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1194 | SkIRect rect = { 30, 50, 40, 60 };
|
| 1195 | SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
|
| 1196 | for (auto contained : tests) {
|
| 1197 | bool success = rect.contains(
|
| 1198 | contained.left(), contained.top(), contained.right(), contained.bottom());
|
| 1199 | SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
|
| 1200 | rect.left(), rect.top(), rect.right(), rect.bottom(),
|
| 1201 | success ? "contains" : "does not contain",
|
| 1202 | contained.left(), contained.top(), contained.right(), contained.bottom());
|
| 1203 | }
|
| 1204 | #StdOut
|
| 1205 | rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
|
| 1206 | rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
|
| 1207 | rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
|
| 1208 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1209 | ## |
| 1210 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1211 | #SeeAlso containsNoEmptyCheck SkRect::contains |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1212 | |
| 1213 | ## |
| 1214 | |
| 1215 | # ------------------------------------------------------------------------------ |
| 1216 | |
| 1217 | #Method bool contains(const SkIRect& r) const |
| 1218 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1219 | Returns true if Rect contains r. |
| 1220 | Returns false if Rect is empty or r is empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1221 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1222 | Rect contains r when Rect area completely includes r area. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1223 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1224 | #Param r IRect contained ## |
| 1225 | |
| 1226 | #Return true if all sides of IRect are outside r ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1227 | |
| 1228 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1229 | SkIRect rect = { 30, 50, 40, 60 };
|
| 1230 | SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
|
| 1231 | for (auto contained : tests) {
|
| 1232 | SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
|
| 1233 | rect.left(), rect.top(), rect.right(), rect.bottom(),
|
| 1234 | rect.contains(contained) ? "contains" : "does not contain",
|
| 1235 | contained.left(), contained.top(), contained.right(), contained.bottom());
|
| 1236 | }
|
| 1237 | #StdOut
|
| 1238 | rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
|
| 1239 | rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
|
| 1240 | rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
|
| 1241 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1242 | ## |
| 1243 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1244 | #SeeAlso containsNoEmptyCheck SkRect::contains |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1245 | |
| 1246 | ## |
| 1247 | |
| 1248 | # ------------------------------------------------------------------------------ |
| 1249 | |
| 1250 | #Method bool contains(const SkRect& r) const |
| 1251 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1252 | Returns true if Rect contains r. |
| 1253 | Returns false if Rect is empty or r is empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1254 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1255 | Rect contains r when Rect area completely includes r area. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1256 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1257 | #Param r Rect contained ## |
| 1258 | |
| 1259 | #Return true if all sides of IRect are outside r ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1260 | |
| 1261 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1262 | SkIRect rect = { 30, 50, 40, 60 };
|
| 1263 | SkRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
|
| 1264 | for (auto contained : tests) {
|
| 1265 | SkDebugf("rect: (%d, %d, %d, %d) %s (%g, %g, %g, %g)\n",
|
| 1266 | rect.left(), rect.top(), rect.right(), rect.bottom(),
|
| 1267 | rect.contains(contained) ? "contains" : "does not contain",
|
| 1268 | contained.left(), contained.top(), contained.right(), contained.bottom());
|
| 1269 | }
|
| 1270 | #StdOut
|
| 1271 | rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
|
| 1272 | rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
|
| 1273 | rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
|
| 1274 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1275 | ## |
| 1276 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1277 | #SeeAlso containsNoEmptyCheck SkRect::contains |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1278 | |
| 1279 | ## |
| 1280 | |
| 1281 | # ------------------------------------------------------------------------------ |
| 1282 | |
| 1283 | #Method bool containsNoEmptyCheck(int32_t left, int32_t top, |
| 1284 | int32_t right, int32_t bottom) const |
| 1285 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1286 | Constructs IRect from (left, top, right, bottom). Does not sort |
| 1287 | construction. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1288 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1289 | Returns true if Rect contains construction. |
| 1290 | Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1291 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1292 | Return is undefined if Rect is empty or construction is empty. |
| 1293 | |
| 1294 | #Param left x minimum of constructed Rect ## |
| 1295 | #Param top y minimum of constructed Rect ## |
| 1296 | #Param right x maximum of constructed Rect ## |
| 1297 | #Param bottom y maximum of constructed Rect ## |
| 1298 | |
| 1299 | #Return true if all sides of IRect are outside construction ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1300 | |
| 1301 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1302 | SkIRect rect = { 30, 50, 40, 60 };
|
| 1303 | SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
|
| 1304 | for (auto contained : tests) {
|
| 1305 | bool success = rect.containsNoEmptyCheck(
|
| 1306 | contained.left(), contained.top(), contained.right(), contained.bottom());
|
| 1307 | SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
|
| 1308 | rect.left(), rect.top(), rect.right(), rect.bottom(),
|
| 1309 | success ? "contains" : "does not contain",
|
| 1310 | contained.left(), contained.top(), contained.right(), contained.bottom());
|
| 1311 | }
|
| 1312 | #StdOut
|
| 1313 | rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
|
| 1314 | rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
|
| 1315 | rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
|
| 1316 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1317 | ## |
| 1318 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1319 | #SeeAlso contains SkRect::contains |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1320 | |
| 1321 | ## |
| 1322 | |
| 1323 | # ------------------------------------------------------------------------------ |
| 1324 | |
| 1325 | #Method bool containsNoEmptyCheck(const SkIRect& r) const |
| 1326 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1327 | Returns true if Rect contains construction. |
| 1328 | Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1329 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1330 | Return is undefined if Rect is empty or construction is empty. |
| 1331 | |
| 1332 | #Param r Rect contained ## |
| 1333 | |
| 1334 | #Return true if all sides of IRect are outside r ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1335 | |
| 1336 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1337 | SkIRect rect = { 30, 50, 40, 60 };
|
| 1338 | SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
|
| 1339 | for (auto contained : tests) {
|
| 1340 | SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
|
| 1341 | rect.left(), rect.top(), rect.right(), rect.bottom(),
|
| 1342 | rect.containsNoEmptyCheck(contained) ? "contains" : "does not contain",
|
| 1343 | contained.left(), contained.top(), contained.right(), contained.bottom());
|
| 1344 | }
|
| 1345 | #StdOut
|
| 1346 | rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
|
| 1347 | rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
|
| 1348 | rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
|
| 1349 | ##
|
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1350 | ## |
| 1351 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1352 | #SeeAlso contains SkRect::contains |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1353 | |
| 1354 | ## |
| 1355 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1356 | #Topic Intersection |
| 1357 | |
| 1358 | IRects intersect when they enclose a common area. To intersect, each of the pair |
| 1359 | must describe area; fLeft is less than fRight, and fTop is less than fBottom; |
| 1360 | empty() returns false. The intersection of IRect a and IRect b can be described by: |
| 1361 | #Formula |
| 1362 | (max(a.fLeft, b.fLeft), max(a.fTop, b.fTop), |
| 1363 | min(a.fRight, b.fRight), min(a.fBottom, b.fBottom)) |
| 1364 | ## |
| 1365 | The intersection is only meaningful if the resulting IRect is not empty and |
| 1366 | describes an area: fLeft is less than fRight, and fTop is less than fBottom. |
| 1367 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1368 | # ------------------------------------------------------------------------------ |
| 1369 | |
| 1370 | #Method bool intersect(const SkIRect& r) |
| 1371 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1372 | Returns true if IRect intersects r, and sets IRect to intersection. |
| 1373 | Returns false if IRect does not intersect r, and leaves IRect unchanged. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1374 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1375 | Returns false if either r or IRect is empty, leaving IRect unchanged. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1376 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1377 | #Param r limit of result ## |
| 1378 | |
| 1379 | #Return true if r and Rect have area in common ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1380 | |
| 1381 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1382 | #Description |
| 1383 | Two SkDebugf calls are required. If the calls are combined, their arguments |
| 1384 | may not be evaluated in left to right order: the printed intersection may |
| 1385 | be before or after the call to intersect. |
| 1386 | ## |
| 1387 | SkIRect leftRect = { 10, 40, 50, 80 };
|
| 1388 | SkIRect rightRect = { 30, 60, 70, 90 };
|
| 1389 | SkDebugf("%s intersection: ", leftRect.intersect(rightRect) ? "" : "no ");
|
| 1390 | SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
|
| 1391 | leftRect.right(), leftRect.bottom()); |
| 1392 | #StdOut |
| 1393 | intersection: 30, 60, 50, 80 |
| 1394 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1395 | ## |
| 1396 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1397 | #SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1398 | |
| 1399 | ## |
| 1400 | |
| 1401 | # ------------------------------------------------------------------------------ |
| 1402 | |
| 1403 | #Method bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& a, const SkIRect& b) |
| 1404 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1405 | Returns true if a intersects b, and sets IRect to intersection. |
| 1406 | Returns false if a does not intersect b, and leaves IRect unchanged. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1407 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1408 | Returns false if either a or b is empty, leaving IRect unchanged. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1409 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1410 | #Param a IRect to intersect ## |
| 1411 | #Param b IRect to intersect ## |
| 1412 | |
| 1413 | #Return true if a and b have area in common ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1414 | |
| 1415 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1416 | SkIRect result;
|
| 1417 | bool intersected = result.intersect({ 10, 40, 50, 80 }, { 30, 60, 70, 90 });
|
| 1418 | SkDebugf("%s intersection: %d, %d, %d, %d\n", intersected ? "" : "no ",
|
| 1419 | result.left(), result.top(), result.right(), result.bottom());
|
| 1420 | #StdOut |
| 1421 | intersection: 30, 60, 50, 80 |
| 1422 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1423 | ## |
| 1424 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1425 | #SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1426 | |
| 1427 | ## |
| 1428 | |
| 1429 | # ------------------------------------------------------------------------------ |
| 1430 | |
| 1431 | #Method bool SK_WARN_UNUSED_RESULT intersectNoEmptyCheck(const SkIRect& a, const SkIRect& b) |
| 1432 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1433 | Returns true if a intersects b, and sets IRect to intersection. |
| 1434 | Returns false if a does not intersect b, and leaves IRect unchanged. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1435 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1436 | Asserts if either a or b is empty, and if SK_DEBUG is defined. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1437 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1438 | #Param a IRect to intersect ## |
| 1439 | #Param b IRect to intersect ## |
| 1440 | |
| 1441 | #Return true if a and b have area in common ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1442 | |
| 1443 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1444 | SkIRect result;
|
| 1445 | bool intersected = result.intersectNoEmptyCheck({ 10, 40, 50, 80 }, { 30, 60, 70, 90 });
|
| 1446 | SkDebugf("intersection: %d, %d, %d, %d\n",
|
| 1447 | result.left(), result.top(), result.right(), result.bottom());
|
| 1448 | #StdOut |
| 1449 | intersection: 30, 60, 50, 80 |
| 1450 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1451 | ## |
| 1452 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1453 | #SeeAlso Intersects intersect join SkRect::intersect |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1454 | |
| 1455 | ## |
| 1456 | |
| 1457 | # ------------------------------------------------------------------------------ |
| 1458 | |
| 1459 | #Method bool intersect(int32_t left, int32_t top, int32_t right, int32_t bottom) |
| 1460 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1461 | Constructs IRect to intersect from (left, top, right, bottom). Does not sort |
| 1462 | construction. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1463 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1464 | Returns true if IRect intersects construction, and sets IRect to intersection. |
| 1465 | Returns false if IRect does not intersect construction, and leaves IRect unchanged. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1466 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1467 | Returns false if either construction or IRect is empty, leaving IRect unchanged. |
| 1468 | |
| 1469 | #Param left x minimum of constructed IRect ## |
| 1470 | #Param top y minimum of constructed IRect ## |
| 1471 | #Param right x maximum of constructed IRect ## |
| 1472 | #Param bottom y maximum of constructed IRect ## |
| 1473 | |
| 1474 | #Return true if construction and IRect have area in common ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1475 | |
| 1476 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1477 | #Description |
| 1478 | Two SkDebugf calls are required. If the calls are combined, their arguments |
| 1479 | may not be evaluated in left to right order: the printed intersection may |
| 1480 | be before or after the call to intersect. |
| 1481 | ## |
| 1482 | SkIRect leftRect = { 10, 40, 50, 80 };
|
| 1483 | SkDebugf("%s intersection: ", leftRect.intersect(30, 60, 70, 90) ? "" : "no ");
|
| 1484 | SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
|
| 1485 | leftRect.right(), leftRect.bottom()); |
| 1486 | #StdOut |
| 1487 | intersection: 30, 60, 50, 80 |
| 1488 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1489 | ## |
| 1490 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1491 | #SeeAlso intersectNoEmptyCheck Intersects join SkRect::intersect |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1492 | |
| 1493 | ## |
| 1494 | |
| 1495 | # ------------------------------------------------------------------------------ |
| 1496 | |
| 1497 | #Method static bool Intersects(const SkIRect& a, const SkIRect& b) |
| 1498 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1499 | Returns true if a intersects b. |
| 1500 | Returns false if either a or b is empty, or do not intersect. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1501 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1502 | #Param a IRect to intersect ## |
| 1503 | #Param b IRect to intersect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1504 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1505 | #Return true if a and b have area in common ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1506 | |
| 1507 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1508 | SkDebugf("%s intersection", SkIRect::Intersects({10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
|
| 1509 | #StdOut |
| 1510 | intersection |
| 1511 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1512 | ## |
| 1513 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1514 | #SeeAlso IntersectsNoEmptyCheck intersect SkRect::intersect |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1515 | |
| 1516 | ## |
| 1517 | |
| 1518 | # ------------------------------------------------------------------------------ |
| 1519 | |
| 1520 | #Method static bool IntersectsNoEmptyCheck(const SkIRect& a, const SkIRect& b) |
| 1521 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1522 | Returns true if a intersects b. |
| 1523 | Asserts if either a or b is empty, and if SK_DEBUG is defined. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1524 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1525 | #Param a IRect to intersect ## |
| 1526 | #Param b IRect to intersect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1527 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1528 | #Return true if a and b have area in common ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1529 | |
| 1530 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1531 | SkDebugf("%s intersection", SkIRect::IntersectsNoEmptyCheck(
|
| 1532 | {10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
|
| 1533 | #StdOut |
| 1534 | intersection |
| 1535 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1536 | ## |
| 1537 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1538 | #SeeAlso Intersects intersect SkRect::intersect |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1539 | |
| 1540 | ## |
| 1541 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1542 | #Topic Intersection ## |
| 1543 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1544 | # ------------------------------------------------------------------------------ |
| 1545 | |
| 1546 | #Method void join(int32_t left, int32_t top, int32_t right, int32_t bottom) |
| 1547 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1548 | Constructs Rect to intersect from (left, top, right, bottom). Does not sort |
| 1549 | construction. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1550 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1551 | Sets Rect to the union of itself and the construction. |
| 1552 | |
| 1553 | Has no effect if construction is empty. Otherwise, if Rect is empty, sets |
| 1554 | Rect to construction. |
| 1555 | |
| 1556 | #Param left x minimum of constructed Rect ## |
| 1557 | #Param top y minimum of constructed Rect ## |
| 1558 | #Param right x maximum of constructed Rect ## |
| 1559 | #Param bottom y maximum of constructed Rect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1560 | |
| 1561 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1562 | SkIRect rect = { 10, 20, 15, 25};
|
| 1563 | rect.join(50, 60, 55, 65);
|
| 1564 | SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
|
| 1565 | #StdOut |
| 1566 | join: 10, 20, 55, 65 |
| 1567 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1568 | ## |
| 1569 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1570 | #SeeAlso set SkRect::join |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1571 | |
| 1572 | ## |
| 1573 | |
| 1574 | # ------------------------------------------------------------------------------ |
| 1575 | |
| 1576 | #Method void join(const SkIRect& r) |
| 1577 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1578 | Sets Rect to the union of itself and r. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1579 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1580 | Has no effect if r is empty. Otherwise, if Rect is empty, sets Rect to r. |
| 1581 | |
| 1582 | #Param r expansion Rect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1583 | |
| 1584 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1585 | SkIRect rect = { 10, 20, 15, 25};
|
| 1586 | rect.join({50, 60, 55, 65});
|
| 1587 | SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
|
| 1588 | #StdOut |
| 1589 | join: 10, 20, 55, 65 |
| 1590 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1591 | ## |
| 1592 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1593 | #SeeAlso set SkRect::join |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1594 | |
| 1595 | ## |
| 1596 | |
| 1597 | # ------------------------------------------------------------------------------ |
| 1598 | |
| 1599 | #Method void sort() |
| 1600 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1601 | Swaps fLeft and fRight if fLeft is greater than fRight; and swaps |
| 1602 | fTop and fBottom if fTop is greater than fBottom. Result may be empty, |
| 1603 | and width() and height() will be zero or positive. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1604 | |
| 1605 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1606 | SkIRect rect = { 30, 50, 20, 10 };
|
| 1607 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
|
| 1608 | rect.sort();
|
| 1609 | SkDebugf("sorted: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
|
| 1610 | #StdOut |
| 1611 | rect: 30, 50, 20, 10
|
| 1612 | sorted: 20, 10, 30, 50 |
| 1613 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1614 | ## |
| 1615 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1616 | #SeeAlso makeSorted SkRect::sort |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1617 | |
| 1618 | ## |
| 1619 | |
| 1620 | # ------------------------------------------------------------------------------ |
| 1621 | |
| 1622 | #Method SkIRect makeSorted() const |
| 1623 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1624 | Returns Rect with fLeft and fRight swapped if fLeft is greater than fRight; and |
| 1625 | with fTop and fBottom swapped if fTop is greater than fBottom. Result may be empty; |
| 1626 | and width() and height() will be zero or positive. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1627 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1628 | #Return sorted IRect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1629 | |
| 1630 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1631 | SkIRect rect = { 30, 50, 20, 10 };
|
| 1632 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
|
| 1633 | SkIRect sort = rect.makeSorted();
|
| 1634 | SkDebugf("sorted: %d, %d, %d, %d\n", sort.fLeft, sort.fTop, sort.fRight, sort.fBottom);
|
| 1635 | #StdOut |
| 1636 | rect: 30, 50, 20, 10
|
| 1637 | sorted: 20, 10, 30, 50 |
| 1638 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1639 | ## |
| 1640 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1641 | #SeeAlso sort SkRect::makeSorted |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1642 | |
| 1643 | ## |
| 1644 | |
| 1645 | # ------------------------------------------------------------------------------ |
| 1646 | |
| 1647 | #Method static const SkIRect& SK_WARN_UNUSED_RESULT EmptyIRect() |
| 1648 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1649 | Returns a reference to immutable empty IRect, set to (0, 0, 0, 0). |
| 1650 | |
| 1651 | #Return global IRect set to all zeroes ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1652 | |
| 1653 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1654 | const SkIRect& rect = SkIRect::EmptyIRect();
|
| 1655 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
|
| 1656 | #StdOut |
| 1657 | rect: 0, 0, 0, 0 |
| 1658 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1659 | ## |
| 1660 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame^] | 1661 | #SeeAlso MakeEmpty |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1662 | |
| 1663 | ## |
| 1664 | |
| 1665 | #Struct SkIRect ## |
| 1666 | |
| 1667 | #Topic IRect ## |