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