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