blob: 9c8d292e315d52d8303627159a1b1bcfe0c4458a [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 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 Clark2be81cf2018-09-13 12:04:30 -0400189Returns constructed IRect set to: #Formula # (x, y, x + w, y + h) ##.
190Does not validate input; w or h may be negative.
Cary Clark0c5f5462017-12-15 11:21:51 -0500191
192#Param x stored in fLeft ##
193#Param y stored in fTop ##
194#Param w added to x and stored in fRight ##
195#Param h added to y and stored in fBottom ##
196
197#Return bounds at (x, y) with width w and height h ##
198
199#Example
200 SkIRect rect = SkIRect::MakeXYWH(5, 35, -15, 25);
201 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
202 rect.bottom(), rect.isEmpty() ? "true" : "false");
203 rect.sort();
204 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
205 rect.bottom(), rect.isEmpty() ? "true" : "false");
206#StdOut
207rect: 5, 35, -10, 60 isEmpty: true
208rect: -10, 35, 5, 60 isEmpty: false
209##
210##
211
212#SeeAlso MakeLTRB SkRect::MakeXYWH
213
214##
215
Cary Clark4855f782018-02-06 09:41:53 -0500216#Subtopic Constructor ##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500217
Cary Clark4855f782018-02-06 09:41:53 -0500218#Subtopic Property
219#Line # member values, center, validity ##
220#Populate
221##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500222
Cary Clark0c5f5462017-12-15 11:21:51 -0500223# ------------------------------------------------------------------------------
224
Cary Clark6def7202018-01-04 08:13:35 -0500225#Method int32_t left() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500226
Cary Clark4855f782018-02-06 09:41:53 -0500227#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500228#Line # returns smaller bounds in x, if sorted ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500229Returns left edge of IRect, if sorted.
230Call sort() to reverse fLeft and fRight if needed.
231
232#Return fLeft ##
233
234#Example
235 SkIRect unsorted = { 15, 5, 10, 25 };
236 SkDebugf("unsorted.fLeft: %d unsorted.left(): %d\n", unsorted.fLeft, unsorted.left());
237 SkIRect sorted = unsorted.makeSorted();
238 SkDebugf("sorted.fLeft: %d sorted.left(): %d\n", sorted.fLeft, sorted.left());
239#StdOut
240unsorted.fLeft: 15 unsorted.left(): 15
241sorted.fLeft: 10 sorted.left(): 10
242##
243##
244
245#SeeAlso fLeft x() SkRect::left()
246
247##
248
249# ------------------------------------------------------------------------------
250
Cary Clark6def7202018-01-04 08:13:35 -0500251#Method int32_t top() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500252
Cary Clark4855f782018-02-06 09:41:53 -0500253#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500254#Line # returns smaller bounds in y, if sorted ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500255Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
256and sort() to reverse fTop and fBottom if needed.
257
258#Return fTop ##
259
260#Example
261 SkIRect unsorted = { 15, 25, 10, 5 };
262 SkDebugf("unsorted.fTop: %d unsorted.top(): %d\n", unsorted.fTop, unsorted.top());
263 SkIRect sorted = unsorted.makeSorted();
264 SkDebugf("sorted.fTop: %d sorted.top(): %d\n", sorted.fTop, sorted.top());
265#StdOut
266unsorted.fTop: 25 unsorted.top(): 25
267sorted.fTop: 5 sorted.top(): 5
268##
269##
270
271#SeeAlso fTop y() SkRect::top()
272
273##
274
275# ------------------------------------------------------------------------------
276
Cary Clark6def7202018-01-04 08:13:35 -0500277#Method int32_t right() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500278
Cary Clark4855f782018-02-06 09:41:53 -0500279#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500280#Line # returns larger bounds in x, if sorted ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500281Returns right edge of IRect, if sorted.
282Call sort() to reverse fLeft and fRight if needed.
283
284#Return fRight ##
285
286#Example
287 SkIRect unsorted = { 15, 25, 10, 5 };
288 SkDebugf("unsorted.fRight: %d unsorted.right(): %d\n", unsorted.fRight, unsorted.right());
289 SkIRect sorted = unsorted.makeSorted();
290 SkDebugf("sorted.fRight: %d sorted.right(): %d\n", sorted.fRight, sorted.right());
291#StdOut
292unsorted.fRight: 10 unsorted.right(): 10
293sorted.fRight: 15 sorted.right(): 15
294##
295##
296
297#SeeAlso fRight SkRect::right()
298
299##
300
301# ------------------------------------------------------------------------------
302
Cary Clark6def7202018-01-04 08:13:35 -0500303#Method int32_t bottom() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500304
Cary Clark4855f782018-02-06 09:41:53 -0500305#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500306#Line # returns larger bounds in y, if sorted ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500307Returns bottom edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
308and sort() to reverse fTop and fBottom if needed.
309
310#Return fBottom ##
311
312#Example
313 SkIRect unsorted = { 15, 25, 10, 5 };
314 SkDebugf("unsorted.fBottom: %d unsorted.bottom(): %d\n", unsorted.fBottom, unsorted.bottom());
315 SkIRect sorted = unsorted.makeSorted();
316 SkDebugf("sorted.fBottom: %d sorted.bottom(): %d\n", sorted.fBottom, sorted.bottom());
317#StdOut
318unsorted.fBottom: 5 unsorted.bottom(): 5
319sorted.fBottom: 25 sorted.bottom(): 25
320##
321##
322
323#SeeAlso fBottom SkRect::bottom()
324
325##
326
327# ------------------------------------------------------------------------------
328
Cary Clark6def7202018-01-04 08:13:35 -0500329#Method int32_t x() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500330
Cary Clark4855f782018-02-06 09:41:53 -0500331#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500332#Line # returns bounds left ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500333Returns left edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
334and sort() to reverse fLeft and fRight if needed.
335
336#Return fLeft ##
337
338#Example
339 SkIRect unsorted = { 15, 5, 10, 25 };
340 SkDebugf("unsorted.fLeft: %d unsorted.x(): %d\n", unsorted.fLeft, unsorted.x());
341 SkIRect sorted = unsorted.makeSorted();
342 SkDebugf("sorted.fLeft: %d sorted.x(): %d\n", sorted.fLeft, sorted.x());
343#StdOut
344unsorted.fLeft: 15 unsorted.x(): 15
345sorted.fLeft: 10 sorted.x(): 10
346##
347##
348
349#SeeAlso fLeft left() y() SkRect::x()
350
351##
352
353# ------------------------------------------------------------------------------
354
Cary Clark6def7202018-01-04 08:13:35 -0500355#Method int32_t y() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500356
Cary Clark4855f782018-02-06 09:41:53 -0500357#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500358#Line # returns bounds top ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500359Returns top edge of IRect, if sorted. Call isEmpty to see if IRect may be invalid,
360and sort() to reverse fTop and fBottom if needed.
361
362#Return fTop ##
363
364#Example
365 SkIRect unsorted = { 15, 25, 10, 5 };
366 SkDebugf("unsorted.fTop: %d unsorted.y(): %d\n", unsorted.fTop, unsorted.y());
367 SkIRect sorted = unsorted.makeSorted();
368 SkDebugf("sorted.fTop: %d sorted.y(): %d\n", sorted.fTop, sorted.y());
369#StdOut
370unsorted.fTop: 25 unsorted.y(): 25
371sorted.fTop: 5 sorted.y(): 5
372##
373##
374
375#SeeAlso fTop top() x() SkRect::y()
376
377##
378
379# ------------------------------------------------------------------------------
380
Cary Clark6def7202018-01-04 08:13:35 -0500381#Method int32_t width() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500382
Cary Clark4855f782018-02-06 09:41:53 -0500383#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500384#Line # returns span in x ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500385Returns span on the x-axis. This does not check if IRect is sorted, or if
386result fits in 32-bit signed integer; result may be negative.
387
388#Return fRight minus fLeft ##
389
390#Example
391 SkIRect unsorted = { 15, 25, 10, 5 };
392 SkDebugf("unsorted width: %d\n", unsorted.width());
393 SkIRect large = { -2147483647, 1, 2147483644, 2 };
394 SkDebugf("large width: %d\n", large.width());
395#StdOut
396unsorted width: -5
397large width: -5
398##
399##
400
Mike Reeda766ca92018-01-09 11:31:53 -0500401#SeeAlso height() width64() height64() SkRect::width()
402
403##
404
405# ------------------------------------------------------------------------------
406
407#Method int64_t width64() const
408
Cary Clark4855f782018-02-06 09:41:53 -0500409#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500410#Line # returns span in y as int64_t ##
Mike Reeda766ca92018-01-09 11:31:53 -0500411Returns span on the x-axis. This does not check if IRect is sorted, so the
412result may be negative. This is safer than calling width() since width() might
413overflow in its calculation.
414
415#Return fRight minus fLeft cast to int64_t ##
416
Cary Clark186d08f2018-04-03 08:43:27 -0400417#Example
Mike Reeda766ca92018-01-09 11:31:53 -0500418SkIRect large = { -2147483647, 1, 2147483644, 2 };
Cary Clark186d08f2018-04-03 08:43:27 -0400419SkDebugf("width: %d width64: %lld\n", large.width(), large.width64());
Mike Reeda766ca92018-01-09 11:31:53 -0500420#StdOut
421width: -5 width64: 4294967291
422##
423##
424
425#SeeAlso width() height() height64() SkRect::width()
Cary Clark0c5f5462017-12-15 11:21:51 -0500426
427##
428
429# ------------------------------------------------------------------------------
430
Cary Clark6def7202018-01-04 08:13:35 -0500431#Method int32_t height() const
Cary Clark0c5f5462017-12-15 11:21:51 -0500432
Cary Clark4855f782018-02-06 09:41:53 -0500433#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500434#Line # returns span in y ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500435Returns span on the y-axis. This does not check if IRect is sorted, or if
436result fits in 32-bit signed integer; result may be negative.
437
438#Return fBottom minus fTop ##
439
440#Example
441 SkIRect unsorted = { 15, 25, 10, 20 };
442 SkDebugf("unsorted height: %d\n", unsorted.height());
443 SkIRect large = { 1, -2147483647, 2, 2147483644 };
444 SkDebugf("large height: %d\n", large.height());
445#StdOut
446unsorted height: -5
447large height: -5
448##
449##
450
451#SeeAlso width() SkRect::height()
452
453##
454
455# ------------------------------------------------------------------------------
456
Mike Reeda766ca92018-01-09 11:31:53 -0500457#Method int64_t height64() const
458
Cary Clark4855f782018-02-06 09:41:53 -0500459#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500460#Line # returns span in y as int64_t ##
Mike Reeda766ca92018-01-09 11:31:53 -0500461Returns span on the y-axis. This does not check if IRect is sorted, so the
462result may be negative. This is safer than calling height() since height() might
463overflow in its calculation.
464
465#Return fBottom minus fTop cast to int64_t ##
466
Cary Clark186d08f2018-04-03 08:43:27 -0400467#Example
Mike Reeda766ca92018-01-09 11:31:53 -0500468SkIRect large = { 1, -2147483647, 2, 2147483644 };
469SkDebugf("height: %d height64: %lld\n", large.height(), large.height64());
470#StdOut
471height: -5 height64: 4294967291
472##
473##
474
475#SeeAlso width() height() width64() SkRect::height()
476
477##
478
479# ------------------------------------------------------------------------------
480
Cary Clark0c5f5462017-12-15 11:21:51 -0500481#Method SkISize size() const
482
Cary Clark4855f782018-02-06 09:41:53 -0500483#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500484#Line # returns ISize (width, height) ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500485Returns spans on the x-axis and y-axis. This does not check if IRect is sorted,
486or if result fits in 32-bit signed integer; result may be negative.
487
488#Return ISize (width, height) ##
489
490#Example
491 auto debugster = [](const char* prefix, const SkIRect& rect) -> void {
492 SkISize size = rect.size();
493 SkDebugf("%s ", prefix);
494 SkDebugf("rect: %d, %d, %d, %d ", rect.left(), rect.top(), rect.right(), rect.bottom());
495 SkDebugf("size: %d, %d\n", size.width(), size.height());
496 };
497 SkIRect rect = {20, 30, 40, 50};
498 debugster("original", rect);
499 rect.offset(20, 20);
500 debugster(" offset", rect);
501 rect.outset(20, 20);
502 debugster(" outset", rect);
503#StdOut
504original rect: 20, 30, 40, 50 size: 20, 20
505 offset rect: 40, 50, 60, 70 size: 20, 20
506 outset rect: 20, 30, 80, 90 size: 60, 60
507##
508##
509
510#SeeAlso height() width() MakeSize
511
512##
513
514# ------------------------------------------------------------------------------
515
Cary Clark0c5f5462017-12-15 11:21:51 -0500516#Method bool isEmpty() const
517
Cary Clark4855f782018-02-06 09:41:53 -0500518#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500519#Line # returns true if width or height are zero or negative or they exceed int32_t ##
Mike Reedd2849492018-01-10 14:31:18 -0500520Returns true if width() or height() .
Cary Clark0c5f5462017-12-15 11:21:51 -0500521
522#Return true if width() or height() are zero or negative ##
523
524#Example
525 SkIRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}};
526 for (auto rect : tests) {
527 SkDebugf("rect: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
528 rect.bottom(), rect.isEmpty() ? "" : " not");
529 rect.sort();
530 SkDebugf("sorted: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
531 rect.bottom(), rect.isEmpty() ? "" : " not");
532 }
533#StdOut
534rect: {20, 40, 10, 50} is empty
535sorted: {10, 40, 20, 50} is not empty
536rect: {20, 40, 20, 50} is empty
537sorted: {20, 40, 20, 50} is empty
538##
539##
540
541#SeeAlso EmptyIRect MakeEmpty sort SkRect::isEmpty
542
543##
544
545# ------------------------------------------------------------------------------
546
Mike Reedd2849492018-01-10 14:31:18 -0500547#Method bool isEmpty64() const
548
Cary Clark4855f782018-02-06 09:41:53 -0500549#In Property
Cary Clarkab2621d2018-01-30 10:08:57 -0500550#Line # returns true if width or height are zero or negative ##
Mike Reedd2849492018-01-10 14:31:18 -0500551Returns true if fLeft is equal to or greater than fRight, or if fTop is equal
552to or greater than fBottom. Call sort() to reverse rectangles with negative
553width64() or height64().
554
555#Return true if width64() or height64() are zero or negative ##
556
Cary Clark186d08f2018-04-03 08:43:27 -0400557#Example
Mike Reedd2849492018-01-10 14:31:18 -0500558SkIRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}};
559for (auto rect : tests) {
Cary Clark186d08f2018-04-03 08:43:27 -0400560 SkDebugf("rect: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
561 rect.bottom(), rect.isEmpty64() ? "" : " not");
562 rect.sort();
563 SkDebugf("sorted: {%d, %d, %d, %d} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
564 rect.bottom(), rect.isEmpty64() ? "" : " not");
Mike Reedd2849492018-01-10 14:31:18 -0500565}
566#StdOut
567rect: {20, 40, 10, 50} is empty
568sorted: {10, 40, 20, 50} is not empty
569rect: {20, 40, 20, 50} is empty
570sorted: {20, 40, 20, 50} is empty
571##
572##
573
574#SeeAlso EmptyIRect MakeEmpty sort SkRect::isEmpty
575
576##
577
Cary Clark4855f782018-02-06 09:41:53 -0500578#Subtopic Operator
Cary Clark08895c42018-02-01 09:37:32 -0500579#Populate
Cary Clark2dc84ad2018-01-26 12:56:22 -0500580
Mike Reedd2849492018-01-10 14:31:18 -0500581# ------------------------------------------------------------------------------
582
Cary Clark0c5f5462017-12-15 11:21:51 -0500583#Method bool operator==(const SkIRect& a, const SkIRect& b)
584
Cary Clark4855f782018-02-06 09:41:53 -0500585#In Operator
Cary Clarkab2621d2018-01-30 10:08:57 -0500586#Line # returns true if members are equal ##
Cary Clark682c58d2018-05-16 07:07:07 -0400587Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are
Cary Clark0c5f5462017-12-15 11:21:51 -0500588identical to corresponding members in b.
589
590#Param a IRect to compare ##
591#Param b IRect to compare ##
592
593#Return true if members are equal ##
594
595#Example
596 SkIRect test = {0, 0, 2, 2};
597 SkIRect sorted = test.makeSorted();
598 SkDebugf("test %c= sorted\n", test == sorted ? '=' : '!');
599#StdOut
600test == sorted
601##
602##
603
604#SeeAlso operator!=(const SkIRect& a, const SkIRect& b)
605
606##
607
608# ------------------------------------------------------------------------------
609
610#Method bool operator!=(const SkIRect& a, const SkIRect& b)
611
Cary Clark4855f782018-02-06 09:41:53 -0500612#In Operator
Cary Clarkab2621d2018-01-30 10:08:57 -0500613#Line # returns true if members are unequal ##
Cary Clark682c58d2018-05-16 07:07:07 -0400614Returns true if any member in a: fLeft, fTop, fRight, and fBottom; is not
Cary Clark0c5f5462017-12-15 11:21:51 -0500615identical to the corresponding member in b.
616
617#Param a IRect to compare ##
618#Param b IRect to compare ##
619
620#Return true if members are not equal ##
621
622#Example
623 SkIRect test = {2, 2, 0, 0};
624 SkIRect sorted = test.makeSorted();
625 SkDebugf("test %c= sorted\n", test != sorted ? '!' : '=');
626#StdOut
627test != sorted
628##
629##
630
631#SeeAlso operator==(const SkIRect& a, const SkIRect& b)
632
633##
634
Cary Clark4855f782018-02-06 09:41:53 -0500635#Subtopic Operator ##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500636
Cary Clark0c5f5462017-12-15 11:21:51 -0500637# ------------------------------------------------------------------------------
638
Cary Clark78de7512018-02-07 07:27:09 -0500639#Subtopic Set
640#Line # replaces all values ##
641#Populate
642##
Cary Clark0c5f5462017-12-15 11:21:51 -0500643
644#Method void setEmpty()
645
Cary Clark4855f782018-02-06 09:41:53 -0500646#In Set
Cary Clarkab2621d2018-01-30 10:08:57 -0500647#Line # sets to (0, 0, 0, 0) ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500648Sets IRect to (0, 0, 0, 0).
649
650Many other rectangles are empty; if left is equal to or greater than right,
651or if top is equal to or greater than bottom. Setting all members to zero
652is a convenience, but does not designate a special empty rectangle.
653
654#Example
655 SkIRect rect = {3, 4, 1, 2};
656 for (int i = 0; i < 2; ++i) {
657 SkDebugf("rect: {%d, %d, %d, %d} is %s" "empty\n", rect.fLeft, rect.fTop,
658 rect.fRight, rect.fBottom, rect.isEmpty() ? "" : "not ");
659 rect.setEmpty();
660 }
661#StdOut
662rect: {3, 4, 1, 2} is empty
663rect: {0, 0, 0, 0} is empty
664##
665##
666
667#SeeAlso MakeEmpty SkRect::setEmpty
668
669##
670
671# ------------------------------------------------------------------------------
672
673#Method void set(int32_t left, int32_t top, int32_t right, int32_t bottom)
674
Cary Clark4855f782018-02-06 09:41:53 -0500675#In Set
Cary Clarkab2621d2018-01-30 10:08:57 -0500676#Line # sets to (left, top, right, bottom) ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500677Sets IRect to (left, top, right, bottom).
678left and right are not sorted; left is not necessarily less than right.
679top and bottom are not sorted; top is not necessarily less than bottom.
680
681#Param left assigned to fLeft ##
682#Param top assigned to fTop ##
683#Param right assigned to fRight ##
684#Param bottom assigned to fBottom ##
685
686#Example
687 SkIRect rect1 = {3, 4, 1, 2};
688 SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
689 SkIRect rect2;
690 rect2.set(3, 4, 1, 2);
691 SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
692#StdOut
693rect1: {3, 4, 1, 2}
694rect2: {3, 4, 1, 2}
695##
696##
697
698#SeeAlso setLTRB setXYWH SkRect::set
699
700##
701
702# ------------------------------------------------------------------------------
703
704#Method void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom)
705
Cary Clark4855f782018-02-06 09:41:53 -0500706#In Set
Cary Clarkab2621d2018-01-30 10:08:57 -0500707#Line # sets to SkScalar input (left, top, right, bottom) ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500708Sets IRect to (left, top, right, bottom).
709left and right are not sorted; left is not necessarily less than right.
710top and bottom are not sorted; top is not necessarily less than bottom.
711
712#Param left stored in fLeft ##
713#Param top stored in fTop ##
714#Param right stored in fRight ##
715#Param bottom stored in fBottom ##
716
717#Example
718 SkIRect rect1 = {3, 4, 1, 2};
719 SkDebugf("rect1: {%d, %d, %d, %d}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
720 SkIRect rect2;
721 rect2.setLTRB(3, 4, 1, 2);
722 SkDebugf("rect2: {%d, %d, %d, %d}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
723#StdOut
724rect1: {3, 4, 1, 2}
725rect2: {3, 4, 1, 2}
726##
727##
728
729#SeeAlso set setXYWH SkRect::setLTRB
730
731##
732
733# ------------------------------------------------------------------------------
734
735#Method void setXYWH(int32_t x, int32_t y, int32_t width, int32_t height)
736
Cary Clark4855f782018-02-06 09:41:53 -0500737#In Set
Cary Clarkab2621d2018-01-30 10:08:57 -0500738#Line # sets to (x, y, width, height) ##
Cary Clark2be81cf2018-09-13 12:04:30 -0400739Sets IRect to: #Formula # (x, y, x + width, y + height) ##.
740Does not validate input; width or height may be negative.
Cary Clark0c5f5462017-12-15 11:21:51 -0500741
742#Param x stored in fLeft ##
743#Param y stored in fTop ##
744#Param width added to x and stored in fRight ##
745#Param height added to y and stored in fBottom ##
746
747#Example
748 SkIRect rect;
749 rect.setXYWH(5, 35, -15, 25);
750 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
751 rect.bottom(), rect.isEmpty() ? "true" : "false");
752 rect.sort();
753 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
754 rect.bottom(), rect.isEmpty() ? "true" : "false");
755#StdOut
756rect: 5, 35, -10, 60 isEmpty: true
757rect: -10, 35, 5, 60 isEmpty: false
758##
759##
760
761#SeeAlso MakeXYWH setLTRB set SkRect::setXYWH
762
763##
764
Cary Clark2dc84ad2018-01-26 12:56:22 -0500765#Subtopic Inset_Outset_Offset
Cary Clark08895c42018-02-01 09:37:32 -0500766#Line # moves sides ##
Cary Clark4855f782018-02-06 09:41:53 -0500767#Populate
Cary Clark2dc84ad2018-01-26 12:56:22 -0500768
Cary Clark0c5f5462017-12-15 11:21:51 -0500769# ------------------------------------------------------------------------------
770
Cary Clark0c5f5462017-12-15 11:21:51 -0500771#Method SkIRect makeOffset(int32_t dx, int32_t dy) const
772
Cary Clarkab2621d2018-01-30 10:08:57 -0500773#In Inset_Outset_Offset
774#Line # constructs from translated sides ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500775Returns IRect offset by (dx, dy).
776
777If dx is negative, IRect returned is moved to the left.
778If dx is positive, IRect returned is moved to the right.
779If dy is negative, IRect returned is moved upward.
Cary Clark682c58d2018-05-16 07:07:07 -0400780If dy is positive, IRect returned is moved downward.
Cary Clark0c5f5462017-12-15 11:21:51 -0500781
782#Param dx offset added to fLeft and fRight ##
783#Param dy offset added to fTop and fBottom ##
784
Cary Clark5538c132018-06-14 12:28:14 -0400785#Return IRect offset by dx and dy, with original width and height ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500786
787#Example
788 SkIRect rect = { 10, 50, 20, 60 };
789 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
790 rect.bottom(), rect.isEmpty() ? "true" : "false");
791 rect = rect.makeOffset(15, 32);
792 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
793 rect.bottom(), rect.isEmpty() ? "true" : "false");
794#StdOut
795rect: 10, 50, 20, 60 isEmpty: false
796rect: 25, 82, 35, 92 isEmpty: false
797##
798##
799
800#SeeAlso offset() makeInset makeOutset SkRect::makeOffset
801
802##
803
804# ------------------------------------------------------------------------------
805
806#Method SkIRect makeInset(int32_t dx, int32_t dy) const
807
Cary Clarkab2621d2018-01-30 10:08:57 -0500808#In Inset_Outset_Offset
809#Line # constructs from sides moved symmetrically about the center ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500810Returns IRect, inset by (dx, dy).
811
812If dx is negative, IRect returned is wider.
813If dx is positive, IRect returned is narrower.
814If dy is negative, IRect returned is taller.
Cary Clark682c58d2018-05-16 07:07:07 -0400815If dy is positive, IRect returned is shorter.
Cary Clark0c5f5462017-12-15 11:21:51 -0500816
817#Param dx offset added to fLeft and subtracted from fRight ##
818#Param dy offset added to fTop and subtracted from fBottom ##
819
Cary Clark2dc84ad2018-01-26 12:56:22 -0500820#Return IRect inset symmetrically left and right, top and bottom ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500821
822#Example
823 SkIRect rect = { 10, 50, 20, 60 };
824 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
825 rect.bottom(), rect.isEmpty() ? "true" : "false");
826 rect = rect.makeInset(15, 32);
827 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
828 rect.bottom(), rect.isEmpty() ? "true" : "false");
829#StdOut
830rect: 10, 50, 20, 60 isEmpty: false
831rect: 25, 82, 5, 28 isEmpty: true
832##
833##
834
835#SeeAlso inset() makeOffset makeOutset SkRect::makeInset
836
837##
838
839# ------------------------------------------------------------------------------
840
841#Method SkIRect makeOutset(int32_t dx, int32_t dy) const
842
Cary Clarkab2621d2018-01-30 10:08:57 -0500843#In Inset_Outset_Offset
844#Line # constructs from sides moved symmetrically about the center ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500845Returns IRect, outset by (dx, dy).
846
847If dx is negative, IRect returned is narrower.
848If dx is positive, IRect returned is wider.
849If dy is negative, IRect returned is shorter.
Cary Clark682c58d2018-05-16 07:07:07 -0400850If dy is positive, IRect returned is taller.
Cary Clark0c5f5462017-12-15 11:21:51 -0500851
852#Param dx offset subtracted to fLeft and added from fRight ##
853#Param dy offset subtracted to fTop and added from fBottom ##
854
Cary Clark2dc84ad2018-01-26 12:56:22 -0500855#Return IRect outset symmetrically left and right, top and bottom ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500856
857#Example
858 SkIRect rect = { 10, 50, 20, 60 };
859 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
860 rect.bottom(), rect.isEmpty() ? "true" : "false");
861 rect = rect.makeOutset(15, 32);
862 SkDebugf("rect: %d, %d, %d, %d isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
863 rect.bottom(), rect.isEmpty() ? "true" : "false");
864#StdOut
865rect: 10, 50, 20, 60 isEmpty: false
866rect: -5, 18, 35, 92 isEmpty: false
867##
868##
869
870#SeeAlso outset() makeOffset makeInset SkRect::makeOutset
871
872##
873
874# ------------------------------------------------------------------------------
875
876#Method void offset(int32_t dx, int32_t dy)
877
Cary Clarkab2621d2018-01-30 10:08:57 -0500878#In Inset_Outset_Offset
879#Line # translates sides without changing width and height ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500880Offsets IRect by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom.
881
882If dx is negative, moves IRect returned to the left.
883If dx is positive, moves IRect returned to the right.
884If dy is negative, moves IRect returned upward.
Cary Clark682c58d2018-05-16 07:07:07 -0400885If dy is positive, moves IRect returned downward.
Cary Clark0c5f5462017-12-15 11:21:51 -0500886
887#Param dx offset added to fLeft and fRight ##
888#Param dy offset added to fTop and fBottom ##
889
890#Example
891 SkIRect rect = { 10, 14, 50, 73 };
892 rect.offset(5, 13);
893 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
894#StdOut
895rect: 15, 27, 55, 86
896##
897##
898
899#SeeAlso offsetTo makeOffset SkRect::offset
900
901##
902
903# ------------------------------------------------------------------------------
904
905#Method void offset(const SkIPoint& delta)
906
Cary Clarkab2621d2018-01-30 10:08:57 -0500907#In Inset_Outset_Offset
Cary Clark0c5f5462017-12-15 11:21:51 -0500908Offsets IRect by adding delta.fX to fLeft, fRight; and by adding delta.fY to
909fTop, fBottom.
910
911If delta.fX is negative, moves IRect returned to the left.
912If delta.fX is positive, moves IRect returned to the right.
913If delta.fY is negative, moves IRect returned upward.
Cary Clark682c58d2018-05-16 07:07:07 -0400914If delta.fY is positive, moves IRect returned downward.
Cary Clark0c5f5462017-12-15 11:21:51 -0500915
916#Param delta offset added to IRect ##
917
918#Example
919 SkIRect rect = { 10, 14, 50, 73 };
920 rect.offset({5, 13});
921 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
922#StdOut
923rect: 15, 27, 55, 86
924##
925##
926
927#SeeAlso offsetTo makeOffset SkRect::offset
928
929##
930
931# ------------------------------------------------------------------------------
932
933#Method void offsetTo(int32_t newX, int32_t newY)
934
Cary Clarkab2621d2018-01-30 10:08:57 -0500935#In Inset_Outset_Offset
936#Line # translates to (x, y) without changing width and height ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500937Offsets IRect so that fLeft equals newX, and fTop equals newY. width and height
938are unchanged.
939
940#Param newX stored in fLeft, preserving width() ##
941#Param newY stored in fTop, preserving height() ##
942
943#Example
944 SkIRect rect = { 10, 14, 50, 73 };
945 rect.offsetTo(15, 27);
946 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
947#StdOut
948rect: 15, 27, 55, 86
949##
950##
951
952#SeeAlso offset makeOffset setXYWH SkRect::offsetTo
953
954##
955
956# ------------------------------------------------------------------------------
957
958#Method void inset(int32_t dx, int32_t dy)
959
Cary Clarkab2621d2018-01-30 10:08:57 -0500960#In Inset_Outset_Offset
961#Line # moves the sides symmetrically about the center ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500962Insets IRect by (dx,dy).
963
964If dx is positive, makes IRect narrower.
965If dx is negative, makes IRect wider.
966If dy is positive, makes IRect shorter.
967If dy is negative, makes IRect taller.
968
969#Param dx offset added to fLeft and subtracted from fRight ##
970#Param dy offset added to fTop and subtracted from fBottom ##
971
972#Example
973 SkIRect rect = { 10, 14, 50, 73 };
974 rect.inset(5, 13);
975 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
976#StdOut
977rect: 15, 27, 45, 60
978##
979##
980
981#SeeAlso outset makeInset SkRect::inset
982
983##
984
985# ------------------------------------------------------------------------------
986
987#Method void outset(int32_t dx, int32_t dy)
988
Cary Clarkab2621d2018-01-30 10:08:57 -0500989#In Inset_Outset_Offset
990#Line # moves the sides symmetrically about the center ##
Cary Clark0c5f5462017-12-15 11:21:51 -0500991Outsets IRect by (dx, dy).
992
Cary Clark2dc84ad2018-01-26 12:56:22 -0500993If dx is positive, makes IRect wider.
994If dx is negative, makes IRect narrower.
995If dy is positive, makes IRect taller.
996If dy is negative, makes IRect shorter.
Cary Clark0c5f5462017-12-15 11:21:51 -0500997
998#Param dx subtracted to fLeft and added from fRight ##
999#Param dy subtracted to fTop and added from fBottom ##
1000
1001#Example
1002 SkIRect rect = { 10, 14, 50, 73 };
1003 rect.outset(5, 13);
1004 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1005#StdOut
1006rect: 5, 1, 55, 86
1007##
1008##
1009
1010#SeeAlso inset makeOutset SkRect::outset
1011
1012##
1013
Cary Clark2dc84ad2018-01-26 12:56:22 -05001014#Subtopic Inset_Outset_Offset ##
1015
1016#Subtopic Intersection
Cary Clark682c58d2018-05-16 07:07:07 -04001017#Line # sets to shared bounds ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001018
Cary Clark682c58d2018-05-16 07:07:07 -04001019IRects intersect when they enclose a common area. To intersect, each of the pair
Cary Clark2dc84ad2018-01-26 12:56:22 -05001020must describe area; fLeft is less than fRight, and fTop is less than fBottom;
1021empty() returns false. The intersection of IRect pair can be described by:
Cary Clark2be81cf2018-09-13 12:04:30 -04001022#Formula # (max(a.fLeft, b.fLeft), max(a.fTop, b.fTop),
1023 min(a.fRight, b.fRight), min(a.fBottom, b.fBottom)) ##.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001024
1025The intersection is only meaningful if the resulting IRect is not empty and
1026describes an area: fLeft is less than fRight, and fTop is less than fBottom.
1027
Cary Clark4855f782018-02-06 09:41:53 -05001028#Populate
Cary Clark2dc84ad2018-01-26 12:56:22 -05001029
Cary Clark0c5f5462017-12-15 11:21:51 -05001030# ------------------------------------------------------------------------------
1031
Robert Phillips8f8d4812018-05-18 10:19:05 -04001032#Method void adjust(int32_t dL, int32_t dT, int32_t dR, int32_t dB)
1033
1034#In Inset_Outset_Offset
1035#Line # moves the sides independently relative to their original locations ##
Cary Clarkdbc90e42018-05-18 11:57:17 -04001036Adjusts IRect by adding dL to fLeft, dT to fTop, dR to fRight, and dB to fBottom.
Robert Phillips8f8d4812018-05-18 10:19:05 -04001037
1038If dL is positive, narrows IRect on the left. If negative, widens it on the left.
1039If dT is positive, shrinks IRect on the top. If negative, lengthens it on the top.
1040If dR is positive, narrows IRect on the right. If negative, widens it on the right.
1041If dB is positive, shrinks IRect on the bottom. If negative, lengthens it on the bottom.
1042
1043The resulting IRect is not checked for validity. Thus, if the resulting IRect left is
1044greater than right, the IRect will be considered empty. Call sort() after this call
1045if that is not the desired behavior.
1046
1047#Param dL offset added to fLeft ##
1048#Param dT offset added to fTop ##
1049#Param dR offset added to fRight ##
1050#Param dB offset added to fBottom ##
1051
1052#Example
1053 SkIRect rect = { 8, 11, 19, 22 };
1054 rect.adjust(2, -1, 1, -2);
1055 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1056#StdOut
1057rect: 10, 10, 20, 20
1058##
1059##
1060
1061#SeeAlso inset outset
1062
1063##
1064
1065# ------------------------------------------------------------------------------
1066
Cary Clark0c5f5462017-12-15 11:21:51 -05001067#Method bool contains(int32_t x, int32_t y) const
1068
Cary Clarkab2621d2018-01-30 10:08:57 -05001069#In Intersection
Cary Clark300cc5b2018-02-20 12:50:35 -05001070#Line # returns true if IPoint (x, y) is equal or inside ##
Cary Clark2be81cf2018-09-13 12:04:30 -04001071Returns true if: #Formula # fLeft <= x < fRight && fTop <= y < fBottom ##.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001072Returns false if IRect is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001073
Cary Clark2be81cf2018-09-13 12:04:30 -04001074Considers input to describe constructed IRect: #Formula # (x, y, x + 1, y + 1) ## and
Cary Clark0c5f5462017-12-15 11:21:51 -05001075returns true if constructed area is completely enclosed by IRect area.
1076
Cary Clark300cc5b2018-02-20 12:50:35 -05001077#Param x test IPoint x-coordinate ##
1078#Param y test IPoint y-coordinate ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001079
1080#Return true if (x, y) is inside IRect ##
1081
1082#Example
1083 SkIRect rect = { 30, 50, 40, 60 };
1084 SkIPoint pts[] = { { 30, 50}, { 40, 50}, { 30, 60} };
1085 for (auto pt : pts) {
1086 SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d)\n",
1087 rect.left(), rect.top(), rect.right(), rect.bottom(),
1088 rect.contains(pt.x(), pt.y()) ? "contains" : "does not contain", pt.x(), pt.y());
1089 }
1090#StdOut
1091rect: (30, 50, 40, 60) contains (30, 50)
1092rect: (30, 50, 40, 60) does not contain (40, 50)
1093rect: (30, 50, 40, 60) does not contain (30, 60)
1094##
1095##
1096
1097#SeeAlso containsNoEmptyCheck SkRect::contains
1098
1099##
1100
1101# ------------------------------------------------------------------------------
1102
1103#Method bool contains(int32_t left, int32_t top, int32_t right, int32_t bottom) const
1104
Cary Clarkab2621d2018-01-30 10:08:57 -05001105#In Intersection
Cary Clark2dc84ad2018-01-26 12:56:22 -05001106Constructs IRect to intersect from (left, top, right, bottom). Does not sort
Cary Clark0c5f5462017-12-15 11:21:51 -05001107construction.
1108
Cary Clark2dc84ad2018-01-26 12:56:22 -05001109Returns true if IRect contains construction.
1110Returns false if IRect is empty or construction is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001111
Cary Clark5538c132018-06-14 12:28:14 -04001112#Param left x-axis minimum of constructed IRect ##
1113#Param top y-axis minimum of constructed IRect ##
1114#Param right x-axis maximum of constructed IRect ##
1115#Param bottom y-axis maximum of constructed IRect ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001116
1117#Return true if all sides of IRect are outside construction ##
1118
1119#Example
1120 SkIRect rect = { 30, 50, 40, 60 };
1121 SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1122 for (auto contained : tests) {
1123 bool success = rect.contains(
1124 contained.left(), contained.top(), contained.right(), contained.bottom());
1125 SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
1126 rect.left(), rect.top(), rect.right(), rect.bottom(),
1127 success ? "contains" : "does not contain",
1128 contained.left(), contained.top(), contained.right(), contained.bottom());
1129 }
1130#StdOut
1131rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1132rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1133rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1134##
1135##
1136
1137#SeeAlso containsNoEmptyCheck SkRect::contains
1138
1139##
1140
1141# ------------------------------------------------------------------------------
1142
1143#Method bool contains(const SkIRect& r) const
1144
Cary Clarkab2621d2018-01-30 10:08:57 -05001145#In Intersection
Cary Clark2dc84ad2018-01-26 12:56:22 -05001146Returns true if IRect contains r.
1147Returns false if IRect is empty or r is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001148
Cary Clark2dc84ad2018-01-26 12:56:22 -05001149IRect contains r when IRect area completely includes r area.
Cary Clark0c5f5462017-12-15 11:21:51 -05001150
1151#Param r IRect contained ##
1152
1153#Return true if all sides of IRect are outside r ##
1154
1155#Example
1156 SkIRect rect = { 30, 50, 40, 60 };
1157 SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1158 for (auto contained : tests) {
1159 SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
1160 rect.left(), rect.top(), rect.right(), rect.bottom(),
1161 rect.contains(contained) ? "contains" : "does not contain",
1162 contained.left(), contained.top(), contained.right(), contained.bottom());
1163 }
1164#StdOut
1165rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1166rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1167rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1168##
1169##
1170
1171#SeeAlso containsNoEmptyCheck SkRect::contains
1172
1173##
1174
1175# ------------------------------------------------------------------------------
1176
1177#Method bool contains(const SkRect& r) const
1178
Cary Clarkab2621d2018-01-30 10:08:57 -05001179#In Intersection
Cary Clark2dc84ad2018-01-26 12:56:22 -05001180Returns true if IRect contains r.
1181Returns false if IRect is empty or r is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001182
Cary Clark2dc84ad2018-01-26 12:56:22 -05001183IRect contains r when IRect area completely includes r area.
Cary Clark0c5f5462017-12-15 11:21:51 -05001184
1185#Param r Rect contained ##
1186
1187#Return true if all sides of IRect are outside r ##
1188
1189#Example
1190 SkIRect rect = { 30, 50, 40, 60 };
1191 SkRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1192 for (auto contained : tests) {
1193 SkDebugf("rect: (%d, %d, %d, %d) %s (%g, %g, %g, %g)\n",
1194 rect.left(), rect.top(), rect.right(), rect.bottom(),
1195 rect.contains(contained) ? "contains" : "does not contain",
1196 contained.left(), contained.top(), contained.right(), contained.bottom());
1197 }
1198#StdOut
1199rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1200rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1201rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1202##
1203##
1204
1205#SeeAlso containsNoEmptyCheck SkRect::contains
1206
1207##
1208
1209# ------------------------------------------------------------------------------
1210
1211#Method bool containsNoEmptyCheck(int32_t left, int32_t top,
1212 int32_t right, int32_t bottom) const
Cary Clarkab2621d2018-01-30 10:08:57 -05001213#In Intersection
Cary Clark300cc5b2018-02-20 12:50:35 -05001214#Line # returns true if contains unsorted IRect ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001215
1216Constructs IRect from (left, top, right, bottom). Does not sort
1217construction.
1218
Cary Clark2dc84ad2018-01-26 12:56:22 -05001219Returns true if IRect contains construction.
Cary Clark0c5f5462017-12-15 11:21:51 -05001220Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined.
1221
Cary Clark2dc84ad2018-01-26 12:56:22 -05001222Return is undefined if IRect is empty or construction is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001223
Cary Clark5538c132018-06-14 12:28:14 -04001224#Param left x-axis minimum of constructed IRect ##
1225#Param top y-axis minimum of constructed IRect ##
1226#Param right x-axis maximum of constructed IRect ##
1227#Param bottom y-axis maximum of constructed IRect ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001228
1229#Return true if all sides of IRect are outside construction ##
1230
1231#Example
1232 SkIRect rect = { 30, 50, 40, 60 };
1233 SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1234 for (auto contained : tests) {
1235 bool success = rect.containsNoEmptyCheck(
1236 contained.left(), contained.top(), contained.right(), contained.bottom());
1237 SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
1238 rect.left(), rect.top(), rect.right(), rect.bottom(),
1239 success ? "contains" : "does not contain",
1240 contained.left(), contained.top(), contained.right(), contained.bottom());
1241 }
1242#StdOut
1243rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1244rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1245rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1246##
1247##
1248
1249#SeeAlso contains SkRect::contains
1250
1251##
1252
1253# ------------------------------------------------------------------------------
1254
1255#Method bool containsNoEmptyCheck(const SkIRect& r) const
1256
Cary Clarkab2621d2018-01-30 10:08:57 -05001257#In Intersection
Cary Clark2dc84ad2018-01-26 12:56:22 -05001258Returns true if IRect contains construction.
Cary Clark0c5f5462017-12-15 11:21:51 -05001259Asserts if IRect is empty or construction is empty, and if SK_DEBUG is defined.
1260
Cary Clark2dc84ad2018-01-26 12:56:22 -05001261Return is undefined if IRect is empty or construction is empty.
Cary Clark0c5f5462017-12-15 11:21:51 -05001262
Cary Clark2dc84ad2018-01-26 12:56:22 -05001263#Param r IRect contained ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001264
1265#Return true if all sides of IRect are outside r ##
1266
1267#Example
1268 SkIRect rect = { 30, 50, 40, 60 };
1269 SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1270 for (auto contained : tests) {
1271 SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
1272 rect.left(), rect.top(), rect.right(), rect.bottom(),
1273 rect.containsNoEmptyCheck(contained) ? "contains" : "does not contain",
1274 contained.left(), contained.top(), contained.right(), contained.bottom());
1275 }
1276#StdOut
1277rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1278rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1279rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1280##
1281##
1282
1283#SeeAlso contains SkRect::contains
1284
1285##
1286
Cary Clark0c5f5462017-12-15 11:21:51 -05001287# ------------------------------------------------------------------------------
1288
1289#Method bool intersect(const SkIRect& r)
1290
Cary Clarkab2621d2018-01-30 10:08:57 -05001291#In Intersection
1292#Line # sets to shared area; returns true if not empty ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001293Returns true if IRect intersects r, and sets IRect to intersection.
1294Returns false if IRect does not intersect r, and leaves IRect unchanged.
1295
1296Returns false if either r or IRect is empty, leaving IRect unchanged.
1297
1298#Param r limit of result ##
1299
Cary Clark2dc84ad2018-01-26 12:56:22 -05001300#Return true if r and IRect have area in common ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001301
1302#Example
1303#Description
1304Two SkDebugf calls are required. If the calls are combined, their arguments
1305may not be evaluated in left to right order: the printed intersection may
1306be before or after the call to intersect.
1307##
1308 SkIRect leftRect = { 10, 40, 50, 80 };
1309 SkIRect rightRect = { 30, 60, 70, 90 };
1310 SkDebugf("%s intersection: ", leftRect.intersect(rightRect) ? "" : "no ");
Cary Clark682c58d2018-05-16 07:07:07 -04001311 SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
Cary Clark0c5f5462017-12-15 11:21:51 -05001312 leftRect.right(), leftRect.bottom());
1313#StdOut
1314 intersection: 30, 60, 50, 80
Cary Clark682c58d2018-05-16 07:07:07 -04001315##
Cary Clark0c5f5462017-12-15 11:21:51 -05001316##
1317
1318#SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect
1319
1320##
1321
1322# ------------------------------------------------------------------------------
1323
1324#Method bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& a, const SkIRect& b)
1325
Cary Clarkab2621d2018-01-30 10:08:57 -05001326#In Intersection
Cary Clark0c5f5462017-12-15 11:21:51 -05001327Returns true if a intersects b, and sets IRect to intersection.
1328Returns false if a does not intersect b, and leaves IRect unchanged.
1329
1330Returns false if either a or b is empty, leaving IRect unchanged.
1331
1332#Param a IRect to intersect ##
1333#Param b IRect to intersect ##
1334
1335#Return true if a and b have area in common ##
1336
1337#Example
1338 SkIRect result;
1339 bool intersected = result.intersect({ 10, 40, 50, 80 }, { 30, 60, 70, 90 });
1340 SkDebugf("%s intersection: %d, %d, %d, %d\n", intersected ? "" : "no ",
1341 result.left(), result.top(), result.right(), result.bottom());
1342#StdOut
1343 intersection: 30, 60, 50, 80
Cary Clark682c58d2018-05-16 07:07:07 -04001344##
Cary Clark0c5f5462017-12-15 11:21:51 -05001345##
1346
1347#SeeAlso Intersects intersectNoEmptyCheck join SkRect::intersect
1348
1349##
1350
1351# ------------------------------------------------------------------------------
1352
1353#Method bool SK_WARN_UNUSED_RESULT intersectNoEmptyCheck(const SkIRect& a, const SkIRect& b)
1354
Cary Clarkab2621d2018-01-30 10:08:57 -05001355#In Intersection
1356#Line # sets to shared area; returns true if not empty skips empty check ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001357Returns true if a intersects b, and sets IRect to intersection.
1358Returns false if a does not intersect b, and leaves IRect unchanged.
1359
1360Asserts if either a or b is empty, and if SK_DEBUG is defined.
1361
1362#Param a IRect to intersect ##
1363#Param b IRect to intersect ##
1364
1365#Return true if a and b have area in common ##
1366
1367#Example
1368 SkIRect result;
Cary Clark681287e2018-03-16 11:34:15 -04001369 if (result.intersectNoEmptyCheck({ 10, 40, 50, 80 }, { 30, 60, 70, 90 })) {
1370 SkDebugf("intersection: %d, %d, %d, %d\n",
1371 result.left(), result.top(), result.right(), result.bottom());
1372 }
Cary Clark0c5f5462017-12-15 11:21:51 -05001373#StdOut
1374 intersection: 30, 60, 50, 80
Cary Clark682c58d2018-05-16 07:07:07 -04001375##
Cary Clark0c5f5462017-12-15 11:21:51 -05001376##
1377
1378#SeeAlso Intersects intersect join SkRect::intersect
1379
1380##
1381
1382# ------------------------------------------------------------------------------
1383
1384#Method bool intersect(int32_t left, int32_t top, int32_t right, int32_t bottom)
1385
Cary Clarkab2621d2018-01-30 10:08:57 -05001386#In Intersection
Cary Clark0c5f5462017-12-15 11:21:51 -05001387Constructs IRect to intersect from (left, top, right, bottom). Does not sort
1388construction.
1389
1390Returns true if IRect intersects construction, and sets IRect to intersection.
1391Returns false if IRect does not intersect construction, and leaves IRect unchanged.
1392
1393Returns false if either construction or IRect is empty, leaving IRect unchanged.
1394
Cary Clark5538c132018-06-14 12:28:14 -04001395#Param left x-axis minimum of constructed IRect ##
1396#Param top y-axis minimum of constructed IRect ##
1397#Param right x-axis maximum of constructed IRect ##
1398#Param bottom y-axis maximum of constructed IRect ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001399
1400#Return true if construction and IRect have area in common ##
1401
1402#Example
1403#Description
1404Two SkDebugf calls are required. If the calls are combined, their arguments
1405may not be evaluated in left to right order: the printed intersection may
1406be before or after the call to intersect.
1407##
1408 SkIRect leftRect = { 10, 40, 50, 80 };
1409 SkDebugf("%s intersection: ", leftRect.intersect(30, 60, 70, 90) ? "" : "no ");
Cary Clark682c58d2018-05-16 07:07:07 -04001410 SkDebugf("%d, %d, %d, %d\n", leftRect.left(), leftRect.top(),
Cary Clark0c5f5462017-12-15 11:21:51 -05001411 leftRect.right(), leftRect.bottom());
1412#StdOut
1413 intersection: 30, 60, 50, 80
Cary Clark682c58d2018-05-16 07:07:07 -04001414##
Cary Clark0c5f5462017-12-15 11:21:51 -05001415##
1416
1417#SeeAlso intersectNoEmptyCheck Intersects join SkRect::intersect
1418
1419##
1420
1421# ------------------------------------------------------------------------------
1422
1423#Method static bool Intersects(const SkIRect& a, const SkIRect& b)
1424
Cary Clarkab2621d2018-01-30 10:08:57 -05001425#In Intersection
1426#Line # returns true if areas overlap ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001427Returns true if a intersects b.
1428Returns false if either a or b is empty, or do not intersect.
1429
1430#Param a IRect to intersect ##
1431#Param b IRect to intersect ##
1432
1433#Return true if a and b have area in common ##
1434
1435#Example
1436 SkDebugf("%s intersection", SkIRect::Intersects({10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
1437#StdOut
1438 intersection
Cary Clark682c58d2018-05-16 07:07:07 -04001439##
Cary Clark0c5f5462017-12-15 11:21:51 -05001440##
1441
1442#SeeAlso IntersectsNoEmptyCheck intersect SkRect::intersect
1443
1444##
1445
1446# ------------------------------------------------------------------------------
1447
1448#Method static bool IntersectsNoEmptyCheck(const SkIRect& a, const SkIRect& b)
1449
Cary Clarkab2621d2018-01-30 10:08:57 -05001450#In Intersection
1451#Line # returns true if areas overlap skips empty check ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001452Returns true if a intersects b.
1453Asserts if either a or b is empty, and if SK_DEBUG is defined.
1454
1455#Param a IRect to intersect ##
1456#Param b IRect to intersect ##
1457
1458#Return true if a and b have area in common ##
1459
1460#Example
1461 SkDebugf("%s intersection", SkIRect::IntersectsNoEmptyCheck(
1462 {10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
1463#StdOut
1464 intersection
Cary Clark682c58d2018-05-16 07:07:07 -04001465##
Cary Clark0c5f5462017-12-15 11:21:51 -05001466##
1467
1468#SeeAlso Intersects intersect SkRect::intersect
1469
1470##
1471
Cary Clark2dc84ad2018-01-26 12:56:22 -05001472#Subtopic Intersection ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001473
1474# ------------------------------------------------------------------------------
1475
Cary Clark4855f782018-02-06 09:41:53 -05001476#Subtopic Join
Cary Clark682c58d2018-05-16 07:07:07 -04001477#Line # sets to union of bounds ##
Cary Clark4855f782018-02-06 09:41:53 -05001478#Populate
1479##
1480
Cary Clark0c5f5462017-12-15 11:21:51 -05001481#Method void join(int32_t left, int32_t top, int32_t right, int32_t bottom)
1482
Cary Clark4855f782018-02-06 09:41:53 -05001483#In Join
Cary Clarkab2621d2018-01-30 10:08:57 -05001484#Line # sets to union of bounds ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001485Constructs IRect to intersect from (left, top, right, bottom). Does not sort
Cary Clark0c5f5462017-12-15 11:21:51 -05001486construction.
1487
Cary Clark2dc84ad2018-01-26 12:56:22 -05001488Sets IRect to the union of itself and the construction.
Cary Clark0c5f5462017-12-15 11:21:51 -05001489
Cary Clark2dc84ad2018-01-26 12:56:22 -05001490Has no effect if construction is empty. Otherwise, if IRect is empty, sets
1491IRect to construction.
Cary Clark0c5f5462017-12-15 11:21:51 -05001492
Cary Clark5538c132018-06-14 12:28:14 -04001493#Param left x-axis minimum of constructed IRect ##
1494#Param top y-axis minimum of constructed IRect ##
1495#Param right x-axis maximum of constructed IRect ##
1496#Param bottom y-axis maximum of constructed IRect ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001497
1498#Example
1499 SkIRect rect = { 10, 20, 15, 25};
1500 rect.join(50, 60, 55, 65);
1501 SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1502#StdOut
1503 join: 10, 20, 55, 65
Cary Clark682c58d2018-05-16 07:07:07 -04001504##
Cary Clark0c5f5462017-12-15 11:21:51 -05001505##
1506
1507#SeeAlso set SkRect::join
1508
1509##
1510
1511# ------------------------------------------------------------------------------
1512
1513#Method void join(const SkIRect& r)
1514
Cary Clark4855f782018-02-06 09:41:53 -05001515#In Join
Cary Clark2dc84ad2018-01-26 12:56:22 -05001516Sets IRect to the union of itself and r.
Cary Clark0c5f5462017-12-15 11:21:51 -05001517
Cary Clark2dc84ad2018-01-26 12:56:22 -05001518Has no effect if r is empty. Otherwise, if IRect is empty, sets IRect to r.
Cary Clark0c5f5462017-12-15 11:21:51 -05001519
Cary Clark2dc84ad2018-01-26 12:56:22 -05001520#Param r expansion IRect ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001521
1522#Example
1523 SkIRect rect = { 10, 20, 15, 25};
1524 rect.join({50, 60, 55, 65});
1525 SkDebugf("join: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1526#StdOut
1527 join: 10, 20, 55, 65
Cary Clark682c58d2018-05-16 07:07:07 -04001528##
Cary Clark0c5f5462017-12-15 11:21:51 -05001529##
1530
1531#SeeAlso set SkRect::join
1532
1533##
1534
1535# ------------------------------------------------------------------------------
1536
Cary Clark4855f782018-02-06 09:41:53 -05001537#Subtopic Sorting
1538#Line # orders sides ##
1539#Populate
1540##
1541
Cary Clark0c5f5462017-12-15 11:21:51 -05001542#Method void sort()
1543
Cary Clark4855f782018-02-06 09:41:53 -05001544#In Sorting
Cary Clarkab2621d2018-01-30 10:08:57 -05001545#Line # orders sides from smaller to larger ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001546Swaps fLeft and fRight if fLeft is greater than fRight; and swaps
1547fTop and fBottom if fTop is greater than fBottom. Result may be empty,
1548and width() and height() will be zero or positive.
1549
1550#Example
1551 SkIRect rect = { 30, 50, 20, 10 };
1552 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1553 rect.sort();
1554 SkDebugf("sorted: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1555#StdOut
1556rect: 30, 50, 20, 10
1557sorted: 20, 10, 30, 50
1558##
1559##
1560
1561#SeeAlso makeSorted SkRect::sort
1562
1563##
1564
1565# ------------------------------------------------------------------------------
1566
1567#Method SkIRect makeSorted() const
1568
Cary Clark4855f782018-02-06 09:41:53 -05001569#In Sorting
1570#In Constructor
Cary Clark682c58d2018-05-16 07:07:07 -04001571#Line # constructs IRect, ordering sides from smaller to larger ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001572Returns IRect with fLeft and fRight swapped if fLeft is greater than fRight; and
Cary Clark0c5f5462017-12-15 11:21:51 -05001573with fTop and fBottom swapped if fTop is greater than fBottom. Result may be empty;
1574and width() and height() will be zero or positive.
1575
1576#Return sorted IRect ##
1577
1578#Example
1579 SkIRect rect = { 30, 50, 20, 10 };
1580 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1581 SkIRect sort = rect.makeSorted();
1582 SkDebugf("sorted: %d, %d, %d, %d\n", sort.fLeft, sort.fTop, sort.fRight, sort.fBottom);
1583#StdOut
1584rect: 30, 50, 20, 10
1585sorted: 20, 10, 30, 50
1586##
1587##
1588
1589#SeeAlso sort SkRect::makeSorted
1590
1591##
1592
1593# ------------------------------------------------------------------------------
1594
1595#Method static const SkIRect& SK_WARN_UNUSED_RESULT EmptyIRect()
1596
Cary Clark4855f782018-02-06 09:41:53 -05001597#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -05001598#Line # returns immutable bounds of (0, 0, 0, 0) ##
Cary Clark0c5f5462017-12-15 11:21:51 -05001599Returns a reference to immutable empty IRect, set to (0, 0, 0, 0).
1600
1601#Return global IRect set to all zeroes ##
1602
1603#Example
1604 const SkIRect& rect = SkIRect::EmptyIRect();
1605 SkDebugf("rect: %d, %d, %d, %d\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1606#StdOut
1607rect: 0, 0, 0, 0
1608##
1609##
1610
1611#SeeAlso MakeEmpty
1612
1613##
1614
Cary Clark0c95aab2018-01-08 16:20:59 -05001615#Method static SkIRect SK_WARN_UNUSED_RESULT MakeLargest()
Cary Clark0c95aab2018-01-08 16:20:59 -05001616#Deprecated
1617##
1618
Cary Clark0c5f5462017-12-15 11:21:51 -05001619#Struct SkIRect ##
1620
1621#Topic IRect ##