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 | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 17 | #Member int32_t fLeft |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 18 | #Line # smaller x-axis bounds ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 19 | May contain any value. The smaller of the horizontal values when sorted. |
| 20 | When equal to or greater than fRight, IRect is empty. |
| 21 | ## |
| 22 | |
| 23 | #Member int32_t fTop |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 24 | #Line # smaller y-axis bounds ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 25 | May contain any value. The smaller of the horizontal values when sorted. |
| 26 | When equal to or greater than fBottom, IRect is empty. |
| 27 | ## |
| 28 | |
| 29 | #Member int32_t fRight |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 30 | #Line # larger x-axis bounds ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 31 | May contain any value. The larger of the vertical values when sorted. |
| 32 | When equal to or less than fLeft, IRect is empty. |
| 33 | ## |
| 34 | |
| 35 | #Member int32_t fBottom |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 36 | #Line # larger y-axis bounds ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 37 | May contain any value. The larger of the vertical values when sorted. |
| 38 | When equal to or less than fTop, IRect is empty. |
| 39 | ## |
| 40 | |
| 41 | # ------------------------------------------------------------------------------ |
| 42 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 43 | #Method static constexpr SkIRect MakeEmpty() |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 44 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 45 | #In Constructors |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 46 | #Line # returns bounds of (0, 0, 0, 0) ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 47 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 48 | |
| 49 | #Example |
| 50 | SkIRect rect = SkIRect::MakeEmpty(); |
| 51 | SkDebugf("MakeEmpty isEmpty: %s\n", rect.isEmpty() ? "true" : "false"); |
| 52 | rect.offset(10, 10); |
| 53 | SkDebugf("offset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false"); |
| 54 | rect.inset(10, 10); |
| 55 | SkDebugf("inset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false"); |
| 56 | rect.outset(20, 20); |
| 57 | SkDebugf("outset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false"); |
| 58 | #StdOut |
| 59 | MakeEmpty isEmpty: true |
| 60 | offset rect isEmpty: true |
| 61 | inset rect isEmpty: true |
| 62 | outset rect isEmpty: false |
| 63 | ## |
| 64 | ## |
| 65 | |
Mike Reed | 274218e | 2018-01-08 15:05:02 -0500 | [diff] [blame] | 66 | #SeeAlso EmptyIRect isEmpty setEmpty SkRect::MakeEmpty |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 67 | |
| 68 | ## |
| 69 | |
| 70 | # ------------------------------------------------------------------------------ |
| 71 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 72 | #Method static constexpr SkIRect MakeWH(int32_t w, int32_t h) |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 73 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 74 | #In Constructors |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 75 | #Line # constructs from int input returning (0, 0, width, height) ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 76 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 77 | |
| 78 | #Example |
| 79 | SkIRect rect1 = SkIRect::MakeWH(25, 35); |
| 80 | SkIRect rect2 = SkIRect::MakeSize({25, 35}); |
| 81 | SkIRect rect3 = SkIRect::MakeXYWH(0, 0, 25, 35); |
| 82 | SkIRect rect4 = SkIRect::MakeLTRB(0, 0, 25, 35); |
| 83 | SkDebugf("all %s" "equal\n", rect1 == rect2 && rect2 == rect3 && rect3 == rect4 ? |
| 84 | "" : "not "); |
| 85 | #StdOut |
| 86 | all equal |
| 87 | ## |
| 88 | ## |
| 89 | |
| 90 | #SeeAlso MakeSize MakeXYWH SkRect::MakeWH SkRect::MakeIWH |
| 91 | |
| 92 | ## |
| 93 | |
| 94 | # ------------------------------------------------------------------------------ |
| 95 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 96 | #Method static constexpr SkIRect MakeSize(const SkISize& size) |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 97 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 98 | #In Constructors |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 99 | #Line # constructs from ISize returning (0, 0, width, height) ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 100 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 101 | |
| 102 | #Example |
| 103 | SkSize size = {25.5f, 35.5f}; |
| 104 | SkIRect rect = SkIRect::MakeSize(size.toRound()); |
| 105 | SkDebugf("round width: %d height: %d\n", rect.width(), rect.height()); |
| 106 | rect = SkIRect::MakeSize(size.toFloor()); |
| 107 | SkDebugf("floor width: %d height: %d\n", rect.width(), rect.height()); |
| 108 | #StdOut |
| 109 | round width: 26 height: 36 |
| 110 | floor width: 25 height: 35 |
| 111 | ## |
| 112 | ## |
| 113 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 114 | #SeeAlso MakeWH MakeXYWH SkRect::Make SkRect::MakeIWH |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 115 | |
| 116 | ## |
| 117 | |
| 118 | # ------------------------------------------------------------------------------ |
| 119 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 120 | #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] | 121 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 122 | #In Constructors |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 123 | #Line # constructs from int left, top, right, bottom ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 124 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 125 | |
| 126 | #Example |
| 127 | SkIRect rect = SkIRect::MakeLTRB(5, 35, 15, 25); |
| 128 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 129 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 130 | rect.sort(); |
| 131 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 132 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 133 | #StdOut |
| 134 | rect: 5, 35, 15, 25 isEmpty: true |
| 135 | rect: 5, 25, 15, 35 isEmpty: false |
| 136 | ## |
| 137 | ## |
| 138 | |
| 139 | #SeeAlso MakeXYWH SkRect::MakeLTRB |
| 140 | |
| 141 | ## |
| 142 | |
| 143 | # ------------------------------------------------------------------------------ |
| 144 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 145 | #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] | 146 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 147 | #In Constructors |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 148 | #Line # constructs from int input returning (x, y, width, height) ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 149 | |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 150 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 151 | |
| 152 | #Example |
| 153 | SkIRect rect = SkIRect::MakeXYWH(5, 35, -15, 25); |
| 154 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 155 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 156 | rect.sort(); |
| 157 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 158 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 159 | #StdOut |
| 160 | rect: 5, 35, -10, 60 isEmpty: true |
| 161 | rect: -10, 35, 5, 60 isEmpty: false |
| 162 | ## |
| 163 | ## |
| 164 | |
| 165 | #SeeAlso MakeLTRB SkRect::MakeXYWH |
| 166 | |
| 167 | ## |
| 168 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 169 | #Subtopic Property |
| 170 | #Line # member values, center, validity ## |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 171 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 172 | |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 173 | # ------------------------------------------------------------------------------ |
| 174 | |
Cary Clark | 6def720 | 2018-01-04 08:13:35 -0500 | [diff] [blame] | 175 | #Method int32_t left() const |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 176 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 177 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 178 | #Line # returns smaller bounds in x, if sorted ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 179 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 180 | |
| 181 | #Example |
| 182 | SkIRect unsorted = { 15, 5, 10, 25 }; |
| 183 | SkDebugf("unsorted.fLeft: %d unsorted.left(): %d\n", unsorted.fLeft, unsorted.left()); |
| 184 | SkIRect sorted = unsorted.makeSorted(); |
| 185 | SkDebugf("sorted.fLeft: %d sorted.left(): %d\n", sorted.fLeft, sorted.left()); |
| 186 | #StdOut |
| 187 | unsorted.fLeft: 15 unsorted.left(): 15 |
| 188 | sorted.fLeft: 10 sorted.left(): 10 |
| 189 | ## |
| 190 | ## |
| 191 | |
| 192 | #SeeAlso fLeft x() SkRect::left() |
| 193 | |
| 194 | ## |
| 195 | |
| 196 | # ------------------------------------------------------------------------------ |
| 197 | |
Cary Clark | 6def720 | 2018-01-04 08:13:35 -0500 | [diff] [blame] | 198 | #Method int32_t top() const |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 199 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 200 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 201 | #Line # returns smaller bounds in y, if sorted ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 202 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 203 | |
| 204 | #Example |
| 205 | SkIRect unsorted = { 15, 25, 10, 5 }; |
| 206 | SkDebugf("unsorted.fTop: %d unsorted.top(): %d\n", unsorted.fTop, unsorted.top()); |
| 207 | SkIRect sorted = unsorted.makeSorted(); |
| 208 | SkDebugf("sorted.fTop: %d sorted.top(): %d\n", sorted.fTop, sorted.top()); |
| 209 | #StdOut |
| 210 | unsorted.fTop: 25 unsorted.top(): 25 |
| 211 | sorted.fTop: 5 sorted.top(): 5 |
| 212 | ## |
| 213 | ## |
| 214 | |
| 215 | #SeeAlso fTop y() SkRect::top() |
| 216 | |
| 217 | ## |
| 218 | |
| 219 | # ------------------------------------------------------------------------------ |
| 220 | |
Cary Clark | 6def720 | 2018-01-04 08:13:35 -0500 | [diff] [blame] | 221 | #Method int32_t right() const |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 222 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 223 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 224 | #Line # returns larger bounds in x, if sorted ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 225 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 226 | |
| 227 | #Example |
| 228 | SkIRect unsorted = { 15, 25, 10, 5 }; |
| 229 | SkDebugf("unsorted.fRight: %d unsorted.right(): %d\n", unsorted.fRight, unsorted.right()); |
| 230 | SkIRect sorted = unsorted.makeSorted(); |
| 231 | SkDebugf("sorted.fRight: %d sorted.right(): %d\n", sorted.fRight, sorted.right()); |
| 232 | #StdOut |
| 233 | unsorted.fRight: 10 unsorted.right(): 10 |
| 234 | sorted.fRight: 15 sorted.right(): 15 |
| 235 | ## |
| 236 | ## |
| 237 | |
| 238 | #SeeAlso fRight SkRect::right() |
| 239 | |
| 240 | ## |
| 241 | |
| 242 | # ------------------------------------------------------------------------------ |
| 243 | |
Cary Clark | 6def720 | 2018-01-04 08:13:35 -0500 | [diff] [blame] | 244 | #Method int32_t bottom() const |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 245 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 246 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 247 | #Line # returns larger bounds in y, if sorted ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 248 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 249 | |
| 250 | #Example |
| 251 | SkIRect unsorted = { 15, 25, 10, 5 }; |
| 252 | SkDebugf("unsorted.fBottom: %d unsorted.bottom(): %d\n", unsorted.fBottom, unsorted.bottom()); |
| 253 | SkIRect sorted = unsorted.makeSorted(); |
| 254 | SkDebugf("sorted.fBottom: %d sorted.bottom(): %d\n", sorted.fBottom, sorted.bottom()); |
| 255 | #StdOut |
| 256 | unsorted.fBottom: 5 unsorted.bottom(): 5 |
| 257 | sorted.fBottom: 25 sorted.bottom(): 25 |
| 258 | ## |
| 259 | ## |
| 260 | |
| 261 | #SeeAlso fBottom SkRect::bottom() |
| 262 | |
| 263 | ## |
| 264 | |
| 265 | # ------------------------------------------------------------------------------ |
| 266 | |
Cary Clark | 6def720 | 2018-01-04 08:13:35 -0500 | [diff] [blame] | 267 | #Method int32_t x() const |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 268 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 269 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 270 | #Line # returns bounds left ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 271 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 272 | |
| 273 | #Example |
| 274 | SkIRect unsorted = { 15, 5, 10, 25 }; |
| 275 | SkDebugf("unsorted.fLeft: %d unsorted.x(): %d\n", unsorted.fLeft, unsorted.x()); |
| 276 | SkIRect sorted = unsorted.makeSorted(); |
| 277 | SkDebugf("sorted.fLeft: %d sorted.x(): %d\n", sorted.fLeft, sorted.x()); |
| 278 | #StdOut |
| 279 | unsorted.fLeft: 15 unsorted.x(): 15 |
| 280 | sorted.fLeft: 10 sorted.x(): 10 |
| 281 | ## |
| 282 | ## |
| 283 | |
| 284 | #SeeAlso fLeft left() y() SkRect::x() |
| 285 | |
| 286 | ## |
| 287 | |
| 288 | # ------------------------------------------------------------------------------ |
| 289 | |
Cary Clark | 6def720 | 2018-01-04 08:13:35 -0500 | [diff] [blame] | 290 | #Method int32_t y() const |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 291 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 292 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 293 | #Line # returns bounds top ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 294 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 295 | |
| 296 | #Example |
| 297 | SkIRect unsorted = { 15, 25, 10, 5 }; |
| 298 | SkDebugf("unsorted.fTop: %d unsorted.y(): %d\n", unsorted.fTop, unsorted.y()); |
| 299 | SkIRect sorted = unsorted.makeSorted(); |
| 300 | SkDebugf("sorted.fTop: %d sorted.y(): %d\n", sorted.fTop, sorted.y()); |
| 301 | #StdOut |
| 302 | unsorted.fTop: 25 unsorted.y(): 25 |
| 303 | sorted.fTop: 5 sorted.y(): 5 |
| 304 | ## |
| 305 | ## |
| 306 | |
| 307 | #SeeAlso fTop top() x() SkRect::y() |
| 308 | |
| 309 | ## |
| 310 | |
| 311 | # ------------------------------------------------------------------------------ |
| 312 | |
Cary Clark | 6def720 | 2018-01-04 08:13:35 -0500 | [diff] [blame] | 313 | #Method int32_t width() const |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 314 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 315 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 316 | #Line # returns span in x ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 317 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 318 | |
| 319 | #Example |
| 320 | SkIRect unsorted = { 15, 25, 10, 5 }; |
| 321 | SkDebugf("unsorted width: %d\n", unsorted.width()); |
| 322 | SkIRect large = { -2147483647, 1, 2147483644, 2 }; |
| 323 | SkDebugf("large width: %d\n", large.width()); |
| 324 | #StdOut |
| 325 | unsorted width: -5 |
| 326 | large width: -5 |
| 327 | ## |
| 328 | ## |
| 329 | |
Mike Reed | a766ca9 | 2018-01-09 11:31:53 -0500 | [diff] [blame] | 330 | #SeeAlso height() width64() height64() SkRect::width() |
| 331 | |
| 332 | ## |
| 333 | |
| 334 | # ------------------------------------------------------------------------------ |
| 335 | |
| 336 | #Method int64_t width64() const |
| 337 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 338 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 339 | #Line # returns span in y as int64_t ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 340 | #Populate |
Mike Reed | a766ca9 | 2018-01-09 11:31:53 -0500 | [diff] [blame] | 341 | |
Cary Clark | 186d08f | 2018-04-03 08:43:27 -0400 | [diff] [blame] | 342 | #Example |
Mike Reed | a766ca9 | 2018-01-09 11:31:53 -0500 | [diff] [blame] | 343 | SkIRect large = { -2147483647, 1, 2147483644, 2 }; |
Cary Clark | 186d08f | 2018-04-03 08:43:27 -0400 | [diff] [blame] | 344 | SkDebugf("width: %d width64: %lld\n", large.width(), large.width64()); |
Mike Reed | a766ca9 | 2018-01-09 11:31:53 -0500 | [diff] [blame] | 345 | #StdOut |
| 346 | width: -5 width64: 4294967291 |
| 347 | ## |
| 348 | ## |
| 349 | |
| 350 | #SeeAlso width() height() height64() SkRect::width() |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 351 | |
| 352 | ## |
| 353 | |
| 354 | # ------------------------------------------------------------------------------ |
| 355 | |
Cary Clark | 6def720 | 2018-01-04 08:13:35 -0500 | [diff] [blame] | 356 | #Method int32_t height() const |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 357 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 358 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 359 | #Line # returns span in y ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 360 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 361 | |
| 362 | #Example |
| 363 | SkIRect unsorted = { 15, 25, 10, 20 }; |
| 364 | SkDebugf("unsorted height: %d\n", unsorted.height()); |
| 365 | SkIRect large = { 1, -2147483647, 2, 2147483644 }; |
| 366 | SkDebugf("large height: %d\n", large.height()); |
| 367 | #StdOut |
| 368 | unsorted height: -5 |
| 369 | large height: -5 |
| 370 | ## |
| 371 | ## |
| 372 | |
| 373 | #SeeAlso width() SkRect::height() |
| 374 | |
| 375 | ## |
| 376 | |
| 377 | # ------------------------------------------------------------------------------ |
| 378 | |
Mike Reed | a766ca9 | 2018-01-09 11:31:53 -0500 | [diff] [blame] | 379 | #Method int64_t height64() const |
| 380 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 381 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 382 | #Line # returns span in y as int64_t ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 383 | #Populate |
Mike Reed | a766ca9 | 2018-01-09 11:31:53 -0500 | [diff] [blame] | 384 | |
Cary Clark | 186d08f | 2018-04-03 08:43:27 -0400 | [diff] [blame] | 385 | #Example |
Mike Reed | a766ca9 | 2018-01-09 11:31:53 -0500 | [diff] [blame] | 386 | SkIRect large = { 1, -2147483647, 2, 2147483644 }; |
| 387 | SkDebugf("height: %d height64: %lld\n", large.height(), large.height64()); |
| 388 | #StdOut |
| 389 | height: -5 height64: 4294967291 |
| 390 | ## |
| 391 | ## |
| 392 | |
| 393 | #SeeAlso width() height() width64() SkRect::height() |
| 394 | |
| 395 | ## |
| 396 | |
| 397 | # ------------------------------------------------------------------------------ |
| 398 | |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 399 | #Method SkISize size() const |
| 400 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 401 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 402 | #Line # returns ISize (width, height) ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 403 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 404 | |
| 405 | #Example |
| 406 | auto debugster = [](const char* prefix, const SkIRect& rect) -> void { |
| 407 | SkISize size = rect.size(); |
| 408 | SkDebugf("%s ", prefix); |
| 409 | SkDebugf("rect: %d, %d, %d, %d ", rect.left(), rect.top(), rect.right(), rect.bottom()); |
| 410 | SkDebugf("size: %d, %d\n", size.width(), size.height()); |
| 411 | }; |
| 412 | SkIRect rect = {20, 30, 40, 50}; |
| 413 | debugster("original", rect); |
| 414 | rect.offset(20, 20); |
| 415 | debugster(" offset", rect); |
| 416 | rect.outset(20, 20); |
| 417 | debugster(" outset", rect); |
| 418 | #StdOut |
| 419 | original rect: 20, 30, 40, 50 size: 20, 20 |
| 420 | offset rect: 40, 50, 60, 70 size: 20, 20 |
| 421 | outset rect: 20, 30, 80, 90 size: 60, 60 |
| 422 | ## |
| 423 | ## |
| 424 | |
| 425 | #SeeAlso height() width() MakeSize |
| 426 | |
| 427 | ## |
| 428 | |
| 429 | # ------------------------------------------------------------------------------ |
| 430 | |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 431 | #Method bool isEmpty() const |
| 432 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 433 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 434 | #Line # returns true if width or height are zero or negative or they exceed int32_t ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 435 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 436 | |
| 437 | #Example |
| 438 | SkIRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}}; |
| 439 | for (auto rect : tests) { |
| 440 | SkDebugf("rect: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(), |
| 441 | rect.bottom(), rect.isEmpty() ? "" : " not"); |
| 442 | rect.sort(); |
| 443 | SkDebugf("sorted: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(), |
| 444 | rect.bottom(), rect.isEmpty() ? "" : " not"); |
| 445 | } |
| 446 | #StdOut |
| 447 | rect: {20, 40, 10, 50} is empty |
| 448 | sorted: {10, 40, 20, 50} is not empty |
| 449 | rect: {20, 40, 20, 50} is empty |
| 450 | sorted: {20, 40, 20, 50} is empty |
| 451 | ## |
| 452 | ## |
| 453 | |
| 454 | #SeeAlso EmptyIRect MakeEmpty sort SkRect::isEmpty |
| 455 | |
| 456 | ## |
| 457 | |
| 458 | # ------------------------------------------------------------------------------ |
| 459 | |
Mike Reed | d284949 | 2018-01-10 14:31:18 -0500 | [diff] [blame] | 460 | #Method bool isEmpty64() const |
| 461 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 462 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 463 | #Line # returns true if width or height are zero or negative ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 464 | #Populate |
Mike Reed | d284949 | 2018-01-10 14:31:18 -0500 | [diff] [blame] | 465 | |
Cary Clark | 186d08f | 2018-04-03 08:43:27 -0400 | [diff] [blame] | 466 | #Example |
Mike Reed | d284949 | 2018-01-10 14:31:18 -0500 | [diff] [blame] | 467 | SkIRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}}; |
| 468 | for (auto rect : tests) { |
Cary Clark | 186d08f | 2018-04-03 08:43:27 -0400 | [diff] [blame] | 469 | SkDebugf("rect: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(), |
| 470 | rect.bottom(), rect.isEmpty64() ? "" : " not"); |
| 471 | rect.sort(); |
| 472 | SkDebugf("sorted: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(), |
| 473 | rect.bottom(), rect.isEmpty64() ? "" : " not"); |
Mike Reed | d284949 | 2018-01-10 14:31:18 -0500 | [diff] [blame] | 474 | } |
| 475 | #StdOut |
| 476 | rect: {20, 40, 10, 50} is empty |
| 477 | sorted: {10, 40, 20, 50} is not empty |
| 478 | rect: {20, 40, 20, 50} is empty |
| 479 | sorted: {20, 40, 20, 50} is empty |
| 480 | ## |
| 481 | ## |
| 482 | |
| 483 | #SeeAlso EmptyIRect MakeEmpty sort SkRect::isEmpty |
| 484 | |
| 485 | ## |
| 486 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 487 | #Subtopic Operators |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 488 | |
Mike Reed | d284949 | 2018-01-10 14:31:18 -0500 | [diff] [blame] | 489 | # ------------------------------------------------------------------------------ |
| 490 | |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 491 | #Method bool operator==(const SkIRect& a, const SkIRect& b) |
| 492 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 493 | #In Operators |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 494 | #Line # returns true if members are equal ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 495 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 496 | |
| 497 | #Example |
| 498 | SkIRect test = {0, 0, 2, 2}; |
| 499 | SkIRect sorted = test.makeSorted(); |
| 500 | SkDebugf("test %c= sorted\n", test == sorted ? '=' : '!'); |
| 501 | #StdOut |
| 502 | test == sorted |
| 503 | ## |
| 504 | ## |
| 505 | |
| 506 | #SeeAlso operator!=(const SkIRect& a, const SkIRect& b) |
| 507 | |
| 508 | ## |
| 509 | |
| 510 | # ------------------------------------------------------------------------------ |
| 511 | |
| 512 | #Method bool operator!=(const SkIRect& a, const SkIRect& b) |
| 513 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 514 | #In Operators |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 515 | #Line # returns true if members are unequal ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 516 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 517 | |
| 518 | #Example |
| 519 | SkIRect test = {2, 2, 0, 0}; |
| 520 | SkIRect sorted = test.makeSorted(); |
| 521 | SkDebugf("test %c= sorted\n", test != sorted ? '!' : '='); |
| 522 | #StdOut |
| 523 | test != sorted |
| 524 | ## |
| 525 | ## |
| 526 | |
| 527 | #SeeAlso operator==(const SkIRect& a, const SkIRect& b) |
| 528 | |
| 529 | ## |
| 530 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 531 | #Subtopic Operators ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 532 | |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 533 | # ------------------------------------------------------------------------------ |
| 534 | |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 535 | #Subtopic Set |
| 536 | #Line # replaces all values ## |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 537 | ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 538 | |
| 539 | #Method void setEmpty() |
| 540 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 541 | #In Set |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 542 | #Line # sets to (0, 0, 0, 0) ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 543 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 544 | |
| 545 | #Example |
| 546 | SkIRect rect = {3, 4, 1, 2}; |
| 547 | for (int i = 0; i < 2; ++i) { |
| 548 | SkDebugf("rect: {%d, %d, %d, %d} is %s" "empty\n", rect.fLeft, rect.fTop, |
| 549 | rect.fRight, rect.fBottom, rect.isEmpty() ? "" : "not "); |
| 550 | rect.setEmpty(); |
| 551 | } |
| 552 | #StdOut |
| 553 | rect: {3, 4, 1, 2} is empty |
| 554 | rect: {0, 0, 0, 0} is empty |
| 555 | ## |
| 556 | ## |
| 557 | |
| 558 | #SeeAlso MakeEmpty SkRect::setEmpty |
| 559 | |
| 560 | ## |
| 561 | |
| 562 | # ------------------------------------------------------------------------------ |
| 563 | |
| 564 | #Method void set(int32_t left, int32_t top, int32_t right, int32_t bottom) |
| 565 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 566 | #In Set |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 567 | #Line # sets to (left, top, right, bottom) ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 568 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 569 | |
| 570 | #Example |
| 571 | SkIRect rect1 = {3, 4, 1, 2}; |
| 572 | SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom); |
| 573 | SkIRect rect2; |
| 574 | rect2.set(3, 4, 1, 2); |
| 575 | SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom); |
| 576 | #StdOut |
| 577 | rect1: {3, 4, 1, 2} |
| 578 | rect2: {3, 4, 1, 2} |
| 579 | ## |
| 580 | ## |
| 581 | |
| 582 | #SeeAlso setLTRB setXYWH SkRect::set |
| 583 | |
| 584 | ## |
| 585 | |
| 586 | # ------------------------------------------------------------------------------ |
| 587 | |
| 588 | #Method void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom) |
| 589 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 590 | #In Set |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 591 | #Line # sets to SkScalar input (left, top, right, bottom) ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 592 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 593 | |
| 594 | #Example |
| 595 | SkIRect rect1 = {3, 4, 1, 2}; |
| 596 | SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom); |
| 597 | SkIRect rect2; |
| 598 | rect2.setLTRB(3, 4, 1, 2); |
| 599 | SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom); |
| 600 | #StdOut |
| 601 | rect1: {3, 4, 1, 2} |
| 602 | rect2: {3, 4, 1, 2} |
| 603 | ## |
| 604 | ## |
| 605 | |
| 606 | #SeeAlso set setXYWH SkRect::setLTRB |
| 607 | |
| 608 | ## |
| 609 | |
| 610 | # ------------------------------------------------------------------------------ |
| 611 | |
| 612 | #Method void setXYWH(int32_t x, int32_t y, int32_t width, int32_t height) |
| 613 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 614 | #In Set |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 615 | #Line # sets to (x, y, width, height) ## |
Cary Clark | 2be81cf | 2018-09-13 12:04:30 -0400 | [diff] [blame] | 616 | Sets IRect to: #Formula # (x, y, x + width, y + height) ##. |
| 617 | Does not validate input; width or height may be negative. |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 618 | |
| 619 | #Param x stored in fLeft ## |
| 620 | #Param y stored in fTop ## |
| 621 | #Param width added to x and stored in fRight ## |
| 622 | #Param height added to y and stored in fBottom ## |
| 623 | |
| 624 | #Example |
| 625 | SkIRect rect; |
| 626 | rect.setXYWH(5, 35, -15, 25); |
| 627 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 628 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 629 | rect.sort(); |
| 630 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 631 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 632 | #StdOut |
| 633 | rect: 5, 35, -10, 60 isEmpty: true |
| 634 | rect: -10, 35, 5, 60 isEmpty: false |
| 635 | ## |
| 636 | ## |
| 637 | |
| 638 | #SeeAlso MakeXYWH setLTRB set SkRect::setXYWH |
| 639 | |
| 640 | ## |
| 641 | |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 642 | #Subtopic Inset_Outset_Offset |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 643 | #Line # moves sides ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 644 | |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 645 | # ------------------------------------------------------------------------------ |
| 646 | |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 647 | #Method SkIRect makeOffset(int32_t dx, int32_t dy) const |
| 648 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 649 | #In Inset_Outset_Offset |
| 650 | #Line # constructs from translated sides ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 651 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 652 | |
| 653 | #Example |
| 654 | SkIRect rect = { 10, 50, 20, 60 }; |
| 655 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 656 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 657 | rect = rect.makeOffset(15, 32); |
| 658 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 659 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 660 | #StdOut |
| 661 | rect: 10, 50, 20, 60 isEmpty: false |
| 662 | rect: 25, 82, 35, 92 isEmpty: false |
| 663 | ## |
| 664 | ## |
| 665 | |
| 666 | #SeeAlso offset() makeInset makeOutset SkRect::makeOffset |
| 667 | |
| 668 | ## |
| 669 | |
| 670 | # ------------------------------------------------------------------------------ |
| 671 | |
| 672 | #Method SkIRect makeInset(int32_t dx, int32_t dy) const |
| 673 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 674 | #In Inset_Outset_Offset |
| 675 | #Line # constructs from sides moved symmetrically about the center ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 676 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 677 | |
| 678 | #Example |
| 679 | SkIRect rect = { 10, 50, 20, 60 }; |
| 680 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 681 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 682 | rect = rect.makeInset(15, 32); |
| 683 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 684 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 685 | #StdOut |
| 686 | rect: 10, 50, 20, 60 isEmpty: false |
| 687 | rect: 25, 82, 5, 28 isEmpty: true |
| 688 | ## |
| 689 | ## |
| 690 | |
| 691 | #SeeAlso inset() makeOffset makeOutset SkRect::makeInset |
| 692 | |
| 693 | ## |
| 694 | |
| 695 | # ------------------------------------------------------------------------------ |
| 696 | |
| 697 | #Method SkIRect makeOutset(int32_t dx, int32_t dy) const |
| 698 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 699 | #In Inset_Outset_Offset |
| 700 | #Line # constructs from sides moved symmetrically about the center ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 701 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 702 | |
| 703 | #Example |
| 704 | SkIRect rect = { 10, 50, 20, 60 }; |
| 705 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 706 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 707 | rect = rect.makeOutset(15, 32); |
| 708 | SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 709 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 710 | #StdOut |
| 711 | rect: 10, 50, 20, 60 isEmpty: false |
| 712 | rect: -5, 18, 35, 92 isEmpty: false |
| 713 | ## |
| 714 | ## |
| 715 | |
| 716 | #SeeAlso outset() makeOffset makeInset SkRect::makeOutset |
| 717 | |
| 718 | ## |
| 719 | |
| 720 | # ------------------------------------------------------------------------------ |
| 721 | |
| 722 | #Method void offset(int32_t dx, int32_t dy) |
| 723 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 724 | #In Inset_Outset_Offset |
| 725 | #Line # translates sides without changing width and height ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 726 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 727 | |
| 728 | #Example |
| 729 | SkIRect rect = { 10, 14, 50, 73 }; |
| 730 | rect.offset(5, 13); |
| 731 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 732 | #StdOut |
| 733 | rect: 15, 27, 55, 86 |
| 734 | ## |
| 735 | ## |
| 736 | |
| 737 | #SeeAlso offsetTo makeOffset SkRect::offset |
| 738 | |
| 739 | ## |
| 740 | |
| 741 | # ------------------------------------------------------------------------------ |
| 742 | |
| 743 | #Method void offset(const SkIPoint& delta) |
| 744 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 745 | #In Inset_Outset_Offset |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 746 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 747 | |
| 748 | #Example |
| 749 | SkIRect rect = { 10, 14, 50, 73 }; |
| 750 | rect.offset({5, 13}); |
| 751 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 752 | #StdOut |
| 753 | rect: 15, 27, 55, 86 |
| 754 | ## |
| 755 | ## |
| 756 | |
| 757 | #SeeAlso offsetTo makeOffset SkRect::offset |
| 758 | |
| 759 | ## |
| 760 | |
| 761 | # ------------------------------------------------------------------------------ |
| 762 | |
| 763 | #Method void offsetTo(int32_t newX, int32_t newY) |
| 764 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 765 | #In Inset_Outset_Offset |
| 766 | #Line # translates to (x, y) without changing width and height ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 767 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 768 | |
| 769 | #Example |
| 770 | SkIRect rect = { 10, 14, 50, 73 }; |
| 771 | rect.offsetTo(15, 27); |
| 772 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 773 | #StdOut |
| 774 | rect: 15, 27, 55, 86 |
| 775 | ## |
| 776 | ## |
| 777 | |
| 778 | #SeeAlso offset makeOffset setXYWH SkRect::offsetTo |
| 779 | |
| 780 | ## |
| 781 | |
| 782 | # ------------------------------------------------------------------------------ |
| 783 | |
| 784 | #Method void inset(int32_t dx, int32_t dy) |
| 785 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 786 | #In Inset_Outset_Offset |
| 787 | #Line # moves the sides symmetrically about the center ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 788 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 789 | |
| 790 | #Example |
| 791 | SkIRect rect = { 10, 14, 50, 73 }; |
| 792 | rect.inset(5, 13); |
| 793 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 794 | #StdOut |
| 795 | rect: 15, 27, 45, 60 |
| 796 | ## |
| 797 | ## |
| 798 | |
| 799 | #SeeAlso outset makeInset SkRect::inset |
| 800 | |
| 801 | ## |
| 802 | |
| 803 | # ------------------------------------------------------------------------------ |
| 804 | |
| 805 | #Method void outset(int32_t dx, int32_t dy) |
| 806 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 807 | #In Inset_Outset_Offset |
| 808 | #Line # moves the sides symmetrically about the center ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 809 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 810 | |
| 811 | #Example |
| 812 | SkIRect rect = { 10, 14, 50, 73 }; |
| 813 | rect.outset(5, 13); |
| 814 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 815 | #StdOut |
| 816 | rect: 5, 1, 55, 86 |
| 817 | ## |
| 818 | ## |
| 819 | |
| 820 | #SeeAlso inset makeOutset SkRect::outset |
| 821 | |
| 822 | ## |
| 823 | |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 824 | #Subtopic Inset_Outset_Offset ## |
| 825 | |
| 826 | #Subtopic Intersection |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 827 | #Line # sets to shared bounds ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 828 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 829 | 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] | 830 | must describe area; fLeft is less than fRight, and fTop is less than fBottom; |
Cary Clark | 77b3f3a | 2018-11-07 14:59:03 -0500 | [diff] [blame] | 831 | SkIRect::isEmpty() returns false. The intersection of IRect pair can be described by: |
Cary Clark | 2be81cf | 2018-09-13 12:04:30 -0400 | [diff] [blame] | 832 | #Formula # (max(a.fLeft, b.fLeft), max(a.fTop, b.fTop), |
| 833 | min(a.fRight, b.fRight), min(a.fBottom, b.fBottom)) ##. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 834 | |
| 835 | The intersection is only meaningful if the resulting IRect is not empty and |
| 836 | describes an area: fLeft is less than fRight, and fTop is less than fBottom. |
| 837 | |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 838 | # ------------------------------------------------------------------------------ |
| 839 | |
Robert Phillips | 8f8d481 | 2018-05-18 10:19:05 -0400 | [diff] [blame] | 840 | #Method void adjust(int32_t dL, int32_t dT, int32_t dR, int32_t dB) |
| 841 | |
| 842 | #In Inset_Outset_Offset |
| 843 | #Line # moves the sides independently relative to their original locations ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 844 | #Populate |
Robert Phillips | 8f8d481 | 2018-05-18 10:19:05 -0400 | [diff] [blame] | 845 | |
| 846 | #Example |
| 847 | SkIRect rect = { 8, 11, 19, 22 }; |
| 848 | rect.adjust(2, -1, 1, -2); |
| 849 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 850 | #StdOut |
| 851 | rect: 10, 10, 20, 20 |
| 852 | ## |
| 853 | ## |
| 854 | |
| 855 | #SeeAlso inset outset |
| 856 | |
| 857 | ## |
| 858 | |
| 859 | # ------------------------------------------------------------------------------ |
| 860 | |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 861 | #Method bool contains(int32_t x, int32_t y) const |
| 862 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 863 | #In Intersection |
Cary Clark | 300cc5b | 2018-02-20 12:50:35 -0500 | [diff] [blame] | 864 | #Line # returns true if IPoint (x, y) is equal or inside ## |
Cary Clark | 2be81cf | 2018-09-13 12:04:30 -0400 | [diff] [blame] | 865 | Returns true if: #Formula # fLeft <= x < fRight && fTop <= y < fBottom ##. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 866 | Returns false if IRect is empty. |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 867 | |
Cary Clark | 2be81cf | 2018-09-13 12:04:30 -0400 | [diff] [blame] | 868 | 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] | 869 | returns true if constructed area is completely enclosed by IRect area. |
| 870 | |
Cary Clark | 300cc5b | 2018-02-20 12:50:35 -0500 | [diff] [blame] | 871 | #Param x test IPoint x-coordinate ## |
| 872 | #Param y test IPoint y-coordinate ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 873 | |
| 874 | #Return true if (x, y) is inside IRect ## |
| 875 | |
| 876 | #Example |
| 877 | SkIRect rect = { 30, 50, 40, 60 }; |
| 878 | SkIPoint pts[] = { { 30, 50}, { 40, 50}, { 30, 60} }; |
| 879 | for (auto pt : pts) { |
| 880 | SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d)\n", |
| 881 | rect.left(), rect.top(), rect.right(), rect.bottom(), |
| 882 | rect.contains(pt.x(), pt.y()) ? "contains" : "does not contain", pt.x(), pt.y()); |
| 883 | } |
| 884 | #StdOut |
| 885 | rect: (30, 50, 40, 60) contains (30, 50) |
| 886 | rect: (30, 50, 40, 60) does not contain (40, 50) |
| 887 | rect: (30, 50, 40, 60) does not contain (30, 60) |
| 888 | ## |
| 889 | ## |
| 890 | |
| 891 | #SeeAlso containsNoEmptyCheck SkRect::contains |
| 892 | |
| 893 | ## |
| 894 | |
| 895 | # ------------------------------------------------------------------------------ |
| 896 | |
| 897 | #Method bool contains(int32_t left, int32_t top, int32_t right, int32_t bottom) const |
| 898 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 899 | #In Intersection |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 900 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 901 | |
| 902 | #Example |
| 903 | SkIRect rect = { 30, 50, 40, 60 }; |
| 904 | SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} }; |
| 905 | for (auto contained : tests) { |
| 906 | bool success = rect.contains( |
| 907 | contained.left(), contained.top(), contained.right(), contained.bottom()); |
| 908 | SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n", |
| 909 | rect.left(), rect.top(), rect.right(), rect.bottom(), |
| 910 | success ? "contains" : "does not contain", |
| 911 | contained.left(), contained.top(), contained.right(), contained.bottom()); |
| 912 | } |
| 913 | #StdOut |
| 914 | rect: (30, 50, 40, 60) contains (30, 50, 31, 51) |
| 915 | rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50) |
| 916 | rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60) |
| 917 | ## |
| 918 | ## |
| 919 | |
| 920 | #SeeAlso containsNoEmptyCheck SkRect::contains |
| 921 | |
| 922 | ## |
| 923 | |
| 924 | # ------------------------------------------------------------------------------ |
| 925 | |
| 926 | #Method bool contains(const SkIRect& r) const |
| 927 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 928 | #In Intersection |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 929 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 930 | |
| 931 | #Example |
| 932 | SkIRect rect = { 30, 50, 40, 60 }; |
| 933 | SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} }; |
| 934 | for (auto contained : tests) { |
| 935 | SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n", |
| 936 | rect.left(), rect.top(), rect.right(), rect.bottom(), |
| 937 | rect.contains(contained) ? "contains" : "does not contain", |
| 938 | contained.left(), contained.top(), contained.right(), contained.bottom()); |
| 939 | } |
| 940 | #StdOut |
| 941 | rect: (30, 50, 40, 60) contains (30, 50, 31, 51) |
| 942 | rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50) |
| 943 | rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60) |
| 944 | ## |
| 945 | ## |
| 946 | |
| 947 | #SeeAlso containsNoEmptyCheck SkRect::contains |
| 948 | |
| 949 | ## |
| 950 | |
| 951 | # ------------------------------------------------------------------------------ |
| 952 | |
| 953 | #Method bool contains(const SkRect& r) const |
| 954 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 955 | #In Intersection |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 956 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 957 | |
| 958 | #Example |
| 959 | SkIRect rect = { 30, 50, 40, 60 }; |
| 960 | SkRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} }; |
| 961 | for (auto contained : tests) { |
| 962 | SkDebugf("rect: (%d, %d, %d, %d) %s (%g, %g, %g, %g)\n", |
| 963 | rect.left(), rect.top(), rect.right(), rect.bottom(), |
| 964 | rect.contains(contained) ? "contains" : "does not contain", |
| 965 | contained.left(), contained.top(), contained.right(), contained.bottom()); |
| 966 | } |
| 967 | #StdOut |
| 968 | rect: (30, 50, 40, 60) contains (30, 50, 31, 51) |
| 969 | rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50) |
| 970 | rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60) |
| 971 | ## |
| 972 | ## |
| 973 | |
| 974 | #SeeAlso containsNoEmptyCheck SkRect::contains |
| 975 | |
| 976 | ## |
| 977 | |
| 978 | # ------------------------------------------------------------------------------ |
| 979 | |
| 980 | #Method bool containsNoEmptyCheck(int32_t left, int32_t top, |
| 981 | int32_t right, int32_t bottom) const |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 982 | #In Intersection |
Cary Clark | 300cc5b | 2018-02-20 12:50:35 -0500 | [diff] [blame] | 983 | #Line # returns true if contains unsorted IRect ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 984 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 985 | |
| 986 | #Example |
| 987 | SkIRect rect = { 30, 50, 40, 60 }; |
| 988 | SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} }; |
| 989 | for (auto contained : tests) { |
| 990 | bool success = rect.containsNoEmptyCheck( |
| 991 | contained.left(), contained.top(), contained.right(), contained.bottom()); |
| 992 | SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n", |
| 993 | rect.left(), rect.top(), rect.right(), rect.bottom(), |
| 994 | success ? "contains" : "does not contain", |
| 995 | contained.left(), contained.top(), contained.right(), contained.bottom()); |
| 996 | } |
| 997 | #StdOut |
| 998 | rect: (30, 50, 40, 60) contains (30, 50, 31, 51) |
| 999 | rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50) |
| 1000 | rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60) |
| 1001 | ## |
| 1002 | ## |
| 1003 | |
| 1004 | #SeeAlso contains SkRect::contains |
| 1005 | |
| 1006 | ## |
| 1007 | |
| 1008 | # ------------------------------------------------------------------------------ |
| 1009 | |
| 1010 | #Method bool containsNoEmptyCheck(const SkIRect& r) const |
| 1011 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1012 | #In Intersection |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 1013 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1014 | |
| 1015 | #Example |
| 1016 | SkIRect rect = { 30, 50, 40, 60 }; |
| 1017 | SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} }; |
| 1018 | for (auto contained : tests) { |
| 1019 | SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n", |
| 1020 | rect.left(), rect.top(), rect.right(), rect.bottom(), |
| 1021 | rect.containsNoEmptyCheck(contained) ? "contains" : "does not contain", |
| 1022 | contained.left(), contained.top(), contained.right(), contained.bottom()); |
| 1023 | } |
| 1024 | #StdOut |
| 1025 | rect: (30, 50, 40, 60) contains (30, 50, 31, 51) |
| 1026 | rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50) |
| 1027 | rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60) |
| 1028 | ## |
| 1029 | ## |
| 1030 | |
| 1031 | #SeeAlso contains SkRect::contains |
| 1032 | |
| 1033 | ## |
| 1034 | |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1035 | # ------------------------------------------------------------------------------ |
| 1036 | |
| 1037 | #Method bool intersect(const SkIRect& r) |
| 1038 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1039 | #In Intersection |
| 1040 | #Line # sets to shared area; returns true if not empty ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 1041 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1042 | |
| 1043 | #Example |
| 1044 | #Description |
| 1045 | Two SkDebugf calls are required. If the calls are combined, their arguments |
| 1046 | may not be evaluated in left to right order: the printed intersection may |
| 1047 | be before or after the call to intersect. |
| 1048 | ## |
| 1049 | SkIRect leftRect = { 10, 40, 50, 80 }; |
| 1050 | SkIRect rightRect = { 30, 60, 70, 90 }; |
| 1051 | SkDebugf("%s intersection: ", leftRect.intersect(rightRect) ? "" : "no "); |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1052 | SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(), |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1053 | leftRect.right(), leftRect.bottom()); |
| 1054 | #StdOut |
| 1055 | intersection: 30, 60, 50, 80 |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1056 | ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1057 | ## |
| 1058 | |
| 1059 | #SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect |
| 1060 | |
| 1061 | ## |
| 1062 | |
| 1063 | # ------------------------------------------------------------------------------ |
| 1064 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 1065 | #Method bool intersect(const SkIRect& a, const SkIRect& b) |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1066 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1067 | #In Intersection |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 1068 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1069 | |
| 1070 | #Example |
| 1071 | SkIRect result; |
| 1072 | bool intersected = result.intersect({ 10, 40, 50, 80 }, { 30, 60, 70, 90 }); |
| 1073 | SkDebugf("%s intersection: %d, %d, %d, %d\n", intersected ? "" : "no ", |
| 1074 | result.left(), result.top(), result.right(), result.bottom()); |
| 1075 | #StdOut |
| 1076 | intersection: 30, 60, 50, 80 |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1077 | ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1078 | ## |
| 1079 | |
| 1080 | #SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect |
| 1081 | |
| 1082 | ## |
| 1083 | |
| 1084 | # ------------------------------------------------------------------------------ |
| 1085 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 1086 | #Method bool intersectNoEmptyCheck(const SkIRect& a, const SkIRect& b) |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1087 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1088 | #In Intersection |
| 1089 | #Line # sets to shared area; returns true if not empty skips empty check ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 1090 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1091 | |
| 1092 | #Example |
| 1093 | SkIRect result; |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1094 | if (result.intersectNoEmptyCheck({ 10, 40, 50, 80 }, { 30, 60, 70, 90 })) { |
| 1095 | SkDebugf("intersection: %d, %d, %d, %d\n", |
| 1096 | result.left(), result.top(), result.right(), result.bottom()); |
| 1097 | } |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1098 | #StdOut |
| 1099 | intersection: 30, 60, 50, 80 |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1100 | ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1101 | ## |
| 1102 | |
| 1103 | #SeeAlso Intersects intersect join SkRect::intersect |
| 1104 | |
| 1105 | ## |
| 1106 | |
| 1107 | # ------------------------------------------------------------------------------ |
| 1108 | |
| 1109 | #Method bool intersect(int32_t left, int32_t top, int32_t right, int32_t bottom) |
| 1110 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1111 | #In Intersection |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 1112 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1113 | |
| 1114 | #Example |
| 1115 | #Description |
| 1116 | Two SkDebugf calls are required. If the calls are combined, their arguments |
| 1117 | may not be evaluated in left to right order: the printed intersection may |
| 1118 | be before or after the call to intersect. |
| 1119 | ## |
| 1120 | SkIRect leftRect = { 10, 40, 50, 80 }; |
| 1121 | SkDebugf("%s intersection: ", leftRect.intersect(30, 60, 70, 90) ? "" : "no "); |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1122 | SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(), |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1123 | leftRect.right(), leftRect.bottom()); |
| 1124 | #StdOut |
| 1125 | intersection: 30, 60, 50, 80 |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1126 | ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1127 | ## |
| 1128 | |
| 1129 | #SeeAlso intersectNoEmptyCheck Intersects join SkRect::intersect |
| 1130 | |
| 1131 | ## |
| 1132 | |
| 1133 | # ------------------------------------------------------------------------------ |
| 1134 | |
| 1135 | #Method static bool Intersects(const SkIRect& a, const SkIRect& b) |
| 1136 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1137 | #In Intersection |
| 1138 | #Line # returns true if areas overlap ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 1139 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1140 | |
| 1141 | #Example |
| 1142 | SkDebugf("%s intersection", SkIRect::Intersects({10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no "); |
| 1143 | #StdOut |
| 1144 | intersection |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1145 | ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1146 | ## |
| 1147 | |
| 1148 | #SeeAlso IntersectsNoEmptyCheck intersect SkRect::intersect |
| 1149 | |
| 1150 | ## |
| 1151 | |
| 1152 | # ------------------------------------------------------------------------------ |
| 1153 | |
| 1154 | #Method static bool IntersectsNoEmptyCheck(const SkIRect& a, const SkIRect& b) |
| 1155 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1156 | #In Intersection |
| 1157 | #Line # returns true if areas overlap skips empty check ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 1158 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1159 | |
| 1160 | #Example |
| 1161 | SkDebugf("%s intersection", SkIRect::IntersectsNoEmptyCheck( |
| 1162 | {10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no "); |
| 1163 | #StdOut |
| 1164 | intersection |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1165 | ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1166 | ## |
| 1167 | |
| 1168 | #SeeAlso Intersects intersect SkRect::intersect |
| 1169 | |
| 1170 | ## |
| 1171 | |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1172 | #Subtopic Intersection ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1173 | |
| 1174 | # ------------------------------------------------------------------------------ |
| 1175 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 1176 | #Subtopic Join |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1177 | #Line # sets to union of bounds ## |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 1178 | ## |
| 1179 | |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1180 | #Method void join(int32_t left, int32_t top, int32_t right, int32_t bottom) |
| 1181 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 1182 | #In Join |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1183 | #Line # sets to union of bounds ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 1184 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1185 | |
| 1186 | #Example |
| 1187 | SkIRect rect = { 10, 20, 15, 25}; |
| 1188 | rect.join(50, 60, 55, 65); |
| 1189 | SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1190 | #StdOut |
| 1191 | join: 10, 20, 55, 65 |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1192 | ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1193 | ## |
| 1194 | |
| 1195 | #SeeAlso set SkRect::join |
| 1196 | |
| 1197 | ## |
| 1198 | |
| 1199 | # ------------------------------------------------------------------------------ |
| 1200 | |
| 1201 | #Method void join(const SkIRect& r) |
| 1202 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 1203 | #In Join |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 1204 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1205 | |
| 1206 | #Example |
| 1207 | SkIRect rect = { 10, 20, 15, 25}; |
| 1208 | rect.join({50, 60, 55, 65}); |
| 1209 | SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1210 | #StdOut |
| 1211 | join: 10, 20, 55, 65 |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1212 | ## |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1213 | ## |
| 1214 | |
| 1215 | #SeeAlso set SkRect::join |
| 1216 | |
| 1217 | ## |
| 1218 | |
| 1219 | # ------------------------------------------------------------------------------ |
| 1220 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 1221 | #Subtopic Sorting |
| 1222 | #Line # orders sides ## |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 1223 | ## |
| 1224 | |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1225 | #Method void sort() |
| 1226 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 1227 | #In Sorting |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1228 | #Line # orders sides from smaller to larger ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 1229 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1230 | |
| 1231 | #Example |
| 1232 | SkIRect rect = { 30, 50, 20, 10 }; |
| 1233 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1234 | rect.sort(); |
| 1235 | SkDebugf("sorted: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1236 | #StdOut |
| 1237 | rect: 30, 50, 20, 10 |
| 1238 | sorted: 20, 10, 30, 50 |
| 1239 | ## |
| 1240 | ## |
| 1241 | |
| 1242 | #SeeAlso makeSorted SkRect::sort |
| 1243 | |
| 1244 | ## |
| 1245 | |
| 1246 | # ------------------------------------------------------------------------------ |
| 1247 | |
| 1248 | #Method SkIRect makeSorted() const |
| 1249 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 1250 | #In Sorting |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 1251 | #In Constructors |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1252 | #Line # constructs IRect, ordering sides from smaller to larger ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 1253 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1254 | |
| 1255 | #Example |
| 1256 | SkIRect rect = { 30, 50, 20, 10 }; |
| 1257 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1258 | SkIRect sort = rect.makeSorted(); |
| 1259 | SkDebugf("sorted: %d, %d, %d, %d\n", sort.fLeft, sort.fTop, sort.fRight, sort.fBottom); |
| 1260 | #StdOut |
| 1261 | rect: 30, 50, 20, 10 |
| 1262 | sorted: 20, 10, 30, 50 |
| 1263 | ## |
| 1264 | ## |
| 1265 | |
| 1266 | #SeeAlso sort SkRect::makeSorted |
| 1267 | |
| 1268 | ## |
| 1269 | |
| 1270 | # ------------------------------------------------------------------------------ |
| 1271 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 1272 | #Method static const SkIRect& EmptyIRect() |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1273 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 1274 | #In Constructors |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1275 | #Line # returns immutable bounds of (0, 0, 0, 0) ## |
Cary Clark | 09d80c0 | 2018-10-31 12:14:03 -0400 | [diff] [blame] | 1276 | #Populate |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 1277 | |
| 1278 | #Example |
| 1279 | const SkIRect& rect = SkIRect::EmptyIRect(); |
| 1280 | SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1281 | #StdOut |
| 1282 | rect: 0, 0, 0, 0 |
| 1283 | ## |
| 1284 | ## |
| 1285 | |
| 1286 | #SeeAlso MakeEmpty |
Cary Clark | 69261ba | 2018-10-11 15:28:31 -0400 | [diff] [blame] | 1287 | |
| 1288 | ## |
| 1289 | |
| 1290 | #Struct SkIRect ## |
| 1291 | |
| 1292 | #Topic IRect ## |