blob: 43ec20bb54fbef04365bdd4595bc137fdb720b42 [file] [log] [blame]
Cary Clark0c5f5462017-12-15 11:21:51 -05001#Topic IRect
Cary Clark137b8742018-05-30 09:21:49 -04002#Alias IRects ##
3#Alias IRect_Reference ##
Cary Clark0c5f5462017-12-15 11:21:51 -05004
5#Struct SkIRect
6
Cary Clark61313f32018-10-08 14:57:48 -04007#Code
8#Populate
9##
10
Cary Clark682c58d2018-05-16 07:07:07 -040011SkIRect holds four 32-bit integer coordinates describing the upper and
12lower bounds of a rectangle. SkIRect may be created from outer bounds or
Cary Clark0c5f5462017-12-15 11:21:51 -050013from position, width, and height. SkIRect describes an area; if its right
14is less than or equal to its left, or if its bottom is less than or equal to
Cary Clark682c58d2018-05-16 07:07:07 -040015its top, it is considered empty.
16
Cary Clark61313f32018-10-08 14:57:48 -040017#Subtopic Members
Cary Clark0c5f5462017-12-15 11:21:51 -050018
19#Member int32_t fLeft
Cary Clark08895c42018-02-01 09:37:32 -050020#Line # smaller x-axis bounds ##
Cary Clark0c5f5462017-12-15 11:21:51 -050021May contain any value. The smaller of the horizontal values when sorted.
22When equal to or greater than fRight, IRect is empty.
23##
24
25#Member int32_t fTop
Cary Clark08895c42018-02-01 09:37:32 -050026#Line # smaller y-axis bounds ##
Cary Clark0c5f5462017-12-15 11:21:51 -050027May contain any value. The smaller of the horizontal values when sorted.
28When equal to or greater than fBottom, IRect is empty.
29##
30
31#Member int32_t fRight
Cary Clark08895c42018-02-01 09:37:32 -050032#Line # larger x-axis bounds ##
Cary Clark0c5f5462017-12-15 11:21:51 -050033May contain any value. The larger of the vertical values when sorted.
34When equal to or less than fLeft, IRect is empty.
35##
36
37#Member int32_t fBottom
Cary Clark08895c42018-02-01 09:37:32 -050038#Line # larger y-axis bounds ##
Cary Clark0c5f5462017-12-15 11:21:51 -050039May contain any value. The larger of the vertical values when sorted.
40When equal to or less than fTop, IRect is empty.
41##
42
Cary Clark61313f32018-10-08 14:57:48 -040043#Subtopic Members ##
Cary Clark2dc84ad2018-01-26 12:56:22 -050044
Cary Clark61313f32018-10-08 14:57:48 -040045#Subtopic Constructors
Cary Clark2dc84ad2018-01-26 12:56:22 -050046
Cary Clark0c5f5462017-12-15 11:21:51 -050047# ------------------------------------------------------------------------------
48
Cary Clark61313f32018-10-08 14:57:48 -040049#Method static constexpr SkIRect MakeEmpty()
Cary Clark0c5f5462017-12-15 11:21:51 -050050
Cary Clark61313f32018-10-08 14:57:48 -040051#In Constructors
Cary Clarkab2621d2018-01-30 10:08:57 -050052#Line # returns bounds of (0, 0, 0, 0) ##
Cary Clark0c5f5462017-12-15 11:21:51 -050053Returns constructed IRect set to (0, 0, 0, 0).
54Many other rectangles are empty; if left is equal to or greater than right,
55or if top is equal to or greater than bottom. Setting all members to zero
56is 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
70MakeEmpty isEmpty: true
71offset rect isEmpty: true
72inset rect isEmpty: true
73outset rect isEmpty: false
74##
75##
76
Mike Reed274218e2018-01-08 15:05:02 -050077#SeeAlso EmptyIRect isEmpty setEmpty SkRect::MakeEmpty
Cary Clark0c5f5462017-12-15 11:21:51 -050078
79##
80
81# ------------------------------------------------------------------------------
82
Cary Clark61313f32018-10-08 14:57:48 -040083#Method static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Cary Clark0c5f5462017-12-15 11:21:51 -050084
Cary Clark61313f32018-10-08 14:57:48 -040085#In Constructors
Cary Clarkab2621d2018-01-30 10:08:57 -050086#Line # constructs from int input returning (0, 0, width, height) ##
Cary Clark0c5f5462017-12-15 11:21:51 -050087Returns constructed IRect set to (0, 0, w, h). Does not validate input; w or h
88may be negative.
89
Cary Clark2dc84ad2018-01-26 12:56:22 -050090#Param w width of constructed IRect ##
91#Param h height of constructed IRect ##
Cary Clark0c5f5462017-12-15 11:21:51 -050092
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
103all equal
104##
105##
106
107#SeeAlso MakeSize MakeXYWH SkRect::MakeWH SkRect::MakeIWH
108
109##
110
111# ------------------------------------------------------------------------------
112
Cary Clark61313f32018-10-08 14:57:48 -0400113#Method static constexpr SkIRect MakeSize(const SkISize& size)
Cary Clark0c5f5462017-12-15 11:21:51 -0500114
Cary Clark61313f32018-10-08 14:57:48 -0400115#In Constructors
Cary Clarkab2621d2018-01-30 10:08:57 -0500116#Line # constructs from ISize returning (0, 0, width, height) ##
Cary Clark682c58d2018-05-16 07:07:07 -0400117Returns constructed IRect set to (0, 0, size.width(), size.height()).
Cary Clark0c5f5462017-12-15 11:21:51 -0500118Does not validate input; size.width() or size.height() may be negative.
119
Cary Clark2dc84ad2018-01-26 12:56:22 -0500120#Param size values for IRect width and height ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500121
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
131round width: 26 height: 36
132floor width: 25 height: 35
133##
134##
135
Cary Clark682c58d2018-05-16 07:07:07 -0400136#SeeAlso MakeWH MakeXYWH SkRect::Make SkRect::MakeIWH
Cary Clark0c5f5462017-12-15 11:21:51 -0500137
138##
139
140# ------------------------------------------------------------------------------
141
Cary Clark61313f32018-10-08 14:57:48 -0400142#Method static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
Cary Clark0c5f5462017-12-15 11:21:51 -0500143
Cary Clark61313f32018-10-08 14:57:48 -0400144#In Constructors
Cary Clarkab2621d2018-01-30 10:08:57 -0500145#Line # constructs from int left, top, right, bottom ##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500146Returns constructed IRect set to (l, t, r, b). Does not sort input; IRect may
Cary Clark0c5f5462017-12-15 11:21:51 -0500147result 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
164rect: 5, 35, 15, 25 isEmpty: true
165rect: 5, 25, 15, 35 isEmpty: false
166##
167##
168
169#SeeAlso MakeXYWH SkRect::MakeLTRB
170
171##
172
173# ------------------------------------------------------------------------------
174
Cary Clark61313f32018-10-08 14:57:48 -0400175#Method static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Cary Clark0c5f5462017-12-15 11:21:51 -0500176
Cary Clark61313f32018-10-08 14:57:48 -0400177#In Constructors
Cary Clarkab2621d2018-01-30 10:08:57 -0500178#Line # constructs from int input returning (x, y, width, height) ##
Cary Clark2be81cf2018-09-13 12:04:30 -0400179Returns constructed IRect set to: #Formula # (x, y, x + w, y + h) ##.
180Does not validate input; w or h may be negative.
Cary Clark0c5f5462017-12-15 11:21:51 -0500181
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
197rect: 5, 35, -10, 60 isEmpty: true
198rect: -10, 35, 5, 60 isEmpty: false
199##
200##
201
202#SeeAlso MakeLTRB SkRect::MakeXYWH
203
204##
205
Cary Clark61313f32018-10-08 14:57:48 -0400206#Subtopic Constructors ##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500207
Cary Clark4855f782018-02-06 09:41:53 -0500208#Subtopic Property
209#Line # member values, center, validity ##
Cary Clark4855f782018-02-06 09:41:53 -0500210##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500211
Cary Clark0c5f5462017-12-15 11:21:51 -0500212# ------------------------------------------------------------------------------
213
Cary Clark6def7202018-01-04 08:13:35 -0500214#Method int32_t left() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500215
Cary Clark4855f782018-02-06 09:41:53 -0500216#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500217#Line # returns smaller bounds in x, if sorted ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500218Returns left edge of IRect, if sorted.
219Call 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
229unsorted.fLeft: 15 unsorted.left(): 15
230sorted.fLeft: 10 sorted.left(): 10
231##
232##
233
234#SeeAlso fLeft x() SkRect::left()
235
236##
237
238# ------------------------------------------------------------------------------
239
Cary Clark6def7202018-01-04 08:13:35 -0500240#Method int32_t top() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500241
Cary Clark4855f782018-02-06 09:41:53 -0500242#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500243#Line # returns smaller bounds in y, if sorted ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500244Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
245and 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
255unsorted.fTop: 25 unsorted.top(): 25
256sorted.fTop: 5 sorted.top(): 5
257##
258##
259
260#SeeAlso fTop y() SkRect::top()
261
262##
263
264# ------------------------------------------------------------------------------
265
Cary Clark6def7202018-01-04 08:13:35 -0500266#Method int32_t right() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500267
Cary Clark4855f782018-02-06 09:41:53 -0500268#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500269#Line # returns larger bounds in x, if sorted ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500270Returns right edge of IRect, if sorted.
271Call 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
281unsorted.fRight: 10 unsorted.right(): 10
282sorted.fRight: 15 sorted.right(): 15
283##
284##
285
286#SeeAlso fRight SkRect::right()
287
288##
289
290# ------------------------------------------------------------------------------
291
Cary Clark6def7202018-01-04 08:13:35 -0500292#Method int32_t bottom() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500293
Cary Clark4855f782018-02-06 09:41:53 -0500294#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500295#Line # returns larger bounds in y, if sorted ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500296Returns bottom edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
297and 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
307unsorted.fBottom: 5 unsorted.bottom(): 5
308sorted.fBottom: 25 sorted.bottom(): 25
309##
310##
311
312#SeeAlso fBottom SkRect::bottom()
313
314##
315
316# ------------------------------------------------------------------------------
317
Cary Clark6def7202018-01-04 08:13:35 -0500318#Method int32_t x() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500319
Cary Clark4855f782018-02-06 09:41:53 -0500320#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500321#Line # returns bounds left ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500322Returns left edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
323and 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
333unsorted.fLeft: 15 unsorted.x(): 15
334sorted.fLeft: 10 sorted.x(): 10
335##
336##
337
338#SeeAlso fLeft left() y() SkRect::x()
339
340##
341
342# ------------------------------------------------------------------------------
343
Cary Clark6def7202018-01-04 08:13:35 -0500344#Method int32_t y() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500345
Cary Clark4855f782018-02-06 09:41:53 -0500346#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500347#Line # returns bounds top ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500348Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
349and 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
359unsorted.fTop: 25 unsorted.y(): 25
360sorted.fTop: 5 sorted.y(): 5
361##
362##
363
364#SeeAlso fTop top() x() SkRect::y()
365
366##
367
368# ------------------------------------------------------------------------------
369
Cary Clark6def7202018-01-04 08:13:35 -0500370#Method int32_t width() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500371
Cary Clark4855f782018-02-06 09:41:53 -0500372#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500373#Line # returns span in x ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500374Returns span on the x-axis. This does not check if IRect is sorted, or if
375result 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
385unsorted width: -5
386large width: -5
387##
388##
389
Mike Reeda766ca92018-01-09 11:31:53 -0500390#SeeAlso height() width64() height64() SkRect::width()
391
392##
393
394# ------------------------------------------------------------------------------
395
396#Method int64_t width64() const
397
Cary Clark4855f782018-02-06 09:41:53 -0500398#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500399#Line # returns span in y as int64_t ##
Mike Reeda766ca92018-01-09 11:31:53 -0500400Returns span on the x-axis. This does not check if IRect is sorted, so the
401result may be negative. This is safer than calling width() since width() might
402overflow in its calculation.
403
404#Return fRight minus fLeft cast to int64_t ##
405
Cary Clark186d08f2018-04-03 08:43:27 -0400406#Example
Mike Reeda766ca92018-01-09 11:31:53 -0500407SkIRect large = { -2147483647, 1, 2147483644, 2 };
Cary Clark186d08f2018-04-03 08:43:27 -0400408SkDebugf("width: %d width64: %lld\n", large.width(), large.width64());
Mike Reeda766ca92018-01-09 11:31:53 -0500409#StdOut
410width: -5 width64: 4294967291
411##
412##
413
414#SeeAlso width() height() height64() SkRect::width()
Cary Clark0c5f5462017-12-15 11:21:51 -0500415
416##
417
418# ------------------------------------------------------------------------------
419
Cary Clark6def7202018-01-04 08:13:35 -0500420#Method int32_t height() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500421
Cary Clark4855f782018-02-06 09:41:53 -0500422#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500423#Line # returns span in y ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500424Returns span on the y-axis. This does not check if IRect is sorted, or if
425result 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
435unsorted height: -5
436large height: -5
437##
438##
439
440#SeeAlso width() SkRect::height()
441
442##
443
444# ------------------------------------------------------------------------------
445
Mike Reeda766ca92018-01-09 11:31:53 -0500446#Method int64_t height64() const
447
Cary Clark4855f782018-02-06 09:41:53 -0500448#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500449#Line # returns span in y as int64_t ##
Mike Reeda766ca92018-01-09 11:31:53 -0500450Returns span on the y-axis. This does not check if IRect is sorted, so the
451result may be negative. This is safer than calling height() since height() might
452overflow in its calculation.
453
454#Return fBottom minus fTop cast to int64_t ##
455
Cary Clark186d08f2018-04-03 08:43:27 -0400456#Example
Mike Reeda766ca92018-01-09 11:31:53 -0500457SkIRect large = { 1, -2147483647, 2, 2147483644 };
458SkDebugf("height: %d height64: %lld\n", large.height(), large.height64());
459#StdOut
460height: -5 height64: 4294967291
461##
462##
463
464#SeeAlso width() height() width64() SkRect::height()
465
466##
467
468# ------------------------------------------------------------------------------
469
Cary Clark0c5f5462017-12-15 11:21:51 -0500470#Method SkISize size() const
471
Cary Clark4855f782018-02-06 09:41:53 -0500472#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500473#Line # returns ISize (width, height) ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500474Returns spans on the x-axis and y-axis. This does not check if IRect is sorted,
475or 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
493original 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 Clark0c5f5462017-12-15 11:21:51 -0500505#Method bool isEmpty() const
506
Cary Clark4855f782018-02-06 09:41:53 -0500507#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500508#Line # returns true if width or height are zero or negative or they exceed int32_t ##
Cary Clark61313f32018-10-08 14:57:48 -0400509Returns true if width() or height() are zero or negative or they exceed int32_t.
Cary Clark0c5f5462017-12-15 11:21:51 -0500510
Cary Clark61313f32018-10-08 14:57:48 -0400511#Return true if width() or height() are not positive and valid ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500512
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
523rect: {20, 40, 10, 50} is empty
524sorted: {10, 40, 20, 50} is not empty
525rect: {20, 40, 20, 50} is empty
526sorted: {20, 40, 20, 50} is empty
527##
528##
529
530#SeeAlso EmptyIRect MakeEmpty sort SkRect::isEmpty
531
532##
533
534# ------------------------------------------------------------------------------
535
Mike Reedd2849492018-01-10 14:31:18 -0500536#Method bool isEmpty64() const
537
Cary Clark4855f782018-02-06 09:41:53 -0500538#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500539#Line # returns true if width or height are zero or negative ##
Mike Reedd2849492018-01-10 14:31:18 -0500540Returns true if fLeft is equal to or greater than fRight, or if fTop is equal
541to or greater than fBottom. Call sort() to reverse rectangles with negative
542width64() or height64().
543
Cary Clark61313f32018-10-08 14:57:48 -0400544#Return true if width64() or height64() are not positive ##
Mike Reedd2849492018-01-10 14:31:18 -0500545
Cary Clark186d08f2018-04-03 08:43:27 -0400546#Example
Mike Reedd2849492018-01-10 14:31:18 -0500547SkIRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}};
548for (auto rect : tests) {
Cary Clark186d08f2018-04-03 08:43:27 -0400549 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 Reedd2849492018-01-10 14:31:18 -0500554}
555#StdOut
556rect: {20, 40, 10, 50} is empty
557sorted: {10, 40, 20, 50} is not empty
558rect: {20, 40, 20, 50} is empty
559sorted: {20, 40, 20, 50} is empty
560##
561##
562
563#SeeAlso EmptyIRect MakeEmpty sort SkRect::isEmpty
564
565##
566
Cary Clark61313f32018-10-08 14:57:48 -0400567#Subtopic Operators
Cary Clark2dc84ad2018-01-26 12:56:22 -0500568
Mike Reedd2849492018-01-10 14:31:18 -0500569# ------------------------------------------------------------------------------
570
Cary Clark0c5f5462017-12-15 11:21:51 -0500571#Method bool operator==(const SkIRect& a, const SkIRect& b)
572
Cary Clark61313f32018-10-08 14:57:48 -0400573#In Operators
Cary Clarkab2621d2018-01-30 10:08:57 -0500574#Line # returns true if members are equal ##
Cary Clark682c58d2018-05-16 07:07:07 -0400575Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are
Cary Clark0c5f5462017-12-15 11:21:51 -0500576identical 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
588test == 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 Clark61313f32018-10-08 14:57:48 -0400600#In Operators
Cary Clarkab2621d2018-01-30 10:08:57 -0500601#Line # returns true if members are unequal ##
Cary Clark682c58d2018-05-16 07:07:07 -0400602Returns true if any member in a: fLeft, fTop, fRight, and fBottom; is not
Cary Clark0c5f5462017-12-15 11:21:51 -0500603identical 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
615test != sorted
616##
617##
618
619#SeeAlso operator==(const SkIRect& a, const SkIRect& b)
620
621##
622
Cary Clark61313f32018-10-08 14:57:48 -0400623#Subtopic Operators ##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500624
Cary Clark0c5f5462017-12-15 11:21:51 -0500625# ------------------------------------------------------------------------------
626
Cary Clark78de7512018-02-07 07:27:09 -0500627#Subtopic Set
628#Line # replaces all values ##
Cary Clark78de7512018-02-07 07:27:09 -0500629##
Cary Clark0c5f5462017-12-15 11:21:51 -0500630
631#Method void setEmpty()
632
Cary Clark4855f782018-02-06 09:41:53 -0500633#In Set
Cary Clarkab2621d2018-01-30 10:08:57 -0500634#Line # sets to (0, 0, 0, 0) ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500635Sets IRect to (0, 0, 0, 0).
636
637Many other rectangles are empty; if left is equal to or greater than right,
638or if top is equal to or greater than bottom. Setting all members to zero
639is 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
649rect: {3, 4, 1, 2} is empty
650rect: {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 Clark4855f782018-02-06 09:41:53 -0500662#In Set
Cary Clarkab2621d2018-01-30 10:08:57 -0500663#Line # sets to (left, top, right, bottom) ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500664Sets IRect to (left, top, right, bottom).
665left and right are not sorted; left is not necessarily less than right.
666top 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
680rect1: {3, 4, 1, 2}
681rect2: {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 Clark4855f782018-02-06 09:41:53 -0500693#In Set
Cary Clarkab2621d2018-01-30 10:08:57 -0500694#Line # sets to SkScalar input (left, top, right, bottom) ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500695Sets IRect to (left, top, right, bottom).
696left and right are not sorted; left is not necessarily less than right.
697top 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
711rect1: {3, 4, 1, 2}
712rect2: {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 Clark4855f782018-02-06 09:41:53 -0500724#In Set
Cary Clarkab2621d2018-01-30 10:08:57 -0500725#Line # sets to (x, y, width, height) ##
Cary Clark2be81cf2018-09-13 12:04:30 -0400726Sets IRect to: #Formula # (x, y, x + width, y + height) ##.
727Does not validate input; width or height may be negative.
Cary Clark0c5f5462017-12-15 11:21:51 -0500728
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
743rect: 5, 35, -10, 60 isEmpty: true
744rect: -10, 35, 5, 60 isEmpty: false
745##
746##
747
748#SeeAlso MakeXYWH setLTRB set SkRect::setXYWH
749
750##
751
Cary Clark2dc84ad2018-01-26 12:56:22 -0500752#Subtopic Inset_Outset_Offset
Cary Clark08895c42018-02-01 09:37:32 -0500753#Line # moves sides ##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500754
Cary Clark0c5f5462017-12-15 11:21:51 -0500755# ------------------------------------------------------------------------------
756
Cary Clark0c5f5462017-12-15 11:21:51 -0500757#Method SkIRect makeOffset(int32_t dx, int32_t dy) const
758
Cary Clarkab2621d2018-01-30 10:08:57 -0500759#In Inset_Outset_Offset
760#Line # constructs from translated sides ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500761Returns IRect offset by (dx, dy).
762
763If dx is negative, IRect returned is moved to the left.
764If dx is positive, IRect returned is moved to the right.
765If dy is negative, IRect returned is moved upward.
Cary Clark682c58d2018-05-16 07:07:07 -0400766If dy is positive, IRect returned is moved downward.
Cary Clark0c5f5462017-12-15 11:21:51 -0500767
768#Param dx offset added to fLeft and fRight ##
769#Param dy offset added to fTop and fBottom ##
770
Cary Clark5538c132018-06-14 12:28:14 -0400771#Return IRect offset by dx and dy, with original width and height ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500772
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
781rect: 10, 50, 20, 60 isEmpty: false
782rect: 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 Clarkab2621d2018-01-30 10:08:57 -0500794#In Inset_Outset_Offset
795#Line # constructs from sides moved symmetrically about the center ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500796Returns IRect, inset by (dx, dy).
797
798If dx is negative, IRect returned is wider.
799If dx is positive, IRect returned is narrower.
800If dy is negative, IRect returned is taller.
Cary Clark682c58d2018-05-16 07:07:07 -0400801If dy is positive, IRect returned is shorter.
Cary Clark0c5f5462017-12-15 11:21:51 -0500802
803#Param dx offset added to fLeft and subtracted from fRight ##
804#Param dy offset added to fTop and subtracted from fBottom ##
805
Cary Clark2dc84ad2018-01-26 12:56:22 -0500806#Return IRect inset symmetrically left and right, top and bottom ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500807
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
816rect: 10, 50, 20, 60 isEmpty: false
817rect: 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 Clarkab2621d2018-01-30 10:08:57 -0500829#In Inset_Outset_Offset
830#Line # constructs from sides moved symmetrically about the center ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500831Returns IRect, outset by (dx, dy).
832
833If dx is negative, IRect returned is narrower.
834If dx is positive, IRect returned is wider.
835If dy is negative, IRect returned is shorter.
Cary Clark682c58d2018-05-16 07:07:07 -0400836If dy is positive, IRect returned is taller.
Cary Clark0c5f5462017-12-15 11:21:51 -0500837
838#Param dx offset subtracted to fLeft and added from fRight ##
839#Param dy offset subtracted to fTop and added from fBottom ##
840
Cary Clark2dc84ad2018-01-26 12:56:22 -0500841#Return IRect outset symmetrically left and right, top and bottom ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500842
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
851rect: 10, 50, 20, 60 isEmpty: false
852rect: -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 Clarkab2621d2018-01-30 10:08:57 -0500864#In Inset_Outset_Offset
865#Line # translates sides without changing width and height ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500866Offsets IRect by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom.
867
868If dx is negative, moves IRect returned to the left.
869If dx is positive, moves IRect returned to the right.
870If dy is negative, moves IRect returned upward.
Cary Clark682c58d2018-05-16 07:07:07 -0400871If dy is positive, moves IRect returned downward.
Cary Clark0c5f5462017-12-15 11:21:51 -0500872
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
881rect: 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 Clarkab2621d2018-01-30 10:08:57 -0500893#In Inset_Outset_Offset
Cary Clark0c5f5462017-12-15 11:21:51 -0500894Offsets IRect by adding delta.fX to fLeft, fRight; and by adding delta.fY to
895fTop, fBottom.
896
897If delta.fX is negative, moves IRect returned to the left.
898If delta.fX is positive, moves IRect returned to the right.
899If delta.fY is negative, moves IRect returned upward.
Cary Clark682c58d2018-05-16 07:07:07 -0400900If delta.fY is positive, moves IRect returned downward.
Cary Clark0c5f5462017-12-15 11:21:51 -0500901
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
909rect: 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 Clarkab2621d2018-01-30 10:08:57 -0500921#In Inset_Outset_Offset
922#Line # translates to (x, y) without changing width and height ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500923Offsets IRect so that fLeft equals newX, and fTop equals newY. width and height
924are 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
934rect: 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 Clarkab2621d2018-01-30 10:08:57 -0500946#In Inset_Outset_Offset
947#Line # moves the sides symmetrically about the center ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500948Insets IRect by (dx,dy).
949
950If dx is positive, makes IRect narrower.
951If dx is negative, makes IRect wider.
952If dy is positive, makes IRect shorter.
953If 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
963rect: 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 Clarkab2621d2018-01-30 10:08:57 -0500975#In Inset_Outset_Offset
976#Line # moves the sides symmetrically about the center ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500977Outsets IRect by (dx, dy).
978
Cary Clark2dc84ad2018-01-26 12:56:22 -0500979If dx is positive, makes IRect wider.
980If dx is negative, makes IRect narrower.
981If dy is positive, makes IRect taller.
982If dy is negative, makes IRect shorter.
Cary Clark0c5f5462017-12-15 11:21:51 -0500983
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
992rect: 5, 1, 55, 86
993##
994##
995
996#SeeAlso inset makeOutset SkRect::outset
997
998##
999
Cary Clark2dc84ad2018-01-26 12:56:22 -05001000#Subtopic Inset_Outset_Offset ##
1001
1002#Subtopic Intersection
Cary Clark682c58d2018-05-16 07:07:07 -04001003#Line # sets to shared bounds ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001004
Cary Clark682c58d2018-05-16 07:07:07 -04001005IRects intersect when they enclose a common area. To intersect, each of the pair
Cary Clark2dc84ad2018-01-26 12:56:22 -05001006must describe area; fLeft is less than fRight, and fTop is less than fBottom;
1007empty() returns false. The intersection of IRect pair can be described by:
Cary Clark2be81cf2018-09-13 12:04:30 -04001008#Formula # (max(a.fLeft, b.fLeft), max(a.fTop, b.fTop),
1009 min(a.fRight, b.fRight), min(a.fBottom, b.fBottom)) ##.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001010
1011The intersection is only meaningful if the resulting IRect is not empty and
1012describes an area: fLeft is less than fRight, and fTop is less than fBottom.
1013
Cary Clark0c5f5462017-12-15 11:21:51 -05001014# ------------------------------------------------------------------------------
1015
Robert Phillips8f8d4812018-05-18 10:19:05 -04001016#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 Clarkdbc90e42018-05-18 11:57:17 -04001020Adjusts IRect by adding dL to fLeft, dT to fTop, dR to fRight, and dB to fBottom.
Robert Phillips8f8d4812018-05-18 10:19:05 -04001021
1022If dL is positive, narrows IRect on the left. If negative, widens it on the left.
1023If dT is positive, shrinks IRect on the top. If negative, lengthens it on the top.
1024If dR is positive, narrows IRect on the right. If negative, widens it on the right.
1025If dB is positive, shrinks IRect on the bottom. If negative, lengthens it on the bottom.
1026
1027The resulting IRect is not checked for validity. Thus, if the resulting IRect left is
1028greater than right, the IRect will be considered empty. Call sort() after this call
1029if 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
1041rect: 10, 10, 20, 20
1042##
1043##
1044
1045#SeeAlso inset outset
1046
1047##
1048
1049# ------------------------------------------------------------------------------
1050
Cary Clark0c5f5462017-12-15 11:21:51 -05001051#Method bool contains(int32_t x, int32_t y) const
1052
Cary Clarkab2621d2018-01-30 10:08:57 -05001053#In Intersection
Cary Clark300cc5b2018-02-20 12:50:35 -05001054#Line # returns true if IPoint (x, y) is equal or inside ##
Cary Clark2be81cf2018-09-13 12:04:30 -04001055Returns true if: #Formula # fLeft <= x < fRight && fTop <= y < fBottom ##.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001056Returns false if IRect is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001057
Cary Clark2be81cf2018-09-13 12:04:30 -04001058Considers input to describe constructed IRect: #Formula # (x, y, x + 1, y + 1) ## and
Cary Clark0c5f5462017-12-15 11:21:51 -05001059returns true if constructed area is completely enclosed by IRect area.
1060
Cary Clark300cc5b2018-02-20 12:50:35 -05001061#Param x test IPoint x-coordinate ##
1062#Param y test IPoint y-coordinate ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001063
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
1075rect: (30, 50, 40, 60) contains (30, 50)
1076rect: (30, 50, 40, 60) does not contain (40, 50)
1077rect: (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 Clarkab2621d2018-01-30 10:08:57 -05001089#In Intersection
Cary Clark2dc84ad2018-01-26 12:56:22 -05001090Constructs IRect to intersect from (left, top, right, bottom). Does not sort
Cary Clark0c5f5462017-12-15 11:21:51 -05001091construction.
1092
Cary Clark2dc84ad2018-01-26 12:56:22 -05001093Returns true if IRect contains construction.
1094Returns false if IRect is empty or construction is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001095
Cary Clark5538c132018-06-14 12:28:14 -04001096#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 Clark0c5f5462017-12-15 11:21:51 -05001100
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
1115rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1116rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1117rect: (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 Clarkab2621d2018-01-30 10:08:57 -05001129#In Intersection
Cary Clark2dc84ad2018-01-26 12:56:22 -05001130Returns true if IRect contains r.
1131Returns false if IRect is empty or r is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001132
Cary Clark2dc84ad2018-01-26 12:56:22 -05001133IRect contains r when IRect area completely includes r area.
Cary Clark0c5f5462017-12-15 11:21:51 -05001134
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
1149rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1150rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1151rect: (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 Clarkab2621d2018-01-30 10:08:57 -05001163#In Intersection
Cary Clark2dc84ad2018-01-26 12:56:22 -05001164Returns true if IRect contains r.
1165Returns false if IRect is empty or r is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001166
Cary Clark2dc84ad2018-01-26 12:56:22 -05001167IRect contains r when IRect area completely includes r area.
Cary Clark0c5f5462017-12-15 11:21:51 -05001168
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
1183rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1184rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1185rect: (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 Clarkab2621d2018-01-30 10:08:57 -05001197#In Intersection
Cary Clark300cc5b2018-02-20 12:50:35 -05001198#Line # returns true if contains unsorted IRect ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001199
1200Constructs IRect from (left, top, right, bottom). Does not sort
1201construction.
1202
Cary Clark2dc84ad2018-01-26 12:56:22 -05001203Returns true if IRect contains construction.
Cary Clark0c5f5462017-12-15 11:21:51 -05001204Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined.
1205
Cary Clark2dc84ad2018-01-26 12:56:22 -05001206Return is undefined if IRect is empty or construction is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001207
Cary Clark5538c132018-06-14 12:28:14 -04001208#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 Clark0c5f5462017-12-15 11:21:51 -05001212
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
1227rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1228rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1229rect: (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 Clarkab2621d2018-01-30 10:08:57 -05001241#In Intersection
Cary Clark2dc84ad2018-01-26 12:56:22 -05001242Returns true if IRect contains construction.
Cary Clark0c5f5462017-12-15 11:21:51 -05001243Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined.
1244
Cary Clark2dc84ad2018-01-26 12:56:22 -05001245Return is undefined if IRect is empty or construction is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001246
Cary Clark2dc84ad2018-01-26 12:56:22 -05001247#Param r IRect contained ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001248
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
1261rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1262rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1263rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1264##
1265##
1266
1267#SeeAlso contains SkRect::contains
1268
1269##
1270
Cary Clark0c5f5462017-12-15 11:21:51 -05001271# ------------------------------------------------------------------------------
1272
1273#Method bool intersect(const SkIRect& r)
1274
Cary Clarkab2621d2018-01-30 10:08:57 -05001275#In Intersection
1276#Line # sets to shared area; returns true if not empty ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001277Returns true if IRect intersects r, and sets IRect to intersection.
1278Returns false if IRect does not intersect r, and leaves IRect unchanged.
1279
1280Returns false if either r or IRect is empty, leaving IRect unchanged.
1281
1282#Param r limit of result ##
1283
Cary Clark2dc84ad2018-01-26 12:56:22 -05001284#Return true if r and IRect have area in common ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001285
1286#Example
1287#Description
1288Two SkDebugf calls are required. If the calls are combined, their arguments
1289may not be evaluated in left to right order: the printed intersection may
1290be 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 Clark682c58d2018-05-16 07:07:07 -04001295 SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
Cary Clark0c5f5462017-12-15 11:21:51 -05001296 leftRect.right(), leftRect.bottom());
1297#StdOut
1298 intersection: 30, 60, 50, 80
Cary Clark682c58d2018-05-16 07:07:07 -04001299##
Cary Clark0c5f5462017-12-15 11:21:51 -05001300##
1301
1302#SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect
1303
1304##
1305
1306# ------------------------------------------------------------------------------
1307
Cary Clark61313f32018-10-08 14:57:48 -04001308#Method bool intersect(const SkIRect& a, const SkIRect& b)
Cary Clark0c5f5462017-12-15 11:21:51 -05001309
Cary Clarkab2621d2018-01-30 10:08:57 -05001310#In Intersection
Cary Clark0c5f5462017-12-15 11:21:51 -05001311Returns true if a intersects b, and sets IRect to intersection.
1312Returns false if a does not intersect b, and leaves IRect unchanged.
1313
1314Returns 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 Clark682c58d2018-05-16 07:07:07 -04001328##
Cary Clark0c5f5462017-12-15 11:21:51 -05001329##
1330
1331#SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect
1332
1333##
1334
1335# ------------------------------------------------------------------------------
1336
Cary Clark61313f32018-10-08 14:57:48 -04001337#Method bool intersectNoEmptyCheck(const SkIRect& a, const SkIRect& b)
Cary Clark0c5f5462017-12-15 11:21:51 -05001338
Cary Clarkab2621d2018-01-30 10:08:57 -05001339#In Intersection
1340#Line # sets to shared area; returns true if not empty skips empty check ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001341Returns true if a intersects b, and sets IRect to intersection.
1342Returns false if a does not intersect b, and leaves IRect unchanged.
1343
1344Asserts 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 Clark681287e2018-03-16 11:34:15 -04001353 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 Clark0c5f5462017-12-15 11:21:51 -05001357#StdOut
1358 intersection: 30, 60, 50, 80
Cary Clark682c58d2018-05-16 07:07:07 -04001359##
Cary Clark0c5f5462017-12-15 11:21:51 -05001360##
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 Clarkab2621d2018-01-30 10:08:57 -05001370#In Intersection
Cary Clark0c5f5462017-12-15 11:21:51 -05001371Constructs IRect to intersect from (left, top, right, bottom). Does not sort
1372construction.
1373
1374Returns true if IRect intersects construction, and sets IRect to intersection.
1375Returns false if IRect does not intersect construction, and leaves IRect unchanged.
1376
1377Returns false if either construction or IRect is empty, leaving IRect unchanged.
1378
Cary Clark5538c132018-06-14 12:28:14 -04001379#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 Clark0c5f5462017-12-15 11:21:51 -05001383
1384#Return true if construction and IRect have area in common ##
1385
1386#Example
1387#Description
1388Two SkDebugf calls are required. If the calls are combined, their arguments
1389may not be evaluated in left to right order: the printed intersection may
1390be 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 Clark682c58d2018-05-16 07:07:07 -04001394 SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
Cary Clark0c5f5462017-12-15 11:21:51 -05001395 leftRect.right(), leftRect.bottom());
1396#StdOut
1397 intersection: 30, 60, 50, 80
Cary Clark682c58d2018-05-16 07:07:07 -04001398##
Cary Clark0c5f5462017-12-15 11:21:51 -05001399##
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 Clarkab2621d2018-01-30 10:08:57 -05001409#In Intersection
1410#Line # returns true if areas overlap ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001411Returns true if a intersects b.
1412Returns 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 Clark682c58d2018-05-16 07:07:07 -04001423##
Cary Clark0c5f5462017-12-15 11:21:51 -05001424##
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 Clarkab2621d2018-01-30 10:08:57 -05001434#In Intersection
1435#Line # returns true if areas overlap skips empty check ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001436Returns true if a intersects b.
1437Asserts 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 Clark682c58d2018-05-16 07:07:07 -04001449##
Cary Clark0c5f5462017-12-15 11:21:51 -05001450##
1451
1452#SeeAlso Intersects intersect SkRect::intersect
1453
1454##
1455
Cary Clark2dc84ad2018-01-26 12:56:22 -05001456#Subtopic Intersection ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001457
1458# ------------------------------------------------------------------------------
1459
Cary Clark4855f782018-02-06 09:41:53 -05001460#Subtopic Join
Cary Clark682c58d2018-05-16 07:07:07 -04001461#Line # sets to union of bounds ##
Cary Clark4855f782018-02-06 09:41:53 -05001462##
1463
Cary Clark0c5f5462017-12-15 11:21:51 -05001464#Method void join(int32_t left, int32_t top, int32_t right, int32_t bottom)
1465
Cary Clark4855f782018-02-06 09:41:53 -05001466#In Join
Cary Clarkab2621d2018-01-30 10:08:57 -05001467#Line # sets to union of bounds ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001468Constructs IRect to intersect from (left, top, right, bottom). Does not sort
Cary Clark0c5f5462017-12-15 11:21:51 -05001469construction.
1470
Cary Clark2dc84ad2018-01-26 12:56:22 -05001471Sets IRect to the union of itself and the construction.
Cary Clark0c5f5462017-12-15 11:21:51 -05001472
Cary Clark2dc84ad2018-01-26 12:56:22 -05001473Has no effect if construction is empty. Otherwise, if IRect is empty, sets
1474IRect to construction.
Cary Clark0c5f5462017-12-15 11:21:51 -05001475
Cary Clark5538c132018-06-14 12:28:14 -04001476#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 Clark0c5f5462017-12-15 11:21:51 -05001480
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 Clark682c58d2018-05-16 07:07:07 -04001487##
Cary Clark0c5f5462017-12-15 11:21:51 -05001488##
1489
1490#SeeAlso set SkRect::join
1491
1492##
1493
1494# ------------------------------------------------------------------------------
1495
1496#Method void join(const SkIRect& r)
1497
Cary Clark4855f782018-02-06 09:41:53 -05001498#In Join
Cary Clark2dc84ad2018-01-26 12:56:22 -05001499Sets IRect to the union of itself and r.
Cary Clark0c5f5462017-12-15 11:21:51 -05001500
Cary Clark2dc84ad2018-01-26 12:56:22 -05001501Has no effect if r is empty. Otherwise, if IRect is empty, sets IRect to r.
Cary Clark0c5f5462017-12-15 11:21:51 -05001502
Cary Clark2dc84ad2018-01-26 12:56:22 -05001503#Param r expansion IRect ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001504
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 Clark682c58d2018-05-16 07:07:07 -04001511##
Cary Clark0c5f5462017-12-15 11:21:51 -05001512##
1513
1514#SeeAlso set SkRect::join
1515
1516##
1517
1518# ------------------------------------------------------------------------------
1519
Cary Clark4855f782018-02-06 09:41:53 -05001520#Subtopic Sorting
1521#Line # orders sides ##
Cary Clark4855f782018-02-06 09:41:53 -05001522##
1523
Cary Clark0c5f5462017-12-15 11:21:51 -05001524#Method void sort()
1525
Cary Clark4855f782018-02-06 09:41:53 -05001526#In Sorting
Cary Clarkab2621d2018-01-30 10:08:57 -05001527#Line # orders sides from smaller to larger ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001528Swaps fLeft and fRight if fLeft is greater than fRight; and swaps
1529fTop and fBottom if fTop is greater than fBottom. Result may be empty,
1530and 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
1538rect: 30, 50, 20, 10
1539sorted: 20, 10, 30, 50
1540##
1541##
1542
1543#SeeAlso makeSorted SkRect::sort
1544
1545##
1546
1547# ------------------------------------------------------------------------------
1548
1549#Method SkIRect makeSorted() const
1550
Cary Clark4855f782018-02-06 09:41:53 -05001551#In Sorting
Cary Clark61313f32018-10-08 14:57:48 -04001552#In Constructors
Cary Clark682c58d2018-05-16 07:07:07 -04001553#Line # constructs IRect, ordering sides from smaller to larger ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001554Returns IRect with fLeft and fRight swapped if fLeft is greater than fRight; and
Cary Clark0c5f5462017-12-15 11:21:51 -05001555with fTop and fBottom swapped if fTop is greater than fBottom. Result may be empty;
1556and 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
1566rect: 30, 50, 20, 10
1567sorted: 20, 10, 30, 50
1568##
1569##
1570
1571#SeeAlso sort SkRect::makeSorted
1572
1573##
1574
1575# ------------------------------------------------------------------------------
1576
Cary Clark61313f32018-10-08 14:57:48 -04001577#Method static const SkIRect& EmptyIRect()
Cary Clark0c5f5462017-12-15 11:21:51 -05001578
Cary Clark61313f32018-10-08 14:57:48 -04001579#In Constructors
Cary Clarkab2621d2018-01-30 10:08:57 -05001580#Line # returns immutable bounds of (0, 0, 0, 0) ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001581Returns 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
1589rect: 0, 0, 0, 0
1590##
1591##
1592
1593#SeeAlso MakeEmpty
1594
1595##
1596
Cary Clark61313f32018-10-08 14:57:48 -04001597#Method static SkIRect MakeLargest()
Cary Clark0c95aab2018-01-08 16:20:59 -05001598#Deprecated
1599##
1600
Cary Clark0c5f5462017-12-15 11:21:51 -05001601#Struct SkIRect ##
1602
1603#Topic IRect ##