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