blob: db8d4ad5016807c79d6d6badc2b044a124cdadf1 [file] [log] [blame]
Cary Clark0c5f5462017-12-15 11:21:51 -05001#Topic IRect
Cary Clark2dc84ad2018-01-26 12:56:22 -05002#Alias IRects
Cary Clark0c5f5462017-12-15 11:21:51 -05003#Alias IRect_Reference
4
5#Struct SkIRect
6
Cary Clark682c58d2018-05-16 07:07:07 -04007SkIRect holds four 32-bit integer coordinates describing the upper and
8lower bounds of a rectangle. SkIRect may be created from outer bounds or
Cary Clark0c5f5462017-12-15 11:21:51 -05009from position, width, and height. SkIRect describes an area; if its right
10is less than or equal to its left, or if its bottom is less than or equal to
Cary Clark682c58d2018-05-16 07:07:07 -040011its top, it is considered empty.
12
13#Subtopic Overview
14#Populate
15##
Cary Clark0c5f5462017-12-15 11:21:51 -050016
Cary Clark4855f782018-02-06 09:41:53 -050017#Subtopic Related_Function
Cary Clark08895c42018-02-01 09:37:32 -050018#Populate
Cary Clark0c5f5462017-12-15 11:21:51 -050019#Subtopic ##
20
Cary Clark4855f782018-02-06 09:41:53 -050021#Subtopic Member_Function
22#Populate
23#Subtopic ##
24
25#Subtopic Member
Cary Clark08895c42018-02-01 09:37:32 -050026#Populate
Cary Clark0c5f5462017-12-15 11:21:51 -050027
28#Member int32_t fLeft
Cary Clark08895c42018-02-01 09:37:32 -050029#Line # smaller x-axis bounds ##
Cary Clark0c5f5462017-12-15 11:21:51 -050030May contain any value. The smaller of the horizontal values when sorted.
31When equal to or greater than fRight, IRect is empty.
32##
33
34#Member int32_t fTop
Cary Clark08895c42018-02-01 09:37:32 -050035#Line # smaller y-axis bounds ##
Cary Clark0c5f5462017-12-15 11:21:51 -050036May contain any value. The smaller of the horizontal values when sorted.
37When equal to or greater than fBottom, IRect is empty.
38##
39
40#Member int32_t fRight
Cary Clark08895c42018-02-01 09:37:32 -050041#Line # larger x-axis bounds ##
Cary Clark0c5f5462017-12-15 11:21:51 -050042May contain any value. The larger of the vertical values when sorted.
43When equal to or less than fLeft, IRect is empty.
44##
45
46#Member int32_t fBottom
Cary Clark08895c42018-02-01 09:37:32 -050047#Line # larger y-axis bounds ##
Cary Clark0c5f5462017-12-15 11:21:51 -050048May contain any value. The larger of the vertical values when sorted.
49When equal to or less than fTop, IRect is empty.
50##
51
Cary Clark4855f782018-02-06 09:41:53 -050052#Subtopic Member ##
Cary Clark2dc84ad2018-01-26 12:56:22 -050053
Cary Clark4855f782018-02-06 09:41:53 -050054#Subtopic Constructor
Cary Clark08895c42018-02-01 09:37:32 -050055#Populate
Cary Clark2dc84ad2018-01-26 12:56:22 -050056
Cary Clark0c5f5462017-12-15 11:21:51 -050057# ------------------------------------------------------------------------------
58
59#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeEmpty()
60
Cary Clark4855f782018-02-06 09:41:53 -050061#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -050062#Line # returns bounds of (0, 0, 0, 0) ##
Cary Clark0c5f5462017-12-15 11:21:51 -050063Returns constructed IRect set to (0, 0, 0, 0).
64Many other rectangles are empty; if left is equal to or greater than right,
65or if top is equal to or greater than bottom. Setting all members to zero
66is a convenience, but does not designate a special empty rectangle.
67
68#Return bounds (0, 0, 0, 0) ##
69
70#Example
71 SkIRect rect = SkIRect::MakeEmpty();
72 SkDebugf("MakeEmpty isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
73 rect.offset(10, 10);
74 SkDebugf("offset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
75 rect.inset(10, 10);
76 SkDebugf("inset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
77 rect.outset(20, 20);
78 SkDebugf("outset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
79#StdOut
80MakeEmpty isEmpty: true
81offset rect isEmpty: true
82inset rect isEmpty: true
83outset rect isEmpty: false
84##
85##
86
Mike Reed274218e2018-01-08 15:05:02 -050087#SeeAlso EmptyIRect isEmpty setEmpty SkRect::MakeEmpty
Cary Clark0c5f5462017-12-15 11:21:51 -050088
89##
90
91# ------------------------------------------------------------------------------
92
93#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeWH(int32_t w, int32_t h)
94
Cary Clark4855f782018-02-06 09:41:53 -050095#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -050096#Line # constructs from int input returning (0, 0, width, height) ##
Cary Clark0c5f5462017-12-15 11:21:51 -050097Returns constructed IRect set to (0, 0, w, h). Does not validate input; w or h
98may be negative.
99
Cary Clark2dc84ad2018-01-26 12:56:22 -0500100#Param w width of constructed IRect ##
101#Param h height of constructed IRect ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500102
103#Return bounds (0, 0, w, h) ##
104
105#Example
106 SkIRect rect1 = SkIRect::MakeWH(25, 35);
107 SkIRect rect2 = SkIRect::MakeSize({25, 35});
108 SkIRect rect3 = SkIRect::MakeXYWH(0, 0, 25, 35);
109 SkIRect rect4 = SkIRect::MakeLTRB(0, 0, 25, 35);
110 SkDebugf("all %s" "equal\n", rect1 == rect2 && rect2 == rect3 && rect3 == rect4 ?
111 "" : "not ");
112#StdOut
113all equal
114##
115##
116
117#SeeAlso MakeSize MakeXYWH SkRect::MakeWH SkRect::MakeIWH
118
119##
120
121# ------------------------------------------------------------------------------
122
123#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeSize(const SkISize& size)
124
Cary Clark4855f782018-02-06 09:41:53 -0500125#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -0500126#Line # constructs from ISize returning (0, 0, width, height) ##
Cary Clark682c58d2018-05-16 07:07:07 -0400127Returns constructed IRect set to (0, 0, size.width(), size.height()).
Cary Clark0c5f5462017-12-15 11:21:51 -0500128Does not validate input; size.width() or size.height() may be negative.
129
Cary Clark2dc84ad2018-01-26 12:56:22 -0500130#Param size values for IRect width and height ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500131
132#Return bounds (0, 0, size.width(), size.height()) ##
133
134#Example
135 SkSize size = {25.5f, 35.5f};
136 SkIRect rect = SkIRect::MakeSize(size.toRound());
137 SkDebugf("round width: %d height: %d\n", rect.width(), rect.height());
138 rect = SkIRect::MakeSize(size.toFloor());
139 SkDebugf("floor width: %d height: %d\n", rect.width(), rect.height());
140#StdOut
141round width: 26 height: 36
142floor width: 25 height: 35
143##
144##
145
Cary Clark682c58d2018-05-16 07:07:07 -0400146#SeeAlso MakeWH MakeXYWH SkRect::Make SkRect::MakeIWH
Cary Clark0c5f5462017-12-15 11:21:51 -0500147
148##
149
150# ------------------------------------------------------------------------------
151
152#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
153
Cary Clark4855f782018-02-06 09:41:53 -0500154#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -0500155#Line # constructs from int left, top, right, bottom ##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500156Returns constructed IRect set to (l, t, r, b). Does not sort input; IRect may
Cary Clark0c5f5462017-12-15 11:21:51 -0500157result in fLeft greater than fRight, or fTop greater than fBottom.
158
159#Param l integer stored in fLeft ##
160#Param t integer stored in fTop ##
161#Param r integer stored in fRight ##
162#Param b integer stored in fBottom ##
163
164#Return bounds (l, t, r, b) ##
165
166#Example
167 SkIRect rect = SkIRect::MakeLTRB(5, 35, 15, 25);
168 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
169 rect.bottom(), rect.isEmpty() ? "true" : "false");
170 rect.sort();
171 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
172 rect.bottom(), rect.isEmpty() ? "true" : "false");
173#StdOut
174rect: 5, 35, 15, 25 isEmpty: true
175rect: 5, 25, 15, 35 isEmpty: false
176##
177##
178
179#SeeAlso MakeXYWH SkRect::MakeLTRB
180
181##
182
183# ------------------------------------------------------------------------------
184
185#Method static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
186
Cary Clark4855f782018-02-06 09:41:53 -0500187#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -0500188#Line # constructs from int input returning (x, y, width, height) ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500189Returns constructed IRect set to:
190#Formula
191(x, y, x + w, y + h)
192##
193. Does not validate input;
194w or h may be negative.
195
196#Param x stored in fLeft ##
197#Param y stored in fTop ##
198#Param w added to x and stored in fRight ##
199#Param h added to y and stored in fBottom ##
200
201#Return bounds at (x, y) with width w and height h ##
202
203#Example
204 SkIRect rect = SkIRect::MakeXYWH(5, 35, -15, 25);
205 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
206 rect.bottom(), rect.isEmpty() ? "true" : "false");
207 rect.sort();
208 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
209 rect.bottom(), rect.isEmpty() ? "true" : "false");
210#StdOut
211rect: 5, 35, -10, 60 isEmpty: true
212rect: -10, 35, 5, 60 isEmpty: false
213##
214##
215
216#SeeAlso MakeLTRB SkRect::MakeXYWH
217
218##
219
Cary Clark4855f782018-02-06 09:41:53 -0500220#Subtopic Constructor ##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500221
Cary Clark4855f782018-02-06 09:41:53 -0500222#Subtopic Property
223#Line # member values, center, validity ##
224#Populate
225##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500226
Cary Clark0c5f5462017-12-15 11:21:51 -0500227# ------------------------------------------------------------------------------
228
Cary Clark6def7202018-01-04 08:13:35 -0500229#Method int32_t left() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500230
Cary Clark4855f782018-02-06 09:41:53 -0500231#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500232#Line # returns smaller bounds in x, if sorted ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500233Returns left edge of IRect, if sorted.
234Call sort() to reverse fLeft and fRight if needed.
235
236#Return fLeft ##
237
238#Example
239 SkIRect unsorted = { 15, 5, 10, 25 };
240 SkDebugf("unsorted.fLeft: %d unsorted.left(): %d\n", unsorted.fLeft, unsorted.left());
241 SkIRect sorted = unsorted.makeSorted();
242 SkDebugf("sorted.fLeft: %d sorted.left(): %d\n", sorted.fLeft, sorted.left());
243#StdOut
244unsorted.fLeft: 15 unsorted.left(): 15
245sorted.fLeft: 10 sorted.left(): 10
246##
247##
248
249#SeeAlso fLeft x() SkRect::left()
250
251##
252
253# ------------------------------------------------------------------------------
254
Cary Clark6def7202018-01-04 08:13:35 -0500255#Method int32_t top() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500256
Cary Clark4855f782018-02-06 09:41:53 -0500257#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500258#Line # returns smaller bounds in y, if sorted ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500259Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
260and sort() to reverse fTop and fBottom if needed.
261
262#Return fTop ##
263
264#Example
265 SkIRect unsorted = { 15, 25, 10, 5 };
266 SkDebugf("unsorted.fTop: %d unsorted.top(): %d\n", unsorted.fTop, unsorted.top());
267 SkIRect sorted = unsorted.makeSorted();
268 SkDebugf("sorted.fTop: %d sorted.top(): %d\n", sorted.fTop, sorted.top());
269#StdOut
270unsorted.fTop: 25 unsorted.top(): 25
271sorted.fTop: 5 sorted.top(): 5
272##
273##
274
275#SeeAlso fTop y() SkRect::top()
276
277##
278
279# ------------------------------------------------------------------------------
280
Cary Clark6def7202018-01-04 08:13:35 -0500281#Method int32_t right() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500282
Cary Clark4855f782018-02-06 09:41:53 -0500283#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500284#Line # returns larger bounds in x, if sorted ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500285Returns right edge of IRect, if sorted.
286Call sort() to reverse fLeft and fRight if needed.
287
288#Return fRight ##
289
290#Example
291 SkIRect unsorted = { 15, 25, 10, 5 };
292 SkDebugf("unsorted.fRight: %d unsorted.right(): %d\n", unsorted.fRight, unsorted.right());
293 SkIRect sorted = unsorted.makeSorted();
294 SkDebugf("sorted.fRight: %d sorted.right(): %d\n", sorted.fRight, sorted.right());
295#StdOut
296unsorted.fRight: 10 unsorted.right(): 10
297sorted.fRight: 15 sorted.right(): 15
298##
299##
300
301#SeeAlso fRight SkRect::right()
302
303##
304
305# ------------------------------------------------------------------------------
306
Cary Clark6def7202018-01-04 08:13:35 -0500307#Method int32_t bottom() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500308
Cary Clark4855f782018-02-06 09:41:53 -0500309#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500310#Line # returns larger bounds in y, if sorted ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500311Returns bottom edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
312and sort() to reverse fTop and fBottom if needed.
313
314#Return fBottom ##
315
316#Example
317 SkIRect unsorted = { 15, 25, 10, 5 };
318 SkDebugf("unsorted.fBottom: %d unsorted.bottom(): %d\n", unsorted.fBottom, unsorted.bottom());
319 SkIRect sorted = unsorted.makeSorted();
320 SkDebugf("sorted.fBottom: %d sorted.bottom(): %d\n", sorted.fBottom, sorted.bottom());
321#StdOut
322unsorted.fBottom: 5 unsorted.bottom(): 5
323sorted.fBottom: 25 sorted.bottom(): 25
324##
325##
326
327#SeeAlso fBottom SkRect::bottom()
328
329##
330
331# ------------------------------------------------------------------------------
332
Cary Clark6def7202018-01-04 08:13:35 -0500333#Method int32_t x() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500334
Cary Clark4855f782018-02-06 09:41:53 -0500335#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500336#Line # returns bounds left ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500337Returns left edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
338and sort() to reverse fLeft and fRight if needed.
339
340#Return fLeft ##
341
342#Example
343 SkIRect unsorted = { 15, 5, 10, 25 };
344 SkDebugf("unsorted.fLeft: %d unsorted.x(): %d\n", unsorted.fLeft, unsorted.x());
345 SkIRect sorted = unsorted.makeSorted();
346 SkDebugf("sorted.fLeft: %d sorted.x(): %d\n", sorted.fLeft, sorted.x());
347#StdOut
348unsorted.fLeft: 15 unsorted.x(): 15
349sorted.fLeft: 10 sorted.x(): 10
350##
351##
352
353#SeeAlso fLeft left() y() SkRect::x()
354
355##
356
357# ------------------------------------------------------------------------------
358
Cary Clark6def7202018-01-04 08:13:35 -0500359#Method int32_t y() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500360
Cary Clark4855f782018-02-06 09:41:53 -0500361#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500362#Line # returns bounds top ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500363Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
364and sort() to reverse fTop and fBottom if needed.
365
366#Return fTop ##
367
368#Example
369 SkIRect unsorted = { 15, 25, 10, 5 };
370 SkDebugf("unsorted.fTop: %d unsorted.y(): %d\n", unsorted.fTop, unsorted.y());
371 SkIRect sorted = unsorted.makeSorted();
372 SkDebugf("sorted.fTop: %d sorted.y(): %d\n", sorted.fTop, sorted.y());
373#StdOut
374unsorted.fTop: 25 unsorted.y(): 25
375sorted.fTop: 5 sorted.y(): 5
376##
377##
378
379#SeeAlso fTop top() x() SkRect::y()
380
381##
382
383# ------------------------------------------------------------------------------
384
Cary Clark6def7202018-01-04 08:13:35 -0500385#Method int32_t width() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500386
Cary Clark4855f782018-02-06 09:41:53 -0500387#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500388#Line # returns span in x ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500389Returns span on the x-axis. This does not check if IRect is sorted, or if
390result fits in 32-bit signed integer; result may be negative.
391
392#Return fRight minus fLeft ##
393
394#Example
395 SkIRect unsorted = { 15, 25, 10, 5 };
396 SkDebugf("unsorted width: %d\n", unsorted.width());
397 SkIRect large = { -2147483647, 1, 2147483644, 2 };
398 SkDebugf("large width: %d\n", large.width());
399#StdOut
400unsorted width: -5
401large width: -5
402##
403##
404
Mike Reeda766ca92018-01-09 11:31:53 -0500405#SeeAlso height() width64() height64() SkRect::width()
406
407##
408
409# ------------------------------------------------------------------------------
410
411#Method int64_t width64() const
412
Cary Clark4855f782018-02-06 09:41:53 -0500413#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500414#Line # returns span in y as int64_t ##
Mike Reeda766ca92018-01-09 11:31:53 -0500415Returns span on the x-axis. This does not check if IRect is sorted, so the
416result may be negative. This is safer than calling width() since width() might
417overflow in its calculation.
418
419#Return fRight minus fLeft cast to int64_t ##
420
Cary Clark186d08f2018-04-03 08:43:27 -0400421#Example
Mike Reeda766ca92018-01-09 11:31:53 -0500422SkIRect large = { -2147483647, 1, 2147483644, 2 };
Cary Clark186d08f2018-04-03 08:43:27 -0400423SkDebugf("width: %d width64: %lld\n", large.width(), large.width64());
Mike Reeda766ca92018-01-09 11:31:53 -0500424#StdOut
425width: -5 width64: 4294967291
426##
427##
428
429#SeeAlso width() height() height64() SkRect::width()
Cary Clark0c5f5462017-12-15 11:21:51 -0500430
431##
432
433# ------------------------------------------------------------------------------
434
Cary Clark6def7202018-01-04 08:13:35 -0500435#Method int32_t height() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500436
Cary Clark4855f782018-02-06 09:41:53 -0500437#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500438#Line # returns span in y ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500439Returns span on the y-axis. This does not check if IRect is sorted, or if
440result fits in 32-bit signed integer; result may be negative.
441
442#Return fBottom minus fTop ##
443
444#Example
445 SkIRect unsorted = { 15, 25, 10, 20 };
446 SkDebugf("unsorted height: %d\n", unsorted.height());
447 SkIRect large = { 1, -2147483647, 2, 2147483644 };
448 SkDebugf("large height: %d\n", large.height());
449#StdOut
450unsorted height: -5
451large height: -5
452##
453##
454
455#SeeAlso width() SkRect::height()
456
457##
458
459# ------------------------------------------------------------------------------
460
Mike Reeda766ca92018-01-09 11:31:53 -0500461#Method int64_t height64() const
462
Cary Clark4855f782018-02-06 09:41:53 -0500463#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500464#Line # returns span in y as int64_t ##
Mike Reeda766ca92018-01-09 11:31:53 -0500465Returns span on the y-axis. This does not check if IRect is sorted, so the
466result may be negative. This is safer than calling height() since height() might
467overflow in its calculation.
468
469#Return fBottom minus fTop cast to int64_t ##
470
Cary Clark186d08f2018-04-03 08:43:27 -0400471#Example
Mike Reeda766ca92018-01-09 11:31:53 -0500472SkIRect large = { 1, -2147483647, 2, 2147483644 };
473SkDebugf("height: %d height64: %lld\n", large.height(), large.height64());
474#StdOut
475height: -5 height64: 4294967291
476##
477##
478
479#SeeAlso width() height() width64() SkRect::height()
480
481##
482
483# ------------------------------------------------------------------------------
484
Cary Clark0c5f5462017-12-15 11:21:51 -0500485#Method SkISize size() const
486
Cary Clark4855f782018-02-06 09:41:53 -0500487#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500488#Line # returns ISize (width, height) ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500489Returns spans on the x-axis and y-axis. This does not check if IRect is sorted,
490or if result fits in 32-bit signed integer; result may be negative.
491
492#Return ISize (width, height) ##
493
494#Example
495 auto debugster = [](const char* prefix, const SkIRect& rect) -> void {
496 SkISize size = rect.size();
497 SkDebugf("%s ", prefix);
498 SkDebugf("rect: %d, %d, %d, %d ", rect.left(), rect.top(), rect.right(), rect.bottom());
499 SkDebugf("size: %d, %d\n", size.width(), size.height());
500 };
501 SkIRect rect = {20, 30, 40, 50};
502 debugster("original", rect);
503 rect.offset(20, 20);
504 debugster(" offset", rect);
505 rect.outset(20, 20);
506 debugster(" outset", rect);
507#StdOut
508original rect: 20, 30, 40, 50 size: 20, 20
509 offset rect: 40, 50, 60, 70 size: 20, 20
510 outset rect: 20, 30, 80, 90 size: 60, 60
511##
512##
513
514#SeeAlso height() width() MakeSize
515
516##
517
518# ------------------------------------------------------------------------------
519
Cary Clark0c5f5462017-12-15 11:21:51 -0500520#Method bool isEmpty() const
521
Cary Clark4855f782018-02-06 09:41:53 -0500522#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500523#Line # returns true if width or height are zero or negative or they exceed int32_t ##
Mike Reedd2849492018-01-10 14:31:18 -0500524Returns true if width() or height() .
Cary Clark0c5f5462017-12-15 11:21:51 -0500525
526#Return true if width() or height() are zero or negative ##
527
528#Example
529 SkIRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}};
530 for (auto rect : tests) {
531 SkDebugf("rect: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
532 rect.bottom(), rect.isEmpty() ? "" : " not");
533 rect.sort();
534 SkDebugf("sorted: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
535 rect.bottom(), rect.isEmpty() ? "" : " not");
536 }
537#StdOut
538rect: {20, 40, 10, 50} is empty
539sorted: {10, 40, 20, 50} is not empty
540rect: {20, 40, 20, 50} is empty
541sorted: {20, 40, 20, 50} is empty
542##
543##
544
545#SeeAlso EmptyIRect MakeEmpty sort SkRect::isEmpty
546
547##
548
549# ------------------------------------------------------------------------------
550
Mike Reedd2849492018-01-10 14:31:18 -0500551#Method bool isEmpty64() const
552
Cary Clark4855f782018-02-06 09:41:53 -0500553#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500554#Line # returns true if width or height are zero or negative ##
Mike Reedd2849492018-01-10 14:31:18 -0500555Returns true if fLeft is equal to or greater than fRight, or if fTop is equal
556to or greater than fBottom. Call sort() to reverse rectangles with negative
557width64() or height64().
558
559#Return true if width64() or height64() are zero or negative ##
560
Cary Clark186d08f2018-04-03 08:43:27 -0400561#Example
Mike Reedd2849492018-01-10 14:31:18 -0500562SkIRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}};
563for (auto rect : tests) {
Cary Clark186d08f2018-04-03 08:43:27 -0400564 SkDebugf("rect: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
565 rect.bottom(), rect.isEmpty64() ? "" : " not");
566 rect.sort();
567 SkDebugf("sorted: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
568 rect.bottom(), rect.isEmpty64() ? "" : " not");
Mike Reedd2849492018-01-10 14:31:18 -0500569}
570#StdOut
571rect: {20, 40, 10, 50} is empty
572sorted: {10, 40, 20, 50} is not empty
573rect: {20, 40, 20, 50} is empty
574sorted: {20, 40, 20, 50} is empty
575##
576##
577
578#SeeAlso EmptyIRect MakeEmpty sort SkRect::isEmpty
579
580##
581
Cary Clark4855f782018-02-06 09:41:53 -0500582#Subtopic Operator
Cary Clark08895c42018-02-01 09:37:32 -0500583#Populate
Cary Clark2dc84ad2018-01-26 12:56:22 -0500584
Mike Reedd2849492018-01-10 14:31:18 -0500585# ------------------------------------------------------------------------------
586
Cary Clark0c5f5462017-12-15 11:21:51 -0500587#Method bool operator==(const SkIRect& a, const SkIRect& b)
588
Cary Clark4855f782018-02-06 09:41:53 -0500589#In Operator
Cary Clarkab2621d2018-01-30 10:08:57 -0500590#Line # returns true if members are equal ##
Cary Clark682c58d2018-05-16 07:07:07 -0400591Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are
Cary Clark0c5f5462017-12-15 11:21:51 -0500592identical to corresponding members in b.
593
594#Param a IRect to compare ##
595#Param b IRect to compare ##
596
597#Return true if members are equal ##
598
599#Example
600 SkIRect test = {0, 0, 2, 2};
601 SkIRect sorted = test.makeSorted();
602 SkDebugf("test %c= sorted\n", test == sorted ? '=' : '!');
603#StdOut
604test == sorted
605##
606##
607
608#SeeAlso operator!=(const SkIRect& a, const SkIRect& b)
609
610##
611
612# ------------------------------------------------------------------------------
613
614#Method bool operator!=(const SkIRect& a, const SkIRect& b)
615
Cary Clark4855f782018-02-06 09:41:53 -0500616#In Operator
Cary Clarkab2621d2018-01-30 10:08:57 -0500617#Line # returns true if members are unequal ##
Cary Clark682c58d2018-05-16 07:07:07 -0400618Returns true if any member in a: fLeft, fTop, fRight, and fBottom; is not
Cary Clark0c5f5462017-12-15 11:21:51 -0500619identical to the corresponding member in b.
620
621#Param a IRect to compare ##
622#Param b IRect to compare ##
623
624#Return true if members are not equal ##
625
626#Example
627 SkIRect test = {2, 2, 0, 0};
628 SkIRect sorted = test.makeSorted();
629 SkDebugf("test %c= sorted\n", test != sorted ? '!' : '=');
630#StdOut
631test != sorted
632##
633##
634
635#SeeAlso operator==(const SkIRect& a, const SkIRect& b)
636
637##
638
Cary Clark4855f782018-02-06 09:41:53 -0500639#Subtopic Operator ##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500640
Cary Clark0c5f5462017-12-15 11:21:51 -0500641# ------------------------------------------------------------------------------
642
Cary Clark78de7512018-02-07 07:27:09 -0500643#Subtopic Set
644#Line # replaces all values ##
645#Populate
646##
Cary Clark0c5f5462017-12-15 11:21:51 -0500647
648#Method void setEmpty()
649
Cary Clark4855f782018-02-06 09:41:53 -0500650#In Set
Cary Clarkab2621d2018-01-30 10:08:57 -0500651#Line # sets to (0, 0, 0, 0) ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500652Sets IRect to (0, 0, 0, 0).
653
654Many other rectangles are empty; if left is equal to or greater than right,
655or if top is equal to or greater than bottom. Setting all members to zero
656is a convenience, but does not designate a special empty rectangle.
657
658#Example
659 SkIRect rect = {3, 4, 1, 2};
660 for (int i = 0; i < 2; ++i) {
661 SkDebugf("rect: {%d, %d, %d, %d} is %s" "empty\n", rect.fLeft, rect.fTop,
662 rect.fRight, rect.fBottom, rect.isEmpty() ? "" : "not ");
663 rect.setEmpty();
664 }
665#StdOut
666rect: {3, 4, 1, 2} is empty
667rect: {0, 0, 0, 0} is empty
668##
669##
670
671#SeeAlso MakeEmpty SkRect::setEmpty
672
673##
674
675# ------------------------------------------------------------------------------
676
677#Method void set(int32_t left, int32_t top, int32_t right, int32_t bottom)
678
Cary Clark4855f782018-02-06 09:41:53 -0500679#In Set
Cary Clarkab2621d2018-01-30 10:08:57 -0500680#Line # sets to (left, top, right, bottom) ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500681Sets IRect to (left, top, right, bottom).
682left and right are not sorted; left is not necessarily less than right.
683top and bottom are not sorted; top is not necessarily less than bottom.
684
685#Param left assigned to fLeft ##
686#Param top assigned to fTop ##
687#Param right assigned to fRight ##
688#Param bottom assigned to fBottom ##
689
690#Example
691 SkIRect rect1 = {3, 4, 1, 2};
692 SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
693 SkIRect rect2;
694 rect2.set(3, 4, 1, 2);
695 SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
696#StdOut
697rect1: {3, 4, 1, 2}
698rect2: {3, 4, 1, 2}
699##
700##
701
702#SeeAlso setLTRB setXYWH SkRect::set
703
704##
705
706# ------------------------------------------------------------------------------
707
708#Method void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom)
709
Cary Clark4855f782018-02-06 09:41:53 -0500710#In Set
Cary Clarkab2621d2018-01-30 10:08:57 -0500711#Line # sets to SkScalar input (left, top, right, bottom) ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500712Sets IRect to (left, top, right, bottom).
713left and right are not sorted; left is not necessarily less than right.
714top and bottom are not sorted; top is not necessarily less than bottom.
715
716#Param left stored in fLeft ##
717#Param top stored in fTop ##
718#Param right stored in fRight ##
719#Param bottom stored in fBottom ##
720
721#Example
722 SkIRect rect1 = {3, 4, 1, 2};
723 SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
724 SkIRect rect2;
725 rect2.setLTRB(3, 4, 1, 2);
726 SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
727#StdOut
728rect1: {3, 4, 1, 2}
729rect2: {3, 4, 1, 2}
730##
731##
732
733#SeeAlso set setXYWH SkRect::setLTRB
734
735##
736
737# ------------------------------------------------------------------------------
738
739#Method void setXYWH(int32_t x, int32_t y, int32_t width, int32_t height)
740
Cary Clark4855f782018-02-06 09:41:53 -0500741#In Set
Cary Clarkab2621d2018-01-30 10:08:57 -0500742#Line # sets to (x, y, width, height) ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500743Sets IRect to:
744#Formula
745(x, y, x + width, y + height)
746##
747. Does not validate input;
748width or height may be negative.
749
750#Param x stored in fLeft ##
751#Param y stored in fTop ##
752#Param width added to x and stored in fRight ##
753#Param height added to y and stored in fBottom ##
754
755#Example
756 SkIRect rect;
757 rect.setXYWH(5, 35, -15, 25);
758 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
759 rect.bottom(), rect.isEmpty() ? "true" : "false");
760 rect.sort();
761 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
762 rect.bottom(), rect.isEmpty() ? "true" : "false");
763#StdOut
764rect: 5, 35, -10, 60 isEmpty: true
765rect: -10, 35, 5, 60 isEmpty: false
766##
767##
768
769#SeeAlso MakeXYWH setLTRB set SkRect::setXYWH
770
771##
772
Cary Clark2dc84ad2018-01-26 12:56:22 -0500773#Subtopic Inset_Outset_Offset
Cary Clark08895c42018-02-01 09:37:32 -0500774#Line # moves sides ##
Cary Clark4855f782018-02-06 09:41:53 -0500775#Populate
Cary Clark2dc84ad2018-01-26 12:56:22 -0500776
Cary Clark0c5f5462017-12-15 11:21:51 -0500777# ------------------------------------------------------------------------------
778
Cary Clark0c5f5462017-12-15 11:21:51 -0500779#Method SkIRect makeOffset(int32_t dx, int32_t dy) const
780
Cary Clarkab2621d2018-01-30 10:08:57 -0500781#In Inset_Outset_Offset
782#Line # constructs from translated sides ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500783Returns IRect offset by (dx, dy).
784
785If dx is negative, IRect returned is moved to the left.
786If dx is positive, IRect returned is moved to the right.
787If dy is negative, IRect returned is moved upward.
Cary Clark682c58d2018-05-16 07:07:07 -0400788If dy is positive, IRect returned is moved downward.
Cary Clark0c5f5462017-12-15 11:21:51 -0500789
790#Param dx offset added to fLeft and fRight ##
791#Param dy offset added to fTop and fBottom ##
792
Cary Clark2dc84ad2018-01-26 12:56:22 -0500793#Return IRect offset in x or y, with original width and height ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500794
795#Example
796 SkIRect rect = { 10, 50, 20, 60 };
797 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
798 rect.bottom(), rect.isEmpty() ? "true" : "false");
799 rect = rect.makeOffset(15, 32);
800 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
801 rect.bottom(), rect.isEmpty() ? "true" : "false");
802#StdOut
803rect: 10, 50, 20, 60 isEmpty: false
804rect: 25, 82, 35, 92 isEmpty: false
805##
806##
807
808#SeeAlso offset() makeInset makeOutset SkRect::makeOffset
809
810##
811
812# ------------------------------------------------------------------------------
813
814#Method SkIRect makeInset(int32_t dx, int32_t dy) const
815
Cary Clarkab2621d2018-01-30 10:08:57 -0500816#In Inset_Outset_Offset
817#Line # constructs from sides moved symmetrically about the center ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500818Returns IRect, inset by (dx, dy).
819
820If dx is negative, IRect returned is wider.
821If dx is positive, IRect returned is narrower.
822If dy is negative, IRect returned is taller.
Cary Clark682c58d2018-05-16 07:07:07 -0400823If dy is positive, IRect returned is shorter.
Cary Clark0c5f5462017-12-15 11:21:51 -0500824
825#Param dx offset added to fLeft and subtracted from fRight ##
826#Param dy offset added to fTop and subtracted from fBottom ##
827
Cary Clark2dc84ad2018-01-26 12:56:22 -0500828#Return IRect inset symmetrically left and right, top and bottom ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500829
830#Example
831 SkIRect rect = { 10, 50, 20, 60 };
832 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
833 rect.bottom(), rect.isEmpty() ? "true" : "false");
834 rect = rect.makeInset(15, 32);
835 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
836 rect.bottom(), rect.isEmpty() ? "true" : "false");
837#StdOut
838rect: 10, 50, 20, 60 isEmpty: false
839rect: 25, 82, 5, 28 isEmpty: true
840##
841##
842
843#SeeAlso inset() makeOffset makeOutset SkRect::makeInset
844
845##
846
847# ------------------------------------------------------------------------------
848
849#Method SkIRect makeOutset(int32_t dx, int32_t dy) const
850
Cary Clarkab2621d2018-01-30 10:08:57 -0500851#In Inset_Outset_Offset
852#Line # constructs from sides moved symmetrically about the center ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500853Returns IRect, outset by (dx, dy).
854
855If dx is negative, IRect returned is narrower.
856If dx is positive, IRect returned is wider.
857If dy is negative, IRect returned is shorter.
Cary Clark682c58d2018-05-16 07:07:07 -0400858If dy is positive, IRect returned is taller.
Cary Clark0c5f5462017-12-15 11:21:51 -0500859
860#Param dx offset subtracted to fLeft and added from fRight ##
861#Param dy offset subtracted to fTop and added from fBottom ##
862
Cary Clark2dc84ad2018-01-26 12:56:22 -0500863#Return IRect outset symmetrically left and right, top and bottom ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500864
865#Example
866 SkIRect rect = { 10, 50, 20, 60 };
867 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
868 rect.bottom(), rect.isEmpty() ? "true" : "false");
869 rect = rect.makeOutset(15, 32);
870 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
871 rect.bottom(), rect.isEmpty() ? "true" : "false");
872#StdOut
873rect: 10, 50, 20, 60 isEmpty: false
874rect: -5, 18, 35, 92 isEmpty: false
875##
876##
877
878#SeeAlso outset() makeOffset makeInset SkRect::makeOutset
879
880##
881
882# ------------------------------------------------------------------------------
883
884#Method void offset(int32_t dx, int32_t dy)
885
Cary Clarkab2621d2018-01-30 10:08:57 -0500886#In Inset_Outset_Offset
887#Line # translates sides without changing width and height ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500888Offsets IRect by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom.
889
890If dx is negative, moves IRect returned to the left.
891If dx is positive, moves IRect returned to the right.
892If dy is negative, moves IRect returned upward.
Cary Clark682c58d2018-05-16 07:07:07 -0400893If dy is positive, moves IRect returned downward.
Cary Clark0c5f5462017-12-15 11:21:51 -0500894
895#Param dx offset added to fLeft and fRight ##
896#Param dy offset added to fTop and fBottom ##
897
898#Example
899 SkIRect rect = { 10, 14, 50, 73 };
900 rect.offset(5, 13);
901 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
902#StdOut
903rect: 15, 27, 55, 86
904##
905##
906
907#SeeAlso offsetTo makeOffset SkRect::offset
908
909##
910
911# ------------------------------------------------------------------------------
912
913#Method void offset(const SkIPoint& delta)
914
Cary Clarkab2621d2018-01-30 10:08:57 -0500915#In Inset_Outset_Offset
Cary Clark0c5f5462017-12-15 11:21:51 -0500916Offsets IRect by adding delta.fX to fLeft, fRight; and by adding delta.fY to
917fTop, fBottom.
918
919If delta.fX is negative, moves IRect returned to the left.
920If delta.fX is positive, moves IRect returned to the right.
921If delta.fY is negative, moves IRect returned upward.
Cary Clark682c58d2018-05-16 07:07:07 -0400922If delta.fY is positive, moves IRect returned downward.
Cary Clark0c5f5462017-12-15 11:21:51 -0500923
924#Param delta offset added to IRect ##
925
926#Example
927 SkIRect rect = { 10, 14, 50, 73 };
928 rect.offset({5, 13});
929 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
930#StdOut
931rect: 15, 27, 55, 86
932##
933##
934
935#SeeAlso offsetTo makeOffset SkRect::offset
936
937##
938
939# ------------------------------------------------------------------------------
940
941#Method void offsetTo(int32_t newX, int32_t newY)
942
Cary Clarkab2621d2018-01-30 10:08:57 -0500943#In Inset_Outset_Offset
944#Line # translates to (x, y) without changing width and height ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500945Offsets IRect so that fLeft equals newX, and fTop equals newY. width and height
946are unchanged.
947
948#Param newX stored in fLeft, preserving width() ##
949#Param newY stored in fTop, preserving height() ##
950
951#Example
952 SkIRect rect = { 10, 14, 50, 73 };
953 rect.offsetTo(15, 27);
954 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
955#StdOut
956rect: 15, 27, 55, 86
957##
958##
959
960#SeeAlso offset makeOffset setXYWH SkRect::offsetTo
961
962##
963
964# ------------------------------------------------------------------------------
965
966#Method void inset(int32_t dx, int32_t dy)
967
Cary Clarkab2621d2018-01-30 10:08:57 -0500968#In Inset_Outset_Offset
969#Line # moves the sides symmetrically about the center ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500970Insets IRect by (dx,dy).
971
972If dx is positive, makes IRect narrower.
973If dx is negative, makes IRect wider.
974If dy is positive, makes IRect shorter.
975If dy is negative, makes IRect taller.
976
977#Param dx offset added to fLeft and subtracted from fRight ##
978#Param dy offset added to fTop and subtracted from fBottom ##
979
980#Example
981 SkIRect rect = { 10, 14, 50, 73 };
982 rect.inset(5, 13);
983 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
984#StdOut
985rect: 15, 27, 45, 60
986##
987##
988
989#SeeAlso outset makeInset SkRect::inset
990
991##
992
993# ------------------------------------------------------------------------------
994
995#Method void outset(int32_t dx, int32_t dy)
996
Cary Clarkab2621d2018-01-30 10:08:57 -0500997#In Inset_Outset_Offset
998#Line # moves the sides symmetrically about the center ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500999Outsets IRect by (dx, dy).
1000
Cary Clark2dc84ad2018-01-26 12:56:22 -05001001If dx is positive, makes IRect wider.
1002If dx is negative, makes IRect narrower.
1003If dy is positive, makes IRect taller.
1004If dy is negative, makes IRect shorter.
Cary Clark0c5f5462017-12-15 11:21:51 -05001005
1006#Param dx subtracted to fLeft and added from fRight ##
1007#Param dy subtracted to fTop and added from fBottom ##
1008
1009#Example
1010 SkIRect rect = { 10, 14, 50, 73 };
1011 rect.outset(5, 13);
1012 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1013#StdOut
1014rect: 5, 1, 55, 86
1015##
1016##
1017
1018#SeeAlso inset makeOutset SkRect::outset
1019
1020##
1021
Cary Clark2dc84ad2018-01-26 12:56:22 -05001022#Subtopic Inset_Outset_Offset ##
1023
1024#Subtopic Intersection
Cary Clark682c58d2018-05-16 07:07:07 -04001025#Line # sets to shared bounds ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001026
Cary Clark682c58d2018-05-16 07:07:07 -04001027IRects intersect when they enclose a common area. To intersect, each of the pair
Cary Clark2dc84ad2018-01-26 12:56:22 -05001028must describe area; fLeft is less than fRight, and fTop is less than fBottom;
1029empty() returns false. The intersection of IRect pair can be described by:
1030
1031#Formula
1032(max(a.fLeft, b.fLeft), max(a.fTop, b.fTop),
1033 min(a.fRight, b.fRight), min(a.fBottom, b.fBottom))
1034##
1035.
1036
1037The intersection is only meaningful if the resulting IRect is not empty and
1038describes an area: fLeft is less than fRight, and fTop is less than fBottom.
1039
Cary Clark4855f782018-02-06 09:41:53 -05001040#Populate
Cary Clark2dc84ad2018-01-26 12:56:22 -05001041
Cary Clark0c5f5462017-12-15 11:21:51 -05001042# ------------------------------------------------------------------------------
1043
Robert Phillips8f8d4812018-05-18 10:19:05 -04001044#Method void adjust(int32_t dL, int32_t dT, int32_t dR, int32_t dB)
1045
1046#In Inset_Outset_Offset
1047#Line # moves the sides independently relative to their original locations ##
Cary Clarkdbc90e42018-05-18 11:57:17 -04001048Adjusts IRect by adding dL to fLeft, dT to fTop, dR to fRight, and dB to fBottom.
Robert Phillips8f8d4812018-05-18 10:19:05 -04001049
1050If dL is positive, narrows IRect on the left. If negative, widens it on the left.
1051If dT is positive, shrinks IRect on the top. If negative, lengthens it on the top.
1052If dR is positive, narrows IRect on the right. If negative, widens it on the right.
1053If dB is positive, shrinks IRect on the bottom. If negative, lengthens it on the bottom.
1054
1055The resulting IRect is not checked for validity. Thus, if the resulting IRect left is
1056greater than right, the IRect will be considered empty. Call sort() after this call
1057if that is not the desired behavior.
1058
1059#Param dL offset added to fLeft ##
1060#Param dT offset added to fTop ##
1061#Param dR offset added to fRight ##
1062#Param dB offset added to fBottom ##
1063
1064#Example
1065 SkIRect rect = { 8, 11, 19, 22 };
1066 rect.adjust(2, -1, 1, -2);
1067 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1068#StdOut
1069rect: 10, 10, 20, 20
1070##
1071##
1072
1073#SeeAlso inset outset
1074
1075##
1076
1077# ------------------------------------------------------------------------------
1078
Cary Clark0c5f5462017-12-15 11:21:51 -05001079#Method bool contains(int32_t x, int32_t y) const
1080
Cary Clarkab2621d2018-01-30 10:08:57 -05001081#In Intersection
Cary Clark300cc5b2018-02-20 12:50:35 -05001082#Line # returns true if IPoint (x, y) is equal or inside ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001083Returns true if:
1084#Formula
1085fLeft <= x < fRight && fTop <= y < fBottom
1086##
1087.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001088Returns false if IRect is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001089
1090Considers input to describe constructed IRect:
1091#Formula
1092(x, y, x + 1, y + 1)
1093##
1094and
1095returns true if constructed area is completely enclosed by IRect area.
1096
Cary Clark300cc5b2018-02-20 12:50:35 -05001097#Param x test IPoint x-coordinate ##
1098#Param y test IPoint y-coordinate ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001099
1100#Return true if (x, y) is inside IRect ##
1101
1102#Example
1103 SkIRect rect = { 30, 50, 40, 60 };
1104 SkIPoint pts[] = { { 30, 50}, { 40, 50}, { 30, 60} };
1105 for (auto pt : pts) {
1106 SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d)\n",
1107 rect.left(), rect.top(), rect.right(), rect.bottom(),
1108 rect.contains(pt.x(), pt.y()) ? "contains" : "does not contain", pt.x(), pt.y());
1109 }
1110#StdOut
1111rect: (30, 50, 40, 60) contains (30, 50)
1112rect: (30, 50, 40, 60) does not contain (40, 50)
1113rect: (30, 50, 40, 60) does not contain (30, 60)
1114##
1115##
1116
1117#SeeAlso containsNoEmptyCheck SkRect::contains
1118
1119##
1120
1121# ------------------------------------------------------------------------------
1122
1123#Method bool contains(int32_t left, int32_t top, int32_t right, int32_t bottom) const
1124
Cary Clarkab2621d2018-01-30 10:08:57 -05001125#In Intersection
Cary Clark2dc84ad2018-01-26 12:56:22 -05001126Constructs IRect to intersect from (left, top, right, bottom). Does not sort
Cary Clark0c5f5462017-12-15 11:21:51 -05001127construction.
1128
Cary Clark2dc84ad2018-01-26 12:56:22 -05001129Returns true if IRect contains construction.
1130Returns false if IRect is empty or construction is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001131
Cary Clark2dc84ad2018-01-26 12:56:22 -05001132#Param left x minimum of constructed IRect ##
1133#Param top y minimum of constructed IRect ##
1134#Param right x maximum of constructed IRect ##
1135#Param bottom y maximum of constructed IRect ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001136
1137#Return true if all sides of IRect are outside construction ##
1138
1139#Example
1140 SkIRect rect = { 30, 50, 40, 60 };
1141 SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1142 for (auto contained : tests) {
1143 bool success = rect.contains(
1144 contained.left(), contained.top(), contained.right(), contained.bottom());
1145 SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
1146 rect.left(), rect.top(), rect.right(), rect.bottom(),
1147 success ? "contains" : "does not contain",
1148 contained.left(), contained.top(), contained.right(), contained.bottom());
1149 }
1150#StdOut
1151rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1152rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1153rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1154##
1155##
1156
1157#SeeAlso containsNoEmptyCheck SkRect::contains
1158
1159##
1160
1161# ------------------------------------------------------------------------------
1162
1163#Method bool contains(const SkIRect& r) const
1164
Cary Clarkab2621d2018-01-30 10:08:57 -05001165#In Intersection
Cary Clark2dc84ad2018-01-26 12:56:22 -05001166Returns true if IRect contains r.
1167Returns false if IRect is empty or r is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001168
Cary Clark2dc84ad2018-01-26 12:56:22 -05001169IRect contains r when IRect area completely includes r area.
Cary Clark0c5f5462017-12-15 11:21:51 -05001170
1171#Param r IRect contained ##
1172
1173#Return true if all sides of IRect are outside r ##
1174
1175#Example
1176 SkIRect rect = { 30, 50, 40, 60 };
1177 SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1178 for (auto contained : tests) {
1179 SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
1180 rect.left(), rect.top(), rect.right(), rect.bottom(),
1181 rect.contains(contained) ? "contains" : "does not contain",
1182 contained.left(), contained.top(), contained.right(), contained.bottom());
1183 }
1184#StdOut
1185rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1186rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1187rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1188##
1189##
1190
1191#SeeAlso containsNoEmptyCheck SkRect::contains
1192
1193##
1194
1195# ------------------------------------------------------------------------------
1196
1197#Method bool contains(const SkRect& r) const
1198
Cary Clarkab2621d2018-01-30 10:08:57 -05001199#In Intersection
Cary Clark2dc84ad2018-01-26 12:56:22 -05001200Returns true if IRect contains r.
1201Returns false if IRect is empty or r is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001202
Cary Clark2dc84ad2018-01-26 12:56:22 -05001203IRect contains r when IRect area completely includes r area.
Cary Clark0c5f5462017-12-15 11:21:51 -05001204
1205#Param r Rect contained ##
1206
1207#Return true if all sides of IRect are outside r ##
1208
1209#Example
1210 SkIRect rect = { 30, 50, 40, 60 };
1211 SkRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1212 for (auto contained : tests) {
1213 SkDebugf("rect: (%d, %d, %d, %d) %s (%g, %g, %g, %g)\n",
1214 rect.left(), rect.top(), rect.right(), rect.bottom(),
1215 rect.contains(contained) ? "contains" : "does not contain",
1216 contained.left(), contained.top(), contained.right(), contained.bottom());
1217 }
1218#StdOut
1219rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1220rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1221rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1222##
1223##
1224
1225#SeeAlso containsNoEmptyCheck SkRect::contains
1226
1227##
1228
1229# ------------------------------------------------------------------------------
1230
1231#Method bool containsNoEmptyCheck(int32_t left, int32_t top,
1232 int32_t right, int32_t bottom) const
Cary Clarkab2621d2018-01-30 10:08:57 -05001233#In Intersection
Cary Clark300cc5b2018-02-20 12:50:35 -05001234#Line # returns true if contains unsorted IRect ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001235
1236Constructs IRect from (left, top, right, bottom). Does not sort
1237construction.
1238
Cary Clark2dc84ad2018-01-26 12:56:22 -05001239Returns true if IRect contains construction.
Cary Clark0c5f5462017-12-15 11:21:51 -05001240Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined.
1241
Cary Clark2dc84ad2018-01-26 12:56:22 -05001242Return is undefined if IRect is empty or construction is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001243
Cary Clark2dc84ad2018-01-26 12:56:22 -05001244#Param left x minimum of constructed IRect ##
1245#Param top y minimum of constructed IRect ##
1246#Param right x maximum of constructed IRect ##
1247#Param bottom y maximum of constructed IRect ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001248
1249#Return true if all sides of IRect are outside construction ##
1250
1251#Example
1252 SkIRect rect = { 30, 50, 40, 60 };
1253 SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1254 for (auto contained : tests) {
1255 bool success = rect.containsNoEmptyCheck(
1256 contained.left(), contained.top(), contained.right(), contained.bottom());
1257 SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
1258 rect.left(), rect.top(), rect.right(), rect.bottom(),
1259 success ? "contains" : "does not contain",
1260 contained.left(), contained.top(), contained.right(), contained.bottom());
1261 }
1262#StdOut
1263rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1264rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1265rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1266##
1267##
1268
1269#SeeAlso contains SkRect::contains
1270
1271##
1272
1273# ------------------------------------------------------------------------------
1274
1275#Method bool containsNoEmptyCheck(const SkIRect& r) const
1276
Cary Clarkab2621d2018-01-30 10:08:57 -05001277#In Intersection
Cary Clark2dc84ad2018-01-26 12:56:22 -05001278Returns true if IRect contains construction.
Cary Clark0c5f5462017-12-15 11:21:51 -05001279Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined.
1280
Cary Clark2dc84ad2018-01-26 12:56:22 -05001281Return is undefined if IRect is empty or construction is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001282
Cary Clark2dc84ad2018-01-26 12:56:22 -05001283#Param r IRect contained ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001284
1285#Return true if all sides of IRect are outside r ##
1286
1287#Example
1288 SkIRect rect = { 30, 50, 40, 60 };
1289 SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1290 for (auto contained : tests) {
1291 SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
1292 rect.left(), rect.top(), rect.right(), rect.bottom(),
1293 rect.containsNoEmptyCheck(contained) ? "contains" : "does not contain",
1294 contained.left(), contained.top(), contained.right(), contained.bottom());
1295 }
1296#StdOut
1297rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1298rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1299rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1300##
1301##
1302
1303#SeeAlso contains SkRect::contains
1304
1305##
1306
Cary Clark0c5f5462017-12-15 11:21:51 -05001307# ------------------------------------------------------------------------------
1308
1309#Method bool intersect(const SkIRect& r)
1310
Cary Clarkab2621d2018-01-30 10:08:57 -05001311#In Intersection
1312#Line # sets to shared area; returns true if not empty ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001313Returns true if IRect intersects r, and sets IRect to intersection.
1314Returns false if IRect does not intersect r, and leaves IRect unchanged.
1315
1316Returns false if either r or IRect is empty, leaving IRect unchanged.
1317
1318#Param r limit of result ##
1319
Cary Clark2dc84ad2018-01-26 12:56:22 -05001320#Return true if r and IRect have area in common ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001321
1322#Example
1323#Description
1324Two SkDebugf calls are required. If the calls are combined, their arguments
1325may not be evaluated in left to right order: the printed intersection may
1326be before or after the call to intersect.
1327##
1328 SkIRect leftRect = { 10, 40, 50, 80 };
1329 SkIRect rightRect = { 30, 60, 70, 90 };
1330 SkDebugf("%s intersection: ", leftRect.intersect(rightRect) ? "" : "no ");
Cary Clark682c58d2018-05-16 07:07:07 -04001331 SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
Cary Clark0c5f5462017-12-15 11:21:51 -05001332 leftRect.right(), leftRect.bottom());
1333#StdOut
1334 intersection: 30, 60, 50, 80
Cary Clark682c58d2018-05-16 07:07:07 -04001335##
Cary Clark0c5f5462017-12-15 11:21:51 -05001336##
1337
1338#SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect
1339
1340##
1341
1342# ------------------------------------------------------------------------------
1343
1344#Method bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& a, const SkIRect& b)
1345
Cary Clarkab2621d2018-01-30 10:08:57 -05001346#In Intersection
Cary Clark0c5f5462017-12-15 11:21:51 -05001347Returns true if a intersects b, and sets IRect to intersection.
1348Returns false if a does not intersect b, and leaves IRect unchanged.
1349
1350Returns false if either a or b is empty, leaving IRect unchanged.
1351
1352#Param a IRect to intersect ##
1353#Param b IRect to intersect ##
1354
1355#Return true if a and b have area in common ##
1356
1357#Example
1358 SkIRect result;
1359 bool intersected = result.intersect({ 10, 40, 50, 80 }, { 30, 60, 70, 90 });
1360 SkDebugf("%s intersection: %d, %d, %d, %d\n", intersected ? "" : "no ",
1361 result.left(), result.top(), result.right(), result.bottom());
1362#StdOut
1363 intersection: 30, 60, 50, 80
Cary Clark682c58d2018-05-16 07:07:07 -04001364##
Cary Clark0c5f5462017-12-15 11:21:51 -05001365##
1366
1367#SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect
1368
1369##
1370
1371# ------------------------------------------------------------------------------
1372
1373#Method bool SK_WARN_UNUSED_RESULT intersectNoEmptyCheck(const SkIRect& a, const SkIRect& b)
1374
Cary Clarkab2621d2018-01-30 10:08:57 -05001375#In Intersection
1376#Line # sets to shared area; returns true if not empty skips empty check ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001377Returns true if a intersects b, and sets IRect to intersection.
1378Returns false if a does not intersect b, and leaves IRect unchanged.
1379
1380Asserts if either a or b is empty, and if SK_DEBUG is defined.
1381
1382#Param a IRect to intersect ##
1383#Param b IRect to intersect ##
1384
1385#Return true if a and b have area in common ##
1386
1387#Example
1388 SkIRect result;
Cary Clark681287e2018-03-16 11:34:15 -04001389 if (result.intersectNoEmptyCheck({ 10, 40, 50, 80 }, { 30, 60, 70, 90 })) {
1390 SkDebugf("intersection: %d, %d, %d, %d\n",
1391 result.left(), result.top(), result.right(), result.bottom());
1392 }
Cary Clark0c5f5462017-12-15 11:21:51 -05001393#StdOut
1394 intersection: 30, 60, 50, 80
Cary Clark682c58d2018-05-16 07:07:07 -04001395##
Cary Clark0c5f5462017-12-15 11:21:51 -05001396##
1397
1398#SeeAlso Intersects intersect join SkRect::intersect
1399
1400##
1401
1402# ------------------------------------------------------------------------------
1403
1404#Method bool intersect(int32_t left, int32_t top, int32_t right, int32_t bottom)
1405
Cary Clarkab2621d2018-01-30 10:08:57 -05001406#In Intersection
Cary Clark0c5f5462017-12-15 11:21:51 -05001407Constructs IRect to intersect from (left, top, right, bottom). Does not sort
1408construction.
1409
1410Returns true if IRect intersects construction, and sets IRect to intersection.
1411Returns false if IRect does not intersect construction, and leaves IRect unchanged.
1412
1413Returns false if either construction or IRect is empty, leaving IRect unchanged.
1414
1415#Param left x minimum of constructed IRect ##
1416#Param top y minimum of constructed IRect ##
1417#Param right x maximum of constructed IRect ##
1418#Param bottom y maximum of constructed IRect ##
1419
1420#Return true if construction and IRect have area in common ##
1421
1422#Example
1423#Description
1424Two SkDebugf calls are required. If the calls are combined, their arguments
1425may not be evaluated in left to right order: the printed intersection may
1426be before or after the call to intersect.
1427##
1428 SkIRect leftRect = { 10, 40, 50, 80 };
1429 SkDebugf("%s intersection: ", leftRect.intersect(30, 60, 70, 90) ? "" : "no ");
Cary Clark682c58d2018-05-16 07:07:07 -04001430 SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
Cary Clark0c5f5462017-12-15 11:21:51 -05001431 leftRect.right(), leftRect.bottom());
1432#StdOut
1433 intersection: 30, 60, 50, 80
Cary Clark682c58d2018-05-16 07:07:07 -04001434##
Cary Clark0c5f5462017-12-15 11:21:51 -05001435##
1436
1437#SeeAlso intersectNoEmptyCheck Intersects join SkRect::intersect
1438
1439##
1440
1441# ------------------------------------------------------------------------------
1442
1443#Method static bool Intersects(const SkIRect& a, const SkIRect& b)
1444
Cary Clarkab2621d2018-01-30 10:08:57 -05001445#In Intersection
1446#Line # returns true if areas overlap ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001447Returns true if a intersects b.
1448Returns false if either a or b is empty, or do not intersect.
1449
1450#Param a IRect to intersect ##
1451#Param b IRect to intersect ##
1452
1453#Return true if a and b have area in common ##
1454
1455#Example
1456 SkDebugf("%s intersection", SkIRect::Intersects({10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
1457#StdOut
1458 intersection
Cary Clark682c58d2018-05-16 07:07:07 -04001459##
Cary Clark0c5f5462017-12-15 11:21:51 -05001460##
1461
1462#SeeAlso IntersectsNoEmptyCheck intersect SkRect::intersect
1463
1464##
1465
1466# ------------------------------------------------------------------------------
1467
1468#Method static bool IntersectsNoEmptyCheck(const SkIRect& a, const SkIRect& b)
1469
Cary Clarkab2621d2018-01-30 10:08:57 -05001470#In Intersection
1471#Line # returns true if areas overlap skips empty check ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001472Returns true if a intersects b.
1473Asserts if either a or b is empty, and if SK_DEBUG is defined.
1474
1475#Param a IRect to intersect ##
1476#Param b IRect to intersect ##
1477
1478#Return true if a and b have area in common ##
1479
1480#Example
1481 SkDebugf("%s intersection", SkIRect::IntersectsNoEmptyCheck(
1482 {10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
1483#StdOut
1484 intersection
Cary Clark682c58d2018-05-16 07:07:07 -04001485##
Cary Clark0c5f5462017-12-15 11:21:51 -05001486##
1487
1488#SeeAlso Intersects intersect SkRect::intersect
1489
1490##
1491
Cary Clark2dc84ad2018-01-26 12:56:22 -05001492#Subtopic Intersection ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001493
1494# ------------------------------------------------------------------------------
1495
Cary Clark4855f782018-02-06 09:41:53 -05001496#Subtopic Join
Cary Clark682c58d2018-05-16 07:07:07 -04001497#Line # sets to union of bounds ##
Cary Clark4855f782018-02-06 09:41:53 -05001498#Populate
1499##
1500
Cary Clark0c5f5462017-12-15 11:21:51 -05001501#Method void join(int32_t left, int32_t top, int32_t right, int32_t bottom)
1502
Cary Clark4855f782018-02-06 09:41:53 -05001503#In Join
Cary Clarkab2621d2018-01-30 10:08:57 -05001504#Line # sets to union of bounds ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001505Constructs IRect to intersect from (left, top, right, bottom). Does not sort
Cary Clark0c5f5462017-12-15 11:21:51 -05001506construction.
1507
Cary Clark2dc84ad2018-01-26 12:56:22 -05001508Sets IRect to the union of itself and the construction.
Cary Clark0c5f5462017-12-15 11:21:51 -05001509
Cary Clark2dc84ad2018-01-26 12:56:22 -05001510Has no effect if construction is empty. Otherwise, if IRect is empty, sets
1511IRect to construction.
Cary Clark0c5f5462017-12-15 11:21:51 -05001512
Cary Clark2dc84ad2018-01-26 12:56:22 -05001513#Param left x minimum of constructed IRect ##
1514#Param top y minimum of constructed IRect ##
1515#Param right x maximum of constructed IRect ##
1516#Param bottom y maximum of constructed IRect ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001517
1518#Example
1519 SkIRect rect = { 10, 20, 15, 25};
1520 rect.join(50, 60, 55, 65);
1521 SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1522#StdOut
1523 join: 10, 20, 55, 65
Cary Clark682c58d2018-05-16 07:07:07 -04001524##
Cary Clark0c5f5462017-12-15 11:21:51 -05001525##
1526
1527#SeeAlso set SkRect::join
1528
1529##
1530
1531# ------------------------------------------------------------------------------
1532
1533#Method void join(const SkIRect& r)
1534
Cary Clark4855f782018-02-06 09:41:53 -05001535#In Join
Cary Clark2dc84ad2018-01-26 12:56:22 -05001536Sets IRect to the union of itself and r.
Cary Clark0c5f5462017-12-15 11:21:51 -05001537
Cary Clark2dc84ad2018-01-26 12:56:22 -05001538Has no effect if r is empty. Otherwise, if IRect is empty, sets IRect to r.
Cary Clark0c5f5462017-12-15 11:21:51 -05001539
Cary Clark2dc84ad2018-01-26 12:56:22 -05001540#Param r expansion IRect ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001541
1542#Example
1543 SkIRect rect = { 10, 20, 15, 25};
1544 rect.join({50, 60, 55, 65});
1545 SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1546#StdOut
1547 join: 10, 20, 55, 65
Cary Clark682c58d2018-05-16 07:07:07 -04001548##
Cary Clark0c5f5462017-12-15 11:21:51 -05001549##
1550
1551#SeeAlso set SkRect::join
1552
1553##
1554
1555# ------------------------------------------------------------------------------
1556
Cary Clark4855f782018-02-06 09:41:53 -05001557#Subtopic Sorting
1558#Line # orders sides ##
1559#Populate
1560##
1561
Cary Clark0c5f5462017-12-15 11:21:51 -05001562#Method void sort()
1563
Cary Clark4855f782018-02-06 09:41:53 -05001564#In Sorting
Cary Clarkab2621d2018-01-30 10:08:57 -05001565#Line # orders sides from smaller to larger ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001566Swaps fLeft and fRight if fLeft is greater than fRight; and swaps
1567fTop and fBottom if fTop is greater than fBottom. Result may be empty,
1568and width() and height() will be zero or positive.
1569
1570#Example
1571 SkIRect rect = { 30, 50, 20, 10 };
1572 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1573 rect.sort();
1574 SkDebugf("sorted: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1575#StdOut
1576rect: 30, 50, 20, 10
1577sorted: 20, 10, 30, 50
1578##
1579##
1580
1581#SeeAlso makeSorted SkRect::sort
1582
1583##
1584
1585# ------------------------------------------------------------------------------
1586
1587#Method SkIRect makeSorted() const
1588
Cary Clark4855f782018-02-06 09:41:53 -05001589#In Sorting
1590#In Constructor
Cary Clark682c58d2018-05-16 07:07:07 -04001591#Line # constructs IRect, ordering sides from smaller to larger ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001592Returns IRect with fLeft and fRight swapped if fLeft is greater than fRight; and
Cary Clark0c5f5462017-12-15 11:21:51 -05001593with fTop and fBottom swapped if fTop is greater than fBottom. Result may be empty;
1594and width() and height() will be zero or positive.
1595
1596#Return sorted IRect ##
1597
1598#Example
1599 SkIRect rect = { 30, 50, 20, 10 };
1600 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1601 SkIRect sort = rect.makeSorted();
1602 SkDebugf("sorted: %d, %d, %d, %d\n", sort.fLeft, sort.fTop, sort.fRight, sort.fBottom);
1603#StdOut
1604rect: 30, 50, 20, 10
1605sorted: 20, 10, 30, 50
1606##
1607##
1608
1609#SeeAlso sort SkRect::makeSorted
1610
1611##
1612
1613# ------------------------------------------------------------------------------
1614
1615#Method static const SkIRect& SK_WARN_UNUSED_RESULT EmptyIRect()
1616
Cary Clark4855f782018-02-06 09:41:53 -05001617#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -05001618#Line # returns immutable bounds of (0, 0, 0, 0) ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001619Returns a reference to immutable empty IRect, set to (0, 0, 0, 0).
1620
1621#Return global IRect set to all zeroes ##
1622
1623#Example
1624 const SkIRect& rect = SkIRect::EmptyIRect();
1625 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1626#StdOut
1627rect: 0, 0, 0, 0
1628##
1629##
1630
1631#SeeAlso MakeEmpty
1632
1633##
1634
Cary Clark0c95aab2018-01-08 16:20:59 -05001635#Method static SkIRect SK_WARN_UNUSED_RESULT MakeLargest()
Cary Clark0c95aab2018-01-08 16:20:59 -05001636#Deprecated
1637##
1638
Cary Clark0c5f5462017-12-15 11:21:51 -05001639#Struct SkIRect ##
1640
1641#Topic IRect ##