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