• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1SkRect Reference
2===
3
4# <a name="Rect"></a> Rect
5
6## <a name="Overview"></a> Overview
7
8## <a name="Subtopics"></a> Subtopics
9
10| name | description |
11| --- | --- |
12| <a href="#Constructors">Constructors</a> | functions that construct <a href="SkRect_Reference#SkRect">SkRect</a> |
13| <a href="#Member_Functions">Member Functions</a> | static functions and member methods |
14| <a href="#Members">Members</a> | member values |
15| <a href="#Operators">Operators</a> | operator overloading methods |
16| <a href="#Related_Functions">Related Functions</a> | similar methods grouped together |
17
18# <a name="SkRect"></a> Struct SkRect
19<a href="#SkRect">SkRect</a> holds four <a href="undocumented#SkScalar">SkScalar</a> coordinates describing the upper and
20lower bounds of a rectangle. <a href="#SkRect">SkRect</a> may be created from outer bounds or
21from position, width, and height. <a href="#SkRect">SkRect</a> describes an area; if its right
22is less than or equal to its left, or if its bottom is less than or equal to
23its top, it is considered empty.
24
25<a href="#SkRect">SkRect</a> can be constructed from int values to avoid compiler warnings that
26integer input cannot convert to <a href="undocumented#SkScalar">SkScalar</a> without loss of precision.
27
28## <a name="Related_Functions"></a> Related Functions
29
30| name | description |
31| --- | --- |
32| <a href="#As_Points">As Points</a> | conversion to and from <a href="#Point">Points</a> |
33| <a href="#From_Integers">From Integers</a> | set <a href="#Scalar">Scalar</a> values from integer input |
34| <a href="#Inset_Outset_Offset">Inset Outset Offset</a> | moves sides |
35| <a href="#Intersection">Intersection</a> | set to shared bounds |
36| <a href="#Join">Join</a> | set to union of bounds |
37| <a href="#Properties">Properties</a> | side values, center, validity |
38| <a href="#Rounding">Rounding</a> | adjust to integer bounds |
39| <a href="#Set">Set</a> | replaces all values |
40| <a href="#Sorting">Sorting</a> | orders sides |
41
42## <a name="Member_Functions"></a> Member Functions
43
44| name | description |
45| --- | --- |
46| <a href="#SkRect_Intersects">Intersects</a> | returns true if areas overlap |
47| <a href="#SkRect_Make">Make</a> | constructs from <a href="undocumented#ISize">ISize</a> returning (0, 0, width, height) |
48| <a href="#SkRect_MakeEmpty">MakeEmpty</a> | constructs from bounds of (0, 0, 0, 0) |
49| <a href="#SkRect_MakeFromIRect">MakeFromIRect</a> | deprecated |
50| <a href="#SkRect_MakeIWH">MakeIWH</a> | constructs from int input returning (0, 0, width, height) |
51| <a href="#SkRect_MakeLTRB">MakeLTRB</a> | constructs from <a href="undocumented#SkScalar">SkScalar</a> left, top, right, bottom |
52| <a href="#SkRect_MakeLargest">MakeLargest</a> | deprecated |
53| <a href="#SkRect_MakeSize">MakeSize</a> | constructs from <a href="undocumented#Size">Size</a> returning (0, 0, width, height) |
54| <a href="#SkRect_MakeWH">MakeWH</a> | constructs from <a href="undocumented#SkScalar">SkScalar</a> input returning (0, 0, width, height) |
55| <a href="#SkRect_MakeXYWH">MakeXYWH</a> | constructs from <a href="undocumented#SkScalar">SkScalar</a> input returning (x, y, width, height) |
56| <a href="#SkRect_asScalars">asScalars</a> | returns pointer to members as array |
57| <a href="#SkRect_bottom">bottom</a> | returns larger bounds in y, if sorted |
58| <a href="#SkRect_centerX">centerX</a> | returns midpoint in x |
59| <a href="#SkRect_centerY">centerY</a> | returns midpoint in y |
60| <a href="#SkRect_contains">contains</a> | returns true if points are equal or inside |
61| <a href="#SkRect_dump_2">dump</a> | sends text representation to standard output using floats |
62| <a href="#SkRect_dumpHex">dumpHex</a> | sends text representation to standard output using hexadecimal |
63| <a href="#SkRect_height">height</a> | returns span in y |
64| <a href="#SkRect_inset">inset</a> | moves the sides symmetrically about the center |
65| <a href="#SkRect_intersect">intersect</a> | sets to shared area; returns true if not empty |
66| <a href="#SkRect_intersects">intersects</a> | returns true if areas overlap |
67| <a href="#SkRect_isEmpty">isEmpty</a> | returns true if width or height are zero or negative |
68| <a href="#SkRect_isFinite">isFinite</a> | returns true if no member is infinite or NaN |
69| <a href="#SkRect_isSorted">isSorted</a> | returns true if width or height are zero or positive |
70| <a href="#SkRect_iset">iset</a> | sets to int input (left, top, right, bottom) |
71| <a href="#SkRect_isetWH">isetWH</a> | sets to int input (0, 0, width, height) |
72| <a href="#SkRect_join">join</a> | sets to union of bounds |
73| <a href="#SkRect_joinNonEmptyArg">joinNonEmptyArg</a> | sets to union of bounds, asserting that argument is not empty |
74| <a href="#SkRect_joinPossiblyEmptyRect">joinPossiblyEmptyRect</a> | sets to union of bounds. Skips empty check for both |
75| <a href="#SkRect_left">left</a> | returns smaller bounds in x, if sorted |
76| <a href="#SkRect_makeInset">makeInset</a> | constructs from sides moved symmetrically about the center |
77| <a href="#SkRect_makeOffset">makeOffset</a> | constructs from translated sides |
78| <a href="#SkRect_makeOutset">makeOutset</a> | constructs from sides moved symmetrically about the center |
79| <a href="#SkRect_makeSorted">makeSorted</a> | constructs, ordering sides from smaller to larger |
80| <a href="#SkRect_offset">offset</a> | translates sides without changing width and height |
81| <a href="#SkRect_offsetTo">offsetTo</a> | translates to (x, y) without changing width and height |
82| <a href="#SkRect_outset">outset</a> | moves the sides symmetrically about the center |
83| <a href="#SkRect_right">right</a> | returns larger bounds in x, if sorted |
84| <a href="#SkRect_round_2">round</a> | sets members to nearest integer value |
85| <a href="#SkRect_roundIn">roundIn</a> | sets members to nearest integer value towards opposite |
86| <a href="#SkRect_roundOut">roundOut</a> | sets members to nearest integer value away from opposite |
87| <a href="#SkRect_set">set</a> | sets to <a href="undocumented#SkScalar">SkScalar</a> input (left, top, right, bottom) and others |
88| <a href="#SkRect_setBounds">setBounds</a> | sets to upper and lower limits of <a href="SkPoint_Reference#Point">Point</a> array |
89| <a href="#SkRect_setBoundsCheck">setBoundsCheck</a> | sets to upper and lower limits of <a href="SkPoint_Reference#Point">Point</a> array |
90| <a href="#SkRect_setEmpty">setEmpty</a> | sets to (0, 0, 0, 0) |
91| <a href="#SkRect_setLTRB">setLTRB</a> | sets to <a href="undocumented#SkScalar">SkScalar</a> input (left, top, right, bottom) |
92| <a href="#SkRect_setWH">setWH</a> | sets to <a href="undocumented#SkScalar">SkScalar</a> input (0, 0, width, height) |
93| <a href="#SkRect_setXYWH">setXYWH</a> | sets to <a href="undocumented#SkScalar">SkScalar</a> input (x, y, width, height) |
94| <a href="#SkRect_sort">sort</a> | orders sides from smaller to larger |
95| <a href="#SkRect_toQuad">toQuad</a> | returns four corners as <a href="SkPoint_Reference#Point">Point</a> |
96| <a href="#SkRect_top">top</a> | returns smaller bounds in y, if sorted |
97| <a href="#SkRect_width">width</a> | returns span in x |
98| <a href="#SkRect_x">x</a> | returns bounds left |
99| <a href="#SkRect_y">y</a> | returns bounds top |
100
101## <a name="Members"></a> Members
102
103| name | description |
104| --- | --- |
105| <a href="#SkRect_fBottom">fBottom</a> | larger y-axis bounds |
106| <a href="#SkRect_fLeft">fLeft</a> | smaller x-axis bounds |
107| <a href="#SkRect_fRight">fRight</a> | larger x-axis bounds |
108| <a href="#SkRect_fTop">fTop</a> | smaller y-axis bounds |
109
110<a name="SkRect_fLeft"> <code><strong>SkScalar  fLeft</strong></code> </a>
111
112May contain any value, including infinities and NaN. The smaller of the
113horizontal values when sorted. When equal to or greater than <a href="#SkRect_fRight">fRight</a>, <a href="#Rect">Rect</a> is empty.
114
115<a name="SkRect_fTop"> <code><strong>SkScalar  fTop</strong></code> </a>
116
117May contain any value, including infinities and NaN. The smaller of the
118vertical values when sorted. When equal to or greater than <a href="#SkRect_fBottom">fBottom</a>, <a href="#Rect">Rect</a> is empty.
119
120<a name="SkRect_fRight"> <code><strong>SkScalar  fRight</strong></code> </a>
121
122May contain any value, including infinities and NaN. The larger of the
123horizontal values when sorted. When equal to or less than <a href="#SkRect_fLeft">fLeft</a>, <a href="#Rect">Rect</a> is empty.
124
125<a name="SkRect_fBottom"> <code><strong>SkScalar  fBottom</strong></code> </a>
126
127May contain any value, including infinities and NaN. The larger of the
128vertical values when sorted. When equal to or less than <a href="#SkRect_fTop">fTop</a>, <a href="#Rect">Rect</a> is empty.
129
130## <a name="Constructors"></a> Constructors
131
132| name | description |
133| --- | ---  |
134| <a href="#SkRect_Make">Make</a> | constructs from <a href="undocumented#ISize">ISize</a> returning (0, 0, width, height) |
135| <a href="#SkRect_MakeEmpty">MakeEmpty</a> | constructs from bounds of (0, 0, 0, 0) |
136| <a href="#SkRect_MakeFromIRect">MakeFromIRect</a> | deprecated |
137| <a href="#SkRect_MakeIWH">MakeIWH</a> | constructs from int input returning (0, 0, width, height) |
138| <a href="#SkRect_MakeLTRB">MakeLTRB</a> | constructs from <a href="undocumented#SkScalar">SkScalar</a> left, top, right, bottom |
139| <a href="#SkRect_MakeLargest">MakeLargest</a> | deprecated |
140| <a href="#SkRect_MakeSize">MakeSize</a> | constructs from <a href="undocumented#Size">Size</a> returning (0, 0, width, height) |
141| <a href="#SkRect_MakeWH">MakeWH</a> | constructs from <a href="undocumented#SkScalar">SkScalar</a> input returning (0, 0, width, height) |
142| <a href="#SkRect_MakeXYWH">MakeXYWH</a> | constructs from <a href="undocumented#SkScalar">SkScalar</a> input returning (x, y, width, height) |
143| <a href="#SkRect_makeInset">makeInset</a> | constructs from sides moved symmetrically about the center |
144| <a href="#SkRect_makeOffset">makeOffset</a> | constructs from translated sides |
145| <a href="#SkRect_makeOutset">makeOutset</a> | constructs from sides moved symmetrically about the center |
146| <a href="#SkRect_makeSorted">makeSorted</a> | constructs, ordering sides from smaller to larger |
147
148<a name="SkRect_MakeEmpty"></a>
149## MakeEmpty
150
151<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
152static constexpr SkRect SK_WARN_UNUSED_RESULT MakeEmpty()
153</pre>
154
155Returns constructed <a href="#Rect">Rect</a> set to (0, 0, 0, 0).
156Many other rectangles are empty; if left is equal to or greater than right,
157or if top is equal to or greater than bottom. Setting all members to zero
158is a convenience, but does not designate a special empty rectangle.
159
160### Return Value
161
162bounds (0, 0, 0, 0)
163
164### Example
165
166<div><fiddle-embed name="2e262d0ac4b8ef51695e0525fc3ecdf6">
167
168#### Example Output
169
170~~~~
171MakeEmpty isEmpty: true
172offset rect isEmpty: true
173inset rect isEmpty: true
174outset rect isEmpty: false
175~~~~
176
177</fiddle-embed></div>
178
179### See Also
180
181<a href="#SkRect_isEmpty">isEmpty</a> <a href="#SkRect_setEmpty">setEmpty</a> <a href="#SkIRect_MakeEmpty">SkIRect::MakeEmpty</a>
182
183---
184
185<a name="SkRect_MakeWH"></a>
186## MakeWH
187
188<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
189static constexpr SkRect SK_WARN_UNUSED_RESULT MakeWH(SkScalar w, SkScalar h)
190</pre>
191
192Returns constructed <a href="#Rect">Rect</a> set to <a href="undocumented#SkScalar">SkScalar</a> values (0, 0, <a href="#SkRect_MakeWH_w">w</a>, <a href="#SkRect_MakeWH_h">h</a>). Does not
193validate input; <a href="#SkRect_MakeWH_w">w</a> or <a href="#SkRect_MakeWH_h">h</a> may be negative.
194
195Passing integer values may generate a compiler warning since <a href="#Rect">Rect</a> cannot
196represent 32-bit integers exactly. Use <a href="SkIRect_Reference#SkIRect">SkIRect</a> for an exact integer rectangle.
197
198### Parameters
199
200<table>  <tr>    <td><a name="SkRect_MakeWH_w"> <code><strong>w </strong></code> </a></td> <td>
201<a href="undocumented#SkScalar">SkScalar</a> width of constructed <a href="#Rect">Rect</a></td>
202  </tr>  <tr>    <td><a name="SkRect_MakeWH_h"> <code><strong>h </strong></code> </a></td> <td>
203<a href="undocumented#SkScalar">SkScalar</a> height of constructed <a href="#Rect">Rect</a></td>
204  </tr>
205</table>
206
207### Return Value
208
209bounds (0, 0, <a href="#SkRect_MakeWH_w">w</a>, <a href="#SkRect_MakeWH_h">h</a>)
210
211### Example
212
213<div><fiddle-embed name="8009d30f431e01f8aea4808e9017d9bf">
214
215#### Example Output
216
217~~~~
218all equal
219~~~~
220
221</fiddle-embed></div>
222
223### See Also
224
225<a href="#SkRect_MakeSize">MakeSize</a> <a href="#SkRect_MakeXYWH">MakeXYWH</a> <a href="#SkRect_MakeIWH">MakeIWH</a> <a href="#SkRect_setWH">setWH</a> <a href="#SkIRect_MakeWH">SkIRect::MakeWH</a>
226
227---
228
229<a name="SkRect_MakeIWH"></a>
230## MakeIWH
231
232<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
233static SkRect SK_WARN_UNUSED_RESULT MakeIWH(int w, int h)
234</pre>
235
236Returns constructed <a href="#Rect">Rect</a> set to integer values (0, 0, <a href="#SkRect_MakeIWH_w">w</a>, <a href="#SkRect_MakeIWH_h">h</a>). Does not validate
237input; <a href="#SkRect_MakeIWH_w">w</a> or <a href="#SkRect_MakeIWH_h">h</a> may be negative.
238
239Use to avoid a compiler warning that input may lose precision when stored.
240Use <a href="SkIRect_Reference#SkIRect">SkIRect</a> for an exact integer rectangle.
241
242### Parameters
243
244<table>  <tr>    <td><a name="SkRect_MakeIWH_w"> <code><strong>w </strong></code> </a></td> <td>
245integer width of constructed <a href="#Rect">Rect</a></td>
246  </tr>  <tr>    <td><a name="SkRect_MakeIWH_h"> <code><strong>h </strong></code> </a></td> <td>
247integer height of constructed <a href="#Rect">Rect</a></td>
248  </tr>
249</table>
250
251### Return Value
252
253bounds (0, 0, <a href="#SkRect_MakeIWH_w">w</a>, <a href="#SkRect_MakeIWH_h">h</a>)
254
255### Example
256
257<div><fiddle-embed name="faa660ac19eaddc3f3eab57a0bddfdcb">
258
259#### Example Output
260
261~~~~
262i_rect width: 25 f_rect width:25
263i_rect width: 125000111 f_rect width:125000112
264~~~~
265
266</fiddle-embed></div>
267
268### See Also
269
270<a href="#SkRect_MakeXYWH">MakeXYWH</a> <a href="#SkRect_MakeWH">MakeWH</a> <a href="#SkRect_isetWH">isetWH</a> <a href="#SkIRect_MakeWH">SkIRect::MakeWH</a>
271
272---
273
274<a name="SkRect_MakeSize"></a>
275## MakeSize
276
277<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
278static constexpr SkRect SK_WARN_UNUSED_RESULT MakeSize(const SkSize& size)
279</pre>
280
281Returns constructed <a href="#Rect">Rect</a> set to (0, 0, <a href="#SkRect_MakeSize_size">size</a>.<a href="#SkRect_width">width</a>, <a href="#SkRect_MakeSize_size">size</a>.<a href="#SkRect_height">height</a>). Does not
282validate input; <a href="#SkRect_MakeSize_size">size</a>.<a href="#SkRect_width">width</a> or <a href="#SkRect_MakeSize_size">size</a>.<a href="#SkRect_height">height</a> may be negative.
283
284### Parameters
285
286<table>  <tr>    <td><a name="SkRect_MakeSize_size"> <code><strong>size </strong></code> </a></td> <td>
287<a href="undocumented#SkScalar">SkScalar</a> values for <a href="#Rect">Rect</a> width and height</td>
288  </tr>
289</table>
290
291### Return Value
292
293bounds (0, 0, <a href="#SkRect_MakeSize_size">size</a>.<a href="#SkRect_width">width</a>, <a href="#SkRect_MakeSize_size">size</a>.<a href="#SkRect_height">height</a>)
294
295### Example
296
297<div><fiddle-embed name="ab2c1a55016c8de9172b77fdf69e00a2">
298
299#### Example Output
300
301~~~~
302rect width: 25.5  height: 35.5
303floor width: 25  height: 35
304~~~~
305
306</fiddle-embed></div>
307
308### See Also
309
310<a href="#SkRect_MakeWH">MakeWH</a> <a href="#SkRect_MakeXYWH">MakeXYWH</a> <a href="#SkRect_MakeIWH">MakeIWH</a> <a href="#SkRect_setWH">setWH</a> <a href="#SkIRect_MakeWH">SkIRect::MakeWH</a>
311
312---
313
314<a name="SkRect_MakeLTRB"></a>
315## MakeLTRB
316
317<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
318static constexpr SkRect SK_WARN_UNUSED_RESULT MakeLTRB(SkScalar l, SkScalar t, SkScalar r, SkScalar b)
319</pre>
320
321Returns constructed <a href="#Rect">Rect</a> set to (<a href="#SkRect_MakeLTRB_l">l</a>, <a href="#SkRect_MakeLTRB_t">t</a>, <a href="#SkRect_MakeLTRB_r">r</a>, <a href="#SkRect_MakeLTRB_b">b</a>). Does not sort input; <a href="#Rect">Rect</a> may
322result in <a href="#SkRect_fLeft">fLeft</a> greater than <a href="#SkRect_fRight">fRight</a>, or <a href="#SkRect_fTop">fTop</a> greater than <a href="#SkRect_fBottom">fBottom</a>.
323
324### Parameters
325
326<table>  <tr>    <td><a name="SkRect_MakeLTRB_l"> <code><strong>l </strong></code> </a></td> <td>
327<a href="undocumented#SkScalar">SkScalar</a> stored in <a href="#SkRect_fLeft">fLeft</a></td>
328  </tr>  <tr>    <td><a name="SkRect_MakeLTRB_t"> <code><strong>t </strong></code> </a></td> <td>
329<a href="undocumented#SkScalar">SkScalar</a> stored in <a href="#SkRect_fTop">fTop</a></td>
330  </tr>  <tr>    <td><a name="SkRect_MakeLTRB_r"> <code><strong>r </strong></code> </a></td> <td>
331<a href="undocumented#SkScalar">SkScalar</a> stored in <a href="#SkRect_fRight">fRight</a></td>
332  </tr>  <tr>    <td><a name="SkRect_MakeLTRB_b"> <code><strong>b </strong></code> </a></td> <td>
333<a href="undocumented#SkScalar">SkScalar</a> stored in <a href="#SkRect_fBottom">fBottom</a></td>
334  </tr>
335</table>
336
337### Return Value
338
339bounds (<a href="#SkRect_MakeLTRB_l">l</a>, <a href="#SkRect_MakeLTRB_t">t</a>, <a href="#SkRect_MakeLTRB_r">r</a>, <a href="#SkRect_MakeLTRB_b">b</a>)
340
341### Example
342
343<div><fiddle-embed name="158b8dd9d02d65a5ae5ab7d1595a5b4c">
344
345#### Example Output
346
347~~~~
348rect: 5, 35, 15, 25  isEmpty: true
349rect: 5, 25, 15, 35  isEmpty: false
350~~~~
351
352</fiddle-embed></div>
353
354### See Also
355
356<a href="#SkRect_MakeXYWH">MakeXYWH</a> <a href="#SkIRect_MakeLTRB">SkIRect::MakeLTRB</a>
357
358---
359
360<a name="SkRect_MakeXYWH"></a>
361## MakeXYWH
362
363<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
364static constexpr SkRect SK_WARN_UNUSED_RESULT MakeXYWH(SkScalar x, SkScalar y, SkScalar w, SkScalar h)
365</pre>
366
367Returns constructed <a href="#Rect">Rect</a> set to(x, y, x + <a href="#SkRect_MakeXYWH_w">w</a>, y + <a href="#SkRect_MakeXYWH_h">h</a>).
368Does not validate input;
369<a href="#SkRect_MakeXYWH_w">w</a> or <a href="#SkRect_MakeXYWH_h">h</a> may be negative.
370
371### Parameters
372
373<table>  <tr>    <td><a name="SkRect_MakeXYWH_x"> <code><strong>x </strong></code> </a></td> <td>
374stored in <a href="#SkRect_fLeft">fLeft</a></td>
375  </tr>  <tr>    <td><a name="SkRect_MakeXYWH_y"> <code><strong>y </strong></code> </a></td> <td>
376stored in <a href="#SkRect_fTop">fTop</a></td>
377  </tr>  <tr>    <td><a name="SkRect_MakeXYWH_w"> <code><strong>w </strong></code> </a></td> <td>
378added to x and stored in <a href="#SkRect_fRight">fRight</a></td>
379  </tr>  <tr>    <td><a name="SkRect_MakeXYWH_h"> <code><strong>h </strong></code> </a></td> <td>
380added to y and stored in <a href="#SkRect_fBottom">fBottom</a></td>
381  </tr>
382</table>
383
384### Return Value
385
386bounds at (x, y) with width <a href="#SkRect_MakeXYWH_w">w</a> and height <a href="#SkRect_MakeXYWH_h">h</a>
387
388### Example
389
390<div><fiddle-embed name="38e464dba13be11ac21e210fbf3b5afc">
391
392#### Example Output
393
394~~~~
395rect: 5, 35, -10, 60  isEmpty: true
396rect: -10, 35, 5, 60  isEmpty: false
397~~~~
398
399</fiddle-embed></div>
400
401### See Also
402
403<a href="#SkRect_MakeLTRB">MakeLTRB</a> <a href="#SkIRect_MakeXYWH">SkIRect::MakeXYWH</a>
404
405---
406
407<a name="SkRect_MakeFromIRect"></a>
408## MakeFromIRect
409
410<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
411static SkRect SK_WARN_UNUSED_RESULT MakeFromIRect(const SkIRect& irect)
412</pre>
413
414Deprecated.
415
416### Parameters
417
418<table>  <tr>    <td><a name="SkRect_MakeFromIRect_irect"> <code><strong>irect </strong></code> </a></td> <td>
419integer rect</td>
420  </tr>
421</table>
422
423### Return Value
424
425<a href="#SkRect_MakeFromIRect_irect">irect</a> as <a href="#SkRect">SkRect</a>
426
427### See Also
428
429<a href="#SkRect_Make">Make</a><sup><a href="#SkRect_Make_2">[2]</a></sup>
430
431---
432
433<a name="SkRect_Make"></a>
434## Make
435
436<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
437static SkRect Make(const SkISize& size)
438</pre>
439
440Returns constructed <a href="SkIRect_Reference#IRect">IRect</a> set to (0, 0, <a href="#SkRect_Make_size">size</a>.<a href="#SkRect_width">width</a>, <a href="#SkRect_Make_size">size</a>.<a href="#SkRect_height">height</a>).
441Does not validate input; <a href="#SkRect_Make_size">size</a>.<a href="#SkRect_width">width</a> or <a href="#SkRect_Make_size">size</a>.<a href="#SkRect_height">height</a> may be negative.
442
443### Parameters
444
445<table>  <tr>    <td><a name="SkRect_Make_size"> <code><strong>size </strong></code> </a></td> <td>
446integer values for <a href="#Rect">Rect</a> width and height</td>
447  </tr>
448</table>
449
450### Return Value
451
452bounds (0, 0, <a href="#SkRect_Make_size">size</a>.<a href="#SkRect_width">width</a>, <a href="#SkRect_Make_size">size</a>.<a href="#SkRect_height">height</a>)
453
454### Example
455
456<div><fiddle-embed name="e866f5e4f6ac52e89acadf48e54ac8e0">
457
458#### Example Output
459
460~~~~
461rect1 == rect2
462~~~~
463
464</fiddle-embed></div>
465
466### See Also
467
468<a href="#SkRect_MakeWH">MakeWH</a> <a href="#SkRect_MakeXYWH">MakeXYWH</a> <a href="#SkRect_MakeIWH">SkRect::MakeIWH</a> <a href="#SkIRect_MakeSize">SkIRect::MakeSize</a>
469
470---
471
472<a name="SkRect_Make_2"></a>
473
474<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
475static SkRect SK_WARN_UNUSED_RESULT Make(const SkIRect& irect)
476</pre>
477
478Returns constructed <a href="SkIRect_Reference#IRect">IRect</a> set to <a href="#SkRect_Make_2_irect">irect</a>, promoting integers to <a href="#Scalar">Scalar</a>.
479Does not validate input; <a href="#SkRect_fLeft">fLeft</a> may be greater than <a href="#SkRect_fRight">fRight</a>, <a href="#SkRect_fTop">fTop</a> may be greater
480than <a href="#SkRect_fBottom">fBottom</a>.
481
482### Parameters
483
484<table>  <tr>    <td><a name="SkRect_Make_2_irect"> <code><strong>irect </strong></code> </a></td> <td>
485integer unsorted bounds</td>
486  </tr>
487</table>
488
489### Return Value
490
491<a href="#SkRect_Make_2_irect">irect</a> members converted to <a href="undocumented#SkScalar">SkScalar</a>
492
493### Example
494
495<div><fiddle-embed name="dd801faa1e60a0fe9e0657674461e063"></fiddle-embed></div>
496
497### See Also
498
499<a href="#SkRect_MakeLTRB">MakeLTRB</a>
500
501---
502
503## <a name="Properties"></a> Properties
504
505| name | description |
506| --- | ---  |
507| <a href="#SkRect_bottom">bottom</a> | returns larger bounds in y, if sorted |
508| <a href="#SkRect_centerX">centerX</a> | returns midpoint in x |
509| <a href="#SkRect_centerY">centerY</a> | returns midpoint in y |
510| <a href="#SkRect_height">height</a> | returns span in y |
511| <a href="#SkRect_isEmpty">isEmpty</a> | returns true if width or height are zero or negative |
512| <a href="#SkRect_isFinite">isFinite</a> | returns true if no member is infinite or NaN |
513| <a href="#SkRect_isSorted">isSorted</a> | returns true if width or height are zero or positive |
514| <a href="#SkRect_left">left</a> | returns smaller bounds in x, if sorted |
515| <a href="#SkRect_right">right</a> | returns larger bounds in x, if sorted |
516| <a href="#SkRect_top">top</a> | returns smaller bounds in y, if sorted |
517| <a href="#SkRect_width">width</a> | returns span in x |
518| <a href="#SkRect_x">x</a> | returns bounds left |
519| <a href="#SkRect_y">y</a> | returns bounds top |
520
521<a name="SkRect_isEmpty"></a>
522## isEmpty
523
524<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
525bool isEmpty() const
526</pre>
527
528Returns true if <a href="#SkRect_fLeft">fLeft</a> is equal to or greater than <a href="#SkRect_fRight">fRight</a>, or if <a href="#SkRect_fTop">fTop</a> is equal
529to or greater than <a href="#SkRect_fBottom">fBottom</a>. Call <a href="#SkRect_sort">sort</a> to reverse rectangles with negative
530<a href="#SkRect_width">width</a> or <a href="#SkRect_height">height</a>.
531
532### Return Value
533
534true if <a href="#SkRect_width">width</a> or <a href="#SkRect_height">height</a> are zero or negative
535
536### Example
537
538<div><fiddle-embed name="1d7b924d6ca2a6aef09684a8a632439c">
539
540#### Example Output
541
542~~~~
543rect: {20, 40, 10, 50} is empty
544sorted: {10, 40, 20, 50} is not empty
545rect: {20, 40, 20, 50} is empty
546sorted: {20, 40, 20, 50} is empty
547~~~~
548
549</fiddle-embed></div>
550
551### See Also
552
553<a href="#SkRect_MakeEmpty">MakeEmpty</a> <a href="#SkRect_sort">sort</a> <a href="#SkIRect_isEmpty">SkIRect::isEmpty</a>
554
555---
556
557<a name="SkRect_isSorted"></a>
558## isSorted
559
560<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
561bool isSorted() const
562</pre>
563
564Returns true if <a href="#SkRect_fLeft">fLeft</a> is equal to or less than <a href="#SkRect_fRight">fRight</a>, or if <a href="#SkRect_fTop">fTop</a> is equal
565to or less than <a href="#SkRect_fBottom">fBottom</a>. Call <a href="#SkRect_sort">sort</a> to reverse rectangles with negative
566<a href="#SkRect_width">width</a> or <a href="#SkRect_height">height</a>.
567
568### Return Value
569
570true if <a href="#SkRect_width">width</a> or <a href="#SkRect_height">height</a> are zero or positive
571
572### Example
573
574<div><fiddle-embed name="c7065a83b220a96f903dbbb65906fe7b">
575
576#### Example Output
577
578~~~~
579rect: {20, 40, 10, 50} is not sorted
580sorted: {10, 40, 20, 50} is sorted
581rect: {20, 40, 20, 50} is sorted
582sorted: {20, 40, 20, 50} is sorted
583~~~~
584
585</fiddle-embed></div>
586
587### See Also
588
589<a href="#SkRect_sort">sort</a> <a href="#SkRect_makeSorted">makeSorted</a> <a href="#SkRect_isEmpty">isEmpty</a>
590
591---
592
593<a name="SkRect_isFinite"></a>
594## isFinite
595
596<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
597bool isFinite() const
598</pre>
599
600Returns true if all values in the rectangle are finite: <a href="undocumented#SK_ScalarMin">SK ScalarMin</a> or larger,
601and <a href="undocumented#SK_ScalarMax">SK ScalarMax</a> or smaller.
602
603### Return Value
604
605true if no member is infinite or NaN
606
607### Example
608
609<div><fiddle-embed name="443fe5f8296d4cdb19cc9862a9cf77a4">
610
611#### Example Output
612
613~~~~
614largest is finite: true
615large width inf
616widest is finite: false
617~~~~
618
619</fiddle-embed></div>
620
621### See Also
622
623<a href="undocumented#SkScalarIsFinite">SkScalarIsFinite</a> <a href="undocumented#SkScalarIsNaN">SkScalarIsNaN</a>
624
625---
626
627<a name="SkRect_x"></a>
628## x
629
630<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
631SkScalar    x() const
632</pre>
633
634Returns left edge of <a href="#Rect">Rect</a>, if sorted. Call <a href="#SkRect_isSorted">isSorted</a> to see if <a href="#Rect">Rect</a> is valid.
635Call <a href="#SkRect_sort">sort</a> to reverse <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fRight">fRight</a> if needed.
636
637### Return Value
638
639<a href="#SkRect_fLeft">fLeft</a>
640
641### Example
642
643<div><fiddle-embed name="23c77a35ac54a439a2989f840aa5cb99">
644
645#### Example Output
646
647~~~~
648unsorted.fLeft: 15 unsorted.x(): 15
649sorted.fLeft: 10 sorted.x(): 10
650~~~~
651
652</fiddle-embed></div>
653
654### See Also
655
656<a href="#SkRect_fLeft">fLeft</a> <a href="#SkRect_left">left</a> <a href="#SkRect_y">y</a> <a href="#SkIRect_x">SkIRect::x()</a>
657
658---
659
660<a name="SkRect_y"></a>
661## y
662
663<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
664SkScalar    y() const
665</pre>
666
667Returns top edge of <a href="#Rect">Rect</a>, if sorted. Call <a href="#SkRect_isEmpty">isEmpty</a> to see if <a href="#Rect">Rect</a> may be invalid,
668and <a href="#SkRect_sort">sort</a> to reverse <a href="#SkRect_fTop">fTop</a> and <a href="#SkRect_fBottom">fBottom</a> if needed.
669
670### Return Value
671
672<a href="#SkRect_fTop">fTop</a>
673
674### Example
675
676<div><fiddle-embed name="c653d9017983d2a047b1fee6a481d82b">
677
678#### Example Output
679
680~~~~
681unsorted.fTop: 25 unsorted.y(): 25
682sorted.fTop: 5 sorted.y(): 5
683~~~~
684
685</fiddle-embed></div>
686
687### See Also
688
689<a href="#SkRect_fTop">fTop</a> <a href="#SkRect_top">top</a> <a href="#SkRect_x">x</a> <a href="#SkIRect_y">SkIRect::y()</a>
690
691---
692
693<a name="SkRect_left"></a>
694## left
695
696<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
697SkScalar    left() const
698</pre>
699
700Returns left edge of <a href="#Rect">Rect</a>, if sorted. Call <a href="#SkRect_isSorted">isSorted</a> to see if <a href="#Rect">Rect</a> is valid.
701Call <a href="#SkRect_sort">sort</a> to reverse <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fRight">fRight</a> if needed.
702
703### Return Value
704
705<a href="#SkRect_fLeft">fLeft</a>
706
707### Example
708
709<div><fiddle-embed name="900dc96c3549795a87036d6458c4fde6">
710
711#### Example Output
712
713~~~~
714unsorted.fLeft: 15 unsorted.left(): 15
715sorted.fLeft: 10 sorted.left(): 10
716~~~~
717
718</fiddle-embed></div>
719
720### See Also
721
722<a href="#SkRect_fLeft">fLeft</a> <a href="#SkRect_x">x</a> <a href="#SkIRect_left">SkIRect::left()</a>
723
724---
725
726<a name="SkRect_top"></a>
727## top
728
729<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
730SkScalar    top() const
731</pre>
732
733Returns top edge of <a href="#Rect">Rect</a>, if sorted. Call <a href="#SkRect_isEmpty">isEmpty</a> to see if <a href="#Rect">Rect</a> may be invalid,
734and <a href="#SkRect_sort">sort</a> to reverse <a href="#SkRect_fTop">fTop</a> and <a href="#SkRect_fBottom">fBottom</a> if needed.
735
736### Return Value
737
738<a href="#SkRect_fTop">fTop</a>
739
740### Example
741
742<div><fiddle-embed name="3cfc24b011aef1ca8ccb57c05711620c">
743
744#### Example Output
745
746~~~~
747unsorted.fTop: 25 unsorted.top(): 25
748sorted.fTop: 5 sorted.top(): 5
749~~~~
750
751</fiddle-embed></div>
752
753### See Also
754
755<a href="#SkRect_fTop">fTop</a> <a href="#SkRect_y">y</a> <a href="#SkIRect_top">SkIRect::top()</a>
756
757---
758
759<a name="SkRect_right"></a>
760## right
761
762<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
763SkScalar    right() const
764</pre>
765
766Returns right edge of <a href="#Rect">Rect</a>, if sorted. Call <a href="#SkRect_isSorted">isSorted</a> to see if <a href="#Rect">Rect</a> is valid.
767Call <a href="#SkRect_sort">sort</a> to reverse <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fRight">fRight</a> if needed.
768
769### Return Value
770
771<a href="#SkRect_fRight">fRight</a>
772
773### Example
774
775<div><fiddle-embed name="ca3de7e5e292b3ad3633b1c39a31d3ab">
776
777#### Example Output
778
779~~~~
780unsorted.fRight: 10 unsorted.right(): 10
781sorted.fRight: 15 sorted.right(): 15
782~~~~
783
784</fiddle-embed></div>
785
786### See Also
787
788<a href="#SkRect_fRight">fRight</a> <a href="#SkIRect_right">SkIRect::right()</a>
789
790---
791
792<a name="SkRect_bottom"></a>
793## bottom
794
795<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
796SkScalar    bottom() const
797</pre>
798
799Returns bottom edge of <a href="#Rect">Rect</a>, if sorted. Call <a href="#SkRect_isEmpty">isEmpty</a> to see if <a href="#Rect">Rect</a> may be invalid,
800and <a href="#SkRect_sort">sort</a> to reverse <a href="#SkRect_fTop">fTop</a> and <a href="#SkRect_fBottom">fBottom</a> if needed.
801
802### Return Value
803
804<a href="#SkRect_fBottom">fBottom</a>
805
806### Example
807
808<div><fiddle-embed name="a98993a66616ae406d8bdc54adfb1411">
809
810#### Example Output
811
812~~~~
813unsorted.fBottom: 5 unsorted.bottom(): 5
814sorted.fBottom: 25 sorted.bottom(): 25
815~~~~
816
817</fiddle-embed></div>
818
819### See Also
820
821<a href="#SkRect_fBottom">fBottom</a> <a href="#SkIRect_bottom">SkIRect::bottom()</a>
822
823---
824
825<a name="SkRect_width"></a>
826## width
827
828<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
829SkScalar    width() const
830</pre>
831
832Returns span on the x-axis. This does not check if <a href="#Rect">Rect</a> is sorted, or if
833result fits in 32-bit float; result may be negative or infinity.
834
835### Return Value
836
837<a href="#SkRect_fRight">fRight</a> minus <a href="#SkRect_fLeft">fLeft</a>
838
839### Example
840
841<div><fiddle-embed name="11f8f0efe6291019fee0ac17844f6c1a"><div>Compare with <a href="#SkIRect_width">SkIRect::width()</a> example.</div>
842
843#### Example Output
844
845~~~~
846unsorted width: -5
847large width: 4294967296
848~~~~
849
850</fiddle-embed></div>
851
852### See Also
853
854<a href="#SkRect_height">height</a> <a href="#SkIRect_width">SkIRect::width()</a>
855
856---
857
858<a name="SkRect_height"></a>
859## height
860
861<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
862SkScalar    height() const
863</pre>
864
865Returns span on the y-axis. This does not check if <a href="SkIRect_Reference#IRect">IRect</a> is sorted, or if
866result fits in 32-bit float; result may be negative or infinity.
867
868### Return Value
869
870<a href="#SkRect_fBottom">fBottom</a> minus <a href="#SkRect_fTop">fTop</a>
871
872### Example
873
874<div><fiddle-embed name="39429e45f05240218ecd511443ab3e44"><div>Compare with <a href="#SkIRect_height">SkIRect::height()</a> example.</div>
875
876#### Example Output
877
878~~~~
879unsorted height: -5
880large height: 4294967296
881~~~~
882
883</fiddle-embed></div>
884
885### See Also
886
887<a href="#SkRect_width">width</a> <a href="#SkIRect_height">SkIRect::height()</a>
888
889---
890
891<a name="SkRect_centerX"></a>
892## centerX
893
894<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
895SkScalar    centerX() const
896</pre>
897
898Returns average of left edge and right edge. Result does not change if <a href="#Rect">Rect</a>
899is sorted. Result may overflow to infinity if <a href="#Rect">Rect</a> is far from the origin.
900
901### Return Value
902
903midpoint in x
904
905### Example
906
907<div><fiddle-embed name="d8439ba8d23a424fa032fb97147fd2d2">
908
909#### Example Output
910
911~~~~
912left:  20 right:  41 centerX: 30.5
913left:  20 right:  41 centerX: 30.5
914left: -20 right: -41 centerX: -30.5
915left: -41 right: -20 centerX: -30.5
916~~~~
917
918</fiddle-embed></div>
919
920### See Also
921
922<a href="#SkRect_centerY">centerY</a> <a href="#SkIRect_centerX">SkIRect::centerX</a>
923
924---
925
926<a name="SkRect_centerY"></a>
927## centerY
928
929<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
930SkScalar    centerY() const
931</pre>
932
933Returns average of top edge and bottom edge. Result does not change if <a href="#Rect">Rect</a>
934is sorted. Result may overflow to infinity if <a href="#Rect">Rect</a> is far from the origin.
935
936### Return Value
937
938midpoint in y
939
940### Example
941
942<div><fiddle-embed name="ebeeafafeb8fe39d5ffc9115b02c2340">
943
944#### Example Output
945
946~~~~
947left: 2e+38 right: 3e+38 centerX: inf safe mid x: 2.5e+38
948~~~~
949
950</fiddle-embed></div>
951
952### See Also
953
954<a href="#SkRect_centerX">centerX</a> <a href="#SkIRect_centerY">SkIRect::centerY</a>
955
956---
957
958## <a name="Operators"></a> Operators
959
960| name | description |
961| --- | ---  |
962| <a href="#SkRect_notequal_operator">operator!=(const SkRect& a, const SkRect& b)</a> | returns true if members are unequal |
963| <a href="#SkRect_equal_operator">operator==(const SkRect& a, const SkRect& b)</a> | returns true if members are equal |
964
965<a name="SkRect_equal_operator"></a>
966## operator==
967
968<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
969bool operator==(const SkRect& a, const SkRect& b)
970</pre>
971
972Returns true if all members in <a href="#SkRect_equal_operator_a">a</a>: <a href="#SkRect_fLeft">fLeft</a>, <a href="#SkRect_fTop">fTop</a>, <a href="#SkRect_fRight">fRight</a>, and <a href="#SkRect_fBottom">fBottom</a>; are
973equal to the corresponding members in <a href="#SkRect_equal_operator_b">b</a>.
974
975<a href="#SkRect_equal_operator_a">a</a> and <a href="#SkRect_equal_operator_b">b</a> are not equal if either contain NaN. <a href="#SkRect_equal_operator_a">a</a> and <a href="#SkRect_equal_operator_b">b</a> are equal if members
976contain zeroes width different signs.
977
978### Parameters
979
980<table>  <tr>    <td><a name="SkRect_equal_operator_a"> <code><strong>a </strong></code> </a></td> <td>
981<a href="#Rect">Rect</a> to compare</td>
982  </tr>  <tr>    <td><a name="SkRect_equal_operator_b"> <code><strong>b </strong></code> </a></td> <td>
983<a href="#Rect">Rect</a> to compare</td>
984  </tr>
985</table>
986
987### Return Value
988
989true if members are equal
990
991### Example
992
993<div><fiddle-embed name="c6c5b40cad7c3a839fdf576b380391a6">
994
995#### Example Output
996
997~~~~
998tests are equal
999{0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal
1000{0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal
1001{0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal
1002~~~~
1003
1004</fiddle-embed></div>
1005
1006### See Also
1007
1008<a href="#SkRect_notequal_operator">operator!=(const SkRect& a, const SkRect& b)</a>
1009
1010---
1011
1012<a name="SkRect_notequal_operator"></a>
1013## operator!=
1014
1015<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1016bool operator!=(const SkRect& a, const SkRect& b)
1017</pre>
1018
1019Returns true if any in <a href="#SkRect_notequal_operator_a">a</a>: <a href="#SkRect_fLeft">fLeft</a>, <a href="#SkRect_fTop">fTop</a>, <a href="#SkRect_fRight">fRight</a>, and <a href="#SkRect_fBottom">fBottom</a>; does not
1020equal the corresponding members in <a href="#SkRect_notequal_operator_b">b</a>.
1021
1022<a href="#SkRect_notequal_operator_a">a</a> and <a href="#SkRect_notequal_operator_b">b</a> are not equal if either contain NaN. <a href="#SkRect_notequal_operator_a">a</a> and <a href="#SkRect_notequal_operator_b">b</a> are equal if members
1023contain zeroes width different signs.
1024
1025### Parameters
1026
1027<table>  <tr>    <td><a name="SkRect_notequal_operator_a"> <code><strong>a </strong></code> </a></td> <td>
1028<a href="#Rect">Rect</a> to compare</td>
1029  </tr>  <tr>    <td><a name="SkRect_notequal_operator_b"> <code><strong>b </strong></code> </a></td> <td>
1030<a href="#Rect">Rect</a> to compare</td>
1031  </tr>
1032</table>
1033
1034### Return Value
1035
1036true if members are not equal
1037
1038### Example
1039
1040<div><fiddle-embed name="286072f8c27ff15be9eb945fa38dc9f7">
1041
1042#### Example Output
1043
1044~~~~
1045test with NaN is not equal to itself
1046~~~~
1047
1048</fiddle-embed></div>
1049
1050### See Also
1051
1052<a href="#SkRect_equal_operator">operator==(const SkRect& a, const SkRect& b)</a>
1053
1054---
1055
1056## <a name="As_Points"></a> As Points
1057
1058| name | description |
1059| --- | ---  |
1060| <a href="#SkRect_setBounds">setBounds</a> | sets to upper and lower limits of <a href="SkPoint_Reference#Point">Point</a> array |
1061| <a href="#SkRect_setBoundsCheck">setBoundsCheck</a> | sets to upper and lower limits of <a href="SkPoint_Reference#Point">Point</a> array |
1062| <a href="#SkRect_toQuad">toQuad</a> | returns four corners as <a href="SkPoint_Reference#Point">Point</a> |
1063
1064<a name="SkRect_toQuad"></a>
1065## toQuad
1066
1067<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1068void toQuad(SkPoint quad[4]) const
1069</pre>
1070
1071Returns four points in <a href="#SkRect_toQuad_quad">quad</a> that enclose <a href="#Rect">Rect</a> ordered as: top-left, top-right,
1072bottom-right, bottom-left.
1073
1074### Parameters
1075
1076<table>  <tr>    <td><a name="SkRect_toQuad_quad"> <code><strong>quad </strong></code> </a></td> <td>
1077storage for corners of <a href="#Rect">Rect</a></td>
1078  </tr>
1079</table>
1080
1081### Example
1082
1083<div><fiddle-embed name="59a6e7d202ac17ab80ec21b233e51f59">
1084
1085#### Example Output
1086
1087~~~~
1088rect: {1, 2, 3, 4}
1089corners: {1, 2} {3, 2} {3, 4} {1, 4}
1090~~~~
1091
1092</fiddle-embed></div>
1093
1094### See Also
1095
1096<a href="#SkPath_addRect">SkPath::addRect</a><sup><a href="#SkPath_addRect_2">[2]</a></sup><sup><a href="#SkPath_addRect_3">[3]</a></sup>
1097
1098---
1099
1100<a name="SkRect_setBounds"></a>
1101## setBounds
1102
1103<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1104void setBounds(const SkPoint pts[], int count)
1105</pre>
1106
1107Sets to bounds of <a href="SkPoint_Reference#Point">Point</a> array with <a href="#SkRect_setBounds_count">count</a> entries. If <a href="#SkRect_setBounds_count">count</a> is zero or smaller,
1108or if <a href="SkPoint_Reference#Point">Point</a> array contains an infinity or NaN, sets to (0, 0, 0, 0).
1109
1110Result is either empty or sorted: <a href="#SkRect_fLeft">fLeft</a> is less than or equal to <a href="#SkRect_fRight">fRight</a>, and
1111<a href="#SkRect_fTop">fTop</a> is less than or equal to <a href="#SkRect_fBottom">fBottom</a>.
1112
1113### Parameters
1114
1115<table>  <tr>    <td><a name="SkRect_setBounds_pts"> <code><strong>pts </strong></code> </a></td> <td>
1116<a href="SkPoint_Reference#Point">Point</a> array</td>
1117  </tr>  <tr>    <td><a name="SkRect_setBounds_count"> <code><strong>count </strong></code> </a></td> <td>
1118entries in array</td>
1119  </tr>
1120</table>
1121
1122### Example
1123
1124<div><fiddle-embed name="cf0da15f48aa54fd1889e7f913601710">
1125
1126#### Example Output
1127
1128~~~~
1129count: 0 rect: 0, 0, 0, 0
1130added:   3, 4 count: 1 rect: 3, 4, 3, 4
1131added:   1, 2 count: 2 rect: 1, 2, 3, 4
1132added:   5, 6 count: 3 rect: 1, 2, 5, 6
1133added: nan, 8 count: 4 rect: 0, 0, 0, 0
1134~~~~
1135
1136</fiddle-embed></div>
1137
1138### See Also
1139
1140<a href="#SkRect_set">set</a><sup><a href="#SkRect_set_2">[2]</a></sup><sup><a href="#SkRect_set_3">[3]</a></sup><sup><a href="#SkRect_set_4">[4]</a></sup> <a href="#SkRect_setBoundsCheck">setBoundsCheck</a> <a href="#SkPath_addPoly">SkPath::addPoly</a>
1141
1142---
1143
1144<a name="SkRect_setBoundsCheck"></a>
1145## setBoundsCheck
1146
1147<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1148bool setBoundsCheck(const SkPoint pts[], int count)
1149</pre>
1150
1151Sets to bounds of <a href="SkPoint_Reference#Point">Point</a> array with <a href="#SkRect_setBoundsCheck_count">count</a> entries. Returns false if <a href="#SkRect_setBoundsCheck_count">count</a> is
1152zero or smaller, or if <a href="SkPoint_Reference#Point">Point</a> array contains an infinity or NaN; in these cases
1153sets <a href="#Rect">Rect</a> to (0, 0, 0, 0).
1154
1155Result is either empty or sorted: <a href="#SkRect_fLeft">fLeft</a> is less than or equal to <a href="#SkRect_fRight">fRight</a>, and
1156<a href="#SkRect_fTop">fTop</a> is less than or equal to <a href="#SkRect_fBottom">fBottom</a>.
1157
1158### Parameters
1159
1160<table>  <tr>    <td><a name="SkRect_setBoundsCheck_pts"> <code><strong>pts </strong></code> </a></td> <td>
1161<a href="SkPoint_Reference#Point">Point</a> array</td>
1162  </tr>  <tr>    <td><a name="SkRect_setBoundsCheck_count"> <code><strong>count </strong></code> </a></td> <td>
1163entries in array</td>
1164  </tr>
1165</table>
1166
1167### Return Value
1168
1169true if all <a href="SkPoint_Reference#Point">Point</a> values are finite
1170
1171### Example
1172
1173<div><fiddle-embed name="83d879b92683b15f9daaf0c9e71c5b35">
1174
1175#### Example Output
1176
1177~~~~
1178count: 0 rect: 0, 0, 0, 0 success: true
1179added:   3, 4 count: 1 rect: 3, 4, 3, 4 success: true
1180added:   1, 2 count: 2 rect: 1, 2, 3, 4 success: true
1181added:   5, 6 count: 3 rect: 1, 2, 5, 6 success: true
1182added: nan, 8 count: 4 rect: 0, 0, 0, 0 success: false
1183~~~~
1184
1185</fiddle-embed></div>
1186
1187### See Also
1188
1189<a href="#SkRect_set">set</a><sup><a href="#SkRect_set_2">[2]</a></sup><sup><a href="#SkRect_set_3">[3]</a></sup><sup><a href="#SkRect_set_4">[4]</a></sup> <a href="#SkRect_setBounds">setBounds</a> <a href="#SkPath_addPoly">SkPath::addPoly</a>
1190
1191---
1192
1193## <a name="Set"></a> Set
1194
1195| name | description |
1196| --- | ---  |
1197| <a href="#SkRect_iset">iset</a> | sets to int input (left, top, right, bottom) |
1198| <a href="#SkRect_isetWH">isetWH</a> | sets to int input (0, 0, width, height) |
1199| <a href="#SkRect_set">set</a> | sets to <a href="undocumented#SkScalar">SkScalar</a> input (left, top, right, bottom) and others |
1200|  | void <a href="#SkRect_set">set(const SkIRect& src)</a> |
1201|  | void <a href="#SkRect_set_2">set(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)</a> |
1202|  | void <a href="#SkRect_set_3">set(const SkPoint pts[], int count)</a> |
1203|  | void <a href="#SkRect_set_4">set(const SkPoint& p0, const SkPoint& p1)</a> |
1204| <a href="#SkRect_setEmpty">setEmpty</a> | sets to (0, 0, 0, 0) |
1205| <a href="#SkRect_setLTRB">setLTRB</a> | sets to <a href="undocumented#SkScalar">SkScalar</a> input (left, top, right, bottom) |
1206| <a href="#SkRect_setWH">setWH</a> | sets to <a href="undocumented#SkScalar">SkScalar</a> input (0, 0, width, height) |
1207| <a href="#SkRect_setXYWH">setXYWH</a> | sets to <a href="undocumented#SkScalar">SkScalar</a> input (x, y, width, height) |
1208
1209<a name="SkRect_setEmpty"></a>
1210## setEmpty
1211
1212<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1213void setEmpty()
1214</pre>
1215
1216Sets <a href="#Rect">Rect</a> to (0, 0, 0, 0).
1217
1218Many other rectangles are empty; if left is equal to or greater than right,
1219or if top is equal to or greater than bottom. Setting all members to zero
1220is a convenience, but does not designate a special empty rectangle.
1221
1222### Example
1223
1224<div><fiddle-embed name="2cf67542d45ef5d7a7efb673b651ff54">
1225
1226#### Example Output
1227
1228~~~~
1229rect: {3, 4, 1, 2} is empty
1230rect: {0, 0, 0, 0} is empty
1231~~~~
1232
1233</fiddle-embed></div>
1234
1235### See Also
1236
1237<a href="#SkRect_MakeEmpty">MakeEmpty</a> <a href="#SkIRect_setEmpty">SkIRect::setEmpty</a>
1238
1239---
1240
1241<a name="SkRect_set"></a>
1242## set
1243
1244<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1245void set(const SkIRect& src)
1246</pre>
1247
1248Sets <a href="#Rect">Rect</a> to <a href="#SkRect_set_src">src</a>, promoting <a href="#SkRect_set_src">src</a> members from integer to <a href="#Scalar">Scalar</a>.
1249Very large values in <a href="#SkRect_set_src">src</a> may lose precision.
1250
1251### Parameters
1252
1253<table>  <tr>    <td><a name="SkRect_set_src"> <code><strong>src </strong></code> </a></td> <td>
1254integer <a href="#Rect">Rect</a></td>
1255  </tr>
1256</table>
1257
1258### Example
1259
1260<div><fiddle-embed name="a10ad8d97062bc3f40942f47e5108917">
1261
1262#### Example Output
1263
1264~~~~
1265i_rect: {3, 4, 1, 2}
1266f_rect: {3, 4, 1, 2}
1267~~~~
1268
1269</fiddle-embed></div>
1270
1271### See Also
1272
1273<a href="#SkRect_setLTRB">setLTRB</a> <a href="undocumented#SkIntToScalar">SkIntToScalar</a>
1274
1275---
1276
1277<a name="SkRect_set_2"></a>
1278
1279<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1280void set(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
1281</pre>
1282
1283Sets <a href="#Rect">Rect</a> to (left, top, right, bottom).
1284left and right are not sorted; left is not necessarily less than right.
1285top and bottom are not sorted; top is not necessarily less than bottom.
1286
1287### Parameters
1288
1289<table>  <tr>    <td><a name="SkRect_set_2_left"> <code><strong>left </strong></code> </a></td> <td>
1290stored in <a href="#SkRect_fLeft">fLeft</a></td>
1291  </tr>  <tr>    <td><a name="SkRect_set_2_top"> <code><strong>top </strong></code> </a></td> <td>
1292stored in <a href="#SkRect_fTop">fTop</a></td>
1293  </tr>  <tr>    <td><a name="SkRect_set_2_right"> <code><strong>right </strong></code> </a></td> <td>
1294stored in <a href="#SkRect_fRight">fRight</a></td>
1295  </tr>  <tr>    <td><a name="SkRect_set_2_bottom"> <code><strong>bottom </strong></code> </a></td> <td>
1296stored in <a href="#SkRect_fBottom">fBottom</a></td>
1297  </tr>
1298</table>
1299
1300### Example
1301
1302<div><fiddle-embed name="9b29ea460d69b4d47323fd9e3e17721e">
1303
1304#### Example Output
1305
1306~~~~
1307rect1: {3, 4, 1, 2}
1308rect2: {3, 4, 1, 2}
1309~~~~
1310
1311</fiddle-embed></div>
1312
1313### See Also
1314
1315<a href="#SkRect_setLTRB">setLTRB</a> <a href="#SkRect_setXYWH">setXYWH</a> <a href="#SkIRect_set">SkIRect::set</a>
1316
1317---
1318
1319<a name="SkRect_setLTRB"></a>
1320## setLTRB
1321
1322<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1323void setLTRB(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
1324</pre>
1325
1326Sets <a href="#Rect">Rect</a> to (left, top, right, bottom).
1327left and right are not sorted; left is not necessarily less than right.
1328top and bottom are not sorted; top is not necessarily less than bottom.
1329
1330### Parameters
1331
1332<table>  <tr>    <td><a name="SkRect_setLTRB_left"> <code><strong>left </strong></code> </a></td> <td>
1333stored in <a href="#SkRect_fLeft">fLeft</a></td>
1334  </tr>  <tr>    <td><a name="SkRect_setLTRB_top"> <code><strong>top </strong></code> </a></td> <td>
1335stored in <a href="#SkRect_fTop">fTop</a></td>
1336  </tr>  <tr>    <td><a name="SkRect_setLTRB_right"> <code><strong>right </strong></code> </a></td> <td>
1337stored in <a href="#SkRect_fRight">fRight</a></td>
1338  </tr>  <tr>    <td><a name="SkRect_setLTRB_bottom"> <code><strong>bottom </strong></code> </a></td> <td>
1339stored in <a href="#SkRect_fBottom">fBottom</a></td>
1340  </tr>
1341</table>
1342
1343### Example
1344
1345<div><fiddle-embed name="70692838793454c8e045d6eaf7edcbff">
1346
1347#### Example Output
1348
1349~~~~
1350rect1: {3, 4, 1, 2}
1351rect2: {3, 4, 1, 2}
1352~~~~
1353
1354</fiddle-embed></div>
1355
1356### See Also
1357
1358<a href="#SkRect_set">set</a><sup><a href="#SkRect_set_2">[2]</a></sup><sup><a href="#SkRect_set_3">[3]</a></sup><sup><a href="#SkRect_set_4">[4]</a></sup> <a href="#SkRect_setXYWH">setXYWH</a> <a href="#SkIRect_set">SkIRect::set</a>
1359
1360---
1361
1362<a name="SkRect_set_3"></a>
1363
1364<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1365void set(const SkPoint pts[], int count)
1366</pre>
1367
1368Sets to bounds of <a href="SkPoint_Reference#Point">Point</a> array with <a href="#SkRect_set_3_count">count</a> entries. If <a href="#SkRect_set_3_count">count</a> is zero or smaller,
1369or if <a href="SkPoint_Reference#Point">Point</a> array contains an infinity or NaN, sets <a href="#Rect">Rect</a> to (0, 0, 0, 0).
1370
1371Result is either empty or sorted: <a href="#SkRect_fLeft">fLeft</a> is less than or equal to <a href="#SkRect_fRight">fRight</a>, and
1372<a href="#SkRect_fTop">fTop</a> is less than or equal to <a href="#SkRect_fBottom">fBottom</a>.
1373
1374### Parameters
1375
1376<table>  <tr>    <td><a name="SkRect_set_3_pts"> <code><strong>pts </strong></code> </a></td> <td>
1377<a href="SkPoint_Reference#Point">Point</a> array</td>
1378  </tr>  <tr>    <td><a name="SkRect_set_3_count"> <code><strong>count </strong></code> </a></td> <td>
1379entries in array</td>
1380  </tr>
1381</table>
1382
1383### Example
1384
1385<div><fiddle-embed name="94295fa5197e21256171b99b4023dd48">
1386
1387#### Example Output
1388
1389~~~~
1390count: 0 rect: 0, 0, 0, 0
1391added:   3, 4 count: 1 rect: 3, 4, 3, 4
1392added:   1, 2 count: 2 rect: 1, 2, 3, 4
1393added:   5, 6 count: 3 rect: 1, 2, 5, 6
1394added: nan, 8 count: 4 rect: 0, 0, 0, 0
1395~~~~
1396
1397</fiddle-embed></div>
1398
1399### See Also
1400
1401<a href="#SkRect_setBounds">setBounds</a> <a href="#SkRect_setBoundsCheck">setBoundsCheck</a> <a href="#SkPath_addPoly">SkPath::addPoly</a>
1402
1403---
1404
1405<a name="SkRect_set_4"></a>
1406
1407<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1408void set(const SkPoint& p0, const SkPoint& p1)
1409</pre>
1410
1411Sets bounds to the smallest <a href="#Rect">Rect</a> enclosing <a href="#Point">Points</a> <a href="#SkRect_set_4_p0">p0</a> and <a href="#SkRect_set_4_p1">p1</a>. The result is
1412sorted and may be empty. Does not check to see if values are finite.
1413
1414### Parameters
1415
1416<table>  <tr>    <td><a name="SkRect_set_4_p0"> <code><strong>p0 </strong></code> </a></td> <td>
1417corner to include</td>
1418  </tr>  <tr>    <td><a name="SkRect_set_4_p1"> <code><strong>p1 </strong></code> </a></td> <td>
1419corner to include</td>
1420  </tr>
1421</table>
1422
1423### Example
1424
1425<div><fiddle-embed name="ee72450381f768f3869153cdbeccdc3e"><div><a href="#SkRect_set_4_p0">p0</a> and <a href="#SkRect_set_4_p1">p1</a> may be swapped and have the same effect unless one contains NaN.</div></fiddle-embed></div>
1426
1427### See Also
1428
1429<a href="#SkRect_setBounds">setBounds</a> <a href="#SkRect_setBoundsCheck">setBoundsCheck</a>
1430
1431---
1432
1433<a name="SkRect_setXYWH"></a>
1434## setXYWH
1435
1436<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1437void setXYWH(SkScalar x, SkScalar y, SkScalar width, SkScalar height)
1438</pre>
1439
1440Sets <a href="#Rect">Rect</a> to(x, y, x + width, y + height).
1441Does not validate input;
1442width or height may be negative.
1443
1444### Parameters
1445
1446<table>  <tr>    <td><a name="SkRect_setXYWH_x"> <code><strong>x </strong></code> </a></td> <td>
1447stored in <a href="#SkRect_fLeft">fLeft</a></td>
1448  </tr>  <tr>    <td><a name="SkRect_setXYWH_y"> <code><strong>y </strong></code> </a></td> <td>
1449stored in <a href="#SkRect_fTop">fTop</a></td>
1450  </tr>  <tr>    <td><a name="SkRect_setXYWH_width"> <code><strong>width </strong></code> </a></td> <td>
1451added to x and stored in <a href="#SkRect_fRight">fRight</a></td>
1452  </tr>  <tr>    <td><a name="SkRect_setXYWH_height"> <code><strong>height </strong></code> </a></td> <td>
1453added to y and stored in <a href="#SkRect_fBottom">fBottom</a></td>
1454  </tr>
1455</table>
1456
1457### Example
1458
1459<div><fiddle-embed name="373cce4c61b9da0384b735b838765163">
1460
1461#### Example Output
1462
1463~~~~
1464rect: 5, 35, -10, 60  isEmpty: true
1465rect: -10, 35, 5, 60  isEmpty: false
1466~~~~
1467
1468</fiddle-embed></div>
1469
1470### See Also
1471
1472<a href="#SkRect_MakeXYWH">MakeXYWH</a> <a href="#SkRect_setLTRB">setLTRB</a> <a href="#SkRect_set">set</a><sup><a href="#SkRect_set_2">[2]</a></sup><sup><a href="#SkRect_set_3">[3]</a></sup><sup><a href="#SkRect_set_4">[4]</a></sup> <a href="#SkIRect_setXYWH">SkIRect::setXYWH</a>
1473
1474---
1475
1476<a name="SkRect_setWH"></a>
1477## setWH
1478
1479<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1480void setWH(SkScalar width, SkScalar height)
1481</pre>
1482
1483Sets <a href="#Rect">Rect</a> to (0, 0, width, height). Does not validate input;
1484width or height may be negative.
1485
1486### Parameters
1487
1488<table>  <tr>    <td><a name="SkRect_setWH_width"> <code><strong>width </strong></code> </a></td> <td>
1489stored in <a href="#SkRect_fRight">fRight</a></td>
1490  </tr>  <tr>    <td><a name="SkRect_setWH_height"> <code><strong>height </strong></code> </a></td> <td>
1491stored in <a href="#SkRect_fBottom">fBottom</a></td>
1492  </tr>
1493</table>
1494
1495### Example
1496
1497<div><fiddle-embed name="9cb5fee17802fa49341f3707bdf5d235">
1498
1499#### Example Output
1500
1501~~~~
1502rect: 0, 0, -15, 25  isEmpty: true
1503rect: -15, 0, 0, 25  isEmpty: false
1504~~~~
1505
1506</fiddle-embed></div>
1507
1508### See Also
1509
1510<a href="#SkRect_MakeWH">MakeWH</a> <a href="#SkRect_setXYWH">setXYWH</a> <a href="#SkRect_isetWH">isetWH</a>
1511
1512---
1513
1514## <a name="From_Integers"></a> From Integers
1515
1516| name | description |
1517| --- | ---  |
1518| <a href="#SkRect_iset">iset</a> | sets to int input (left, top, right, bottom) |
1519| <a href="#SkRect_isetWH">isetWH</a> | sets to int input (0, 0, width, height) |
1520
1521<a name="SkRect_iset"></a>
1522## iset
1523
1524<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1525void iset(int left, int top, int right, int bottom)
1526</pre>
1527
1528Sets <a href="#Rect">Rect</a> to (left, top, right, bottom).
1529All parameters are promoted from integer to <a href="#Scalar">Scalar</a>.
1530left and right are not sorted; left is not necessarily less than right.
1531top and bottom are not sorted; top is not necessarily less than bottom.
1532
1533### Parameters
1534
1535<table>  <tr>    <td><a name="SkRect_iset_left"> <code><strong>left </strong></code> </a></td> <td>
1536promoted to <a href="undocumented#SkScalar">SkScalar</a> and stored in <a href="#SkRect_fLeft">fLeft</a></td>
1537  </tr>  <tr>    <td><a name="SkRect_iset_top"> <code><strong>top </strong></code> </a></td> <td>
1538promoted to <a href="undocumented#SkScalar">SkScalar</a> and stored in <a href="#SkRect_fTop">fTop</a></td>
1539  </tr>  <tr>    <td><a name="SkRect_iset_right"> <code><strong>right </strong></code> </a></td> <td>
1540promoted to <a href="undocumented#SkScalar">SkScalar</a> and stored in <a href="#SkRect_fRight">fRight</a></td>
1541  </tr>  <tr>    <td><a name="SkRect_iset_bottom"> <code><strong>bottom </strong></code> </a></td> <td>
1542promoted to <a href="undocumented#SkScalar">SkScalar</a> and stored in <a href="#SkRect_fBottom">fBottom</a></td>
1543  </tr>
1544</table>
1545
1546### Example
1547
1548<div><fiddle-embed name="18532f1aa90b76364fb8d7ea072f1892">
1549
1550#### Example Output
1551
1552~~~~
1553rect1: {3, 4, 1, 2}
1554rect2: {3, 4, 1, 2}
1555~~~~
1556
1557</fiddle-embed></div>
1558
1559### See Also
1560
1561<a href="#SkRect_set">set</a><sup><a href="#SkRect_set_2">[2]</a></sup><sup><a href="#SkRect_set_3">[3]</a></sup><sup><a href="#SkRect_set_4">[4]</a></sup> <a href="#SkRect_setLTRB">setLTRB</a> <a href="#SkIRect_set">SkIRect::set</a> <a href="undocumented#SkIntToScalar">SkIntToScalar</a>
1562
1563---
1564
1565<a name="SkRect_isetWH"></a>
1566## isetWH
1567
1568<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1569void isetWH(int width, int height)
1570</pre>
1571
1572Sets <a href="#Rect">Rect</a> to (0, 0, width, height).
1573width and height may be zero or negative. width and height are promoted from
1574integer to <a href="undocumented#SkScalar">SkScalar</a>, large values may lose precision.
1575
1576### Parameters
1577
1578<table>  <tr>    <td><a name="SkRect_isetWH_width"> <code><strong>width </strong></code> </a></td> <td>
1579promoted to <a href="undocumented#SkScalar">SkScalar</a> and stored in <a href="#SkRect_fRight">fRight</a></td>
1580  </tr>  <tr>    <td><a name="SkRect_isetWH_height"> <code><strong>height </strong></code> </a></td> <td>
1581promoted to <a href="undocumented#SkScalar">SkScalar</a> and stored in <a href="#SkRect_fBottom">fBottom</a></td>
1582  </tr>
1583</table>
1584
1585### Example
1586
1587<div><fiddle-embed name="ee6000080fc7123214ea404018cf9176">
1588
1589#### Example Output
1590
1591~~~~
1592rect1: {0, 0, 1, 2}
1593rect2: {0, 0, 1, 2}
1594~~~~
1595
1596</fiddle-embed></div>
1597
1598### See Also
1599
1600<a href="#SkRect_MakeWH">MakeWH</a> <a href="#SkRect_MakeXYWH">MakeXYWH</a> <a href="#SkRect_iset">iset</a> <a href="SkIRect_Reference#SkIRect">SkIRect</a>:<a href="#SkRect_MakeWH">MakeWH</a>
1601
1602---
1603
1604## <a name="Inset_Outset_Offset"></a> Inset Outset Offset
1605
1606| name | description |
1607| --- | ---  |
1608| <a href="#SkRect_inset">inset</a> | moves the sides symmetrically about the center |
1609| <a href="#SkRect_makeInset">makeInset</a> | constructs from sides moved symmetrically about the center |
1610| <a href="#SkRect_makeOffset">makeOffset</a> | constructs from translated sides |
1611| <a href="#SkRect_makeOutset">makeOutset</a> | constructs from sides moved symmetrically about the center |
1612| <a href="#SkRect_offset">offset</a> | translates sides without changing width and height |
1613|  | void <a href="#SkRect_offset">offset(SkScalar dx, SkScalar dy)</a> |
1614|  | void <a href="#SkRect_offset_2">offset(const SkPoint& delta)</a> |
1615| <a href="#SkRect_offsetTo">offsetTo</a> | translates to (x, y) without changing width and height |
1616| <a href="#SkRect_outset">outset</a> | moves the sides symmetrically about the center |
1617
1618<a name="SkRect_makeOffset"></a>
1619## makeOffset
1620
1621<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1622SkRect makeOffset(SkScalar dx, SkScalar dy) const
1623</pre>
1624
1625Returns <a href="#Rect">Rect</a> offset by (<a href="#SkRect_makeOffset_dx">dx</a>, <a href="#SkRect_makeOffset_dy">dy</a>).
1626
1627If <a href="#SkRect_makeOffset_dx">dx</a> is negative, <a href="#Rect">Rect</a> returned is moved to the left.
1628If <a href="#SkRect_makeOffset_dx">dx</a> is positive, <a href="#Rect">Rect</a> returned is moved to the right.
1629If <a href="#SkRect_makeOffset_dy">dy</a> is negative, <a href="#Rect">Rect</a> returned is moved upward.
1630If <a href="#SkRect_makeOffset_dy">dy</a> is positive, <a href="#Rect">Rect</a> returned is moved downward.
1631
1632### Parameters
1633
1634<table>  <tr>    <td><a name="SkRect_makeOffset_dx"> <code><strong>dx </strong></code> </a></td> <td>
1635added to <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fRight">fRight</a></td>
1636  </tr>  <tr>    <td><a name="SkRect_makeOffset_dy"> <code><strong>dy </strong></code> </a></td> <td>
1637added to <a href="#SkRect_fTop">fTop</a> and <a href="#SkRect_fBottom">fBottom</a></td>
1638  </tr>
1639</table>
1640
1641### Return Value
1642
1643<a href="#Rect">Rect</a> offset in x or y, with original width and height
1644
1645### Example
1646
1647<div><fiddle-embed name="98841ab0a932f99cccd8e6a34d94ba05">
1648
1649#### Example Output
1650
1651~~~~
1652rect: 10, 50, 20, 60  isEmpty: false
1653rect: 25, 82, 35, 92  isEmpty: false
1654~~~~
1655
1656</fiddle-embed></div>
1657
1658### See Also
1659
1660<a href="#SkRect_offset">offset</a><sup><a href="#SkRect_offset_2">[2]</a></sup> <a href="#SkRect_makeInset">makeInset</a> <a href="#SkRect_makeOutset">makeOutset</a> <a href="#SkIRect_makeOffset">SkIRect::makeOffset</a>
1661
1662---
1663
1664<a name="SkRect_makeInset"></a>
1665## makeInset
1666
1667<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1668SkRect makeInset(SkScalar dx, SkScalar dy) const
1669</pre>
1670
1671Returns <a href="#Rect">Rect</a>, inset by (<a href="#SkRect_makeInset_dx">dx</a>, <a href="#SkRect_makeInset_dy">dy</a>).
1672
1673If <a href="#SkRect_makeInset_dx">dx</a> is negative, <a href="#Rect">Rect</a> returned is wider.
1674If <a href="#SkRect_makeInset_dx">dx</a> is positive, <a href="#Rect">Rect</a> returned is narrower.
1675If <a href="#SkRect_makeInset_dy">dy</a> is negative, <a href="#Rect">Rect</a> returned is taller.
1676If <a href="#SkRect_makeInset_dy">dy</a> is positive, <a href="#Rect">Rect</a> returned is shorter.
1677
1678### Parameters
1679
1680<table>  <tr>    <td><a name="SkRect_makeInset_dx"> <code><strong>dx </strong></code> </a></td> <td>
1681added to <a href="#SkRect_fLeft">fLeft</a> and subtracted from <a href="#SkRect_fRight">fRight</a></td>
1682  </tr>  <tr>    <td><a name="SkRect_makeInset_dy"> <code><strong>dy </strong></code> </a></td> <td>
1683added to <a href="#SkRect_fTop">fTop</a> and subtracted from <a href="#SkRect_fBottom">fBottom</a></td>
1684  </tr>
1685</table>
1686
1687### Return Value
1688
1689<a href="#Rect">Rect</a> inset symmetrically left and right, top and bottom
1690
1691### Example
1692
1693<div><fiddle-embed name="b8d32ab2f7ea3d4d5fb5a4ea2156f1c5">
1694
1695#### Example Output
1696
1697~~~~
1698rect: 10, 50, 20, 60  isEmpty: false
1699rect: 25, 82, 5, 28  isEmpty: true
1700~~~~
1701
1702</fiddle-embed></div>
1703
1704### See Also
1705
1706<a href="#SkRect_inset">inset</a> <a href="#SkRect_makeOffset">makeOffset</a> <a href="#SkRect_makeOutset">makeOutset</a> <a href="#SkIRect_makeInset">SkIRect::makeInset</a>
1707
1708---
1709
1710<a name="SkRect_makeOutset"></a>
1711## makeOutset
1712
1713<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1714SkRect makeOutset(SkScalar dx, SkScalar dy) const
1715</pre>
1716
1717Returns <a href="#Rect">Rect</a>, outset by (<a href="#SkRect_makeOutset_dx">dx</a>, <a href="#SkRect_makeOutset_dy">dy</a>).
1718
1719If <a href="#SkRect_makeOutset_dx">dx</a> is negative, <a href="#Rect">Rect</a> returned is narrower.
1720If <a href="#SkRect_makeOutset_dx">dx</a> is positive, <a href="#Rect">Rect</a> returned is wider.
1721If <a href="#SkRect_makeOutset_dy">dy</a> is negative, <a href="#Rect">Rect</a> returned is shorter.
1722If <a href="#SkRect_makeOutset_dy">dy</a> is positive, <a href="#Rect">Rect</a> returned is taller.
1723
1724### Parameters
1725
1726<table>  <tr>    <td><a name="SkRect_makeOutset_dx"> <code><strong>dx </strong></code> </a></td> <td>
1727subtracted to <a href="#SkRect_fLeft">fLeft</a> and added from <a href="#SkRect_fRight">fRight</a></td>
1728  </tr>  <tr>    <td><a name="SkRect_makeOutset_dy"> <code><strong>dy </strong></code> </a></td> <td>
1729subtracted to <a href="#SkRect_fTop">fTop</a> and added from <a href="#SkRect_fBottom">fBottom</a></td>
1730  </tr>
1731</table>
1732
1733### Return Value
1734
1735<a href="#Rect">Rect</a> outset symmetrically left and right, top and bottom
1736
1737### Example
1738
1739<div><fiddle-embed name="87176fc60914cbca9c6a20998a033c24">
1740
1741#### Example Output
1742
1743~~~~
1744rect: 10, 50, 20, 60  isEmpty: false
1745rect: -5, 18, 35, 92  isEmpty: false
1746~~~~
1747
1748</fiddle-embed></div>
1749
1750### See Also
1751
1752<a href="#SkRect_outset">outset</a> <a href="#SkRect_makeOffset">makeOffset</a> <a href="#SkRect_makeInset">makeInset</a> <a href="#SkIRect_makeOutset">SkIRect::makeOutset</a>
1753
1754---
1755
1756<a name="SkRect_offset"></a>
1757## offset
1758
1759<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1760void offset(SkScalar dx, SkScalar dy)
1761</pre>
1762
1763Offsets <a href="#Rect">Rect</a> by adding <a href="#SkRect_offset_dx">dx</a> to <a href="#SkRect_fLeft">fLeft</a>, <a href="#SkRect_fRight">fRight</a>; and by adding <a href="#SkRect_offset_dy">dy</a> to <a href="#SkRect_fTop">fTop</a>, <a href="#SkRect_fBottom">fBottom</a>.
1764
1765If <a href="#SkRect_offset_dx">dx</a> is negative, moves <a href="#Rect">Rect</a> to the left.
1766If <a href="#SkRect_offset_dx">dx</a> is positive, moves <a href="#Rect">Rect</a> to the right.
1767If <a href="#SkRect_offset_dy">dy</a> is negative, moves <a href="#Rect">Rect</a> upward.
1768If <a href="#SkRect_offset_dy">dy</a> is positive, moves <a href="#Rect">Rect</a> downward.
1769
1770### Parameters
1771
1772<table>  <tr>    <td><a name="SkRect_offset_dx"> <code><strong>dx </strong></code> </a></td> <td>
1773offset added to <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fRight">fRight</a></td>
1774  </tr>  <tr>    <td><a name="SkRect_offset_dy"> <code><strong>dy </strong></code> </a></td> <td>
1775offset added to <a href="#SkRect_fTop">fTop</a> and <a href="#SkRect_fBottom">fBottom</a></td>
1776  </tr>
1777</table>
1778
1779### Example
1780
1781<div><fiddle-embed name="04eb33f0fd376f2942ca5f1c7f6cbcfc">
1782
1783#### Example Output
1784
1785~~~~
1786rect: 15, 27, 55, 86
1787~~~~
1788
1789</fiddle-embed></div>
1790
1791### See Also
1792
1793<a href="#SkRect_offsetTo">offsetTo</a> <a href="#SkRect_makeOffset">makeOffset</a> <a href="#SkIRect_offset">SkIRect::offset</a><sup><a href="#SkIRect_offset_2">[2]</a></sup>
1794
1795---
1796
1797<a name="SkRect_offset_2"></a>
1798
1799<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1800void offset(const SkPoint& delta)
1801</pre>
1802
1803Offsets <a href="#Rect">Rect</a> by adding <a href="#SkRect_offset_2_delta">delta</a>.fX to <a href="#SkRect_fLeft">fLeft</a>, <a href="#SkRect_fRight">fRight</a>; and by adding <a href="#SkRect_offset_2_delta">delta</a>.fY to
1804<a href="#SkRect_fTop">fTop</a>, <a href="#SkRect_fBottom">fBottom</a>.
1805
1806If <a href="#SkRect_offset_2_delta">delta</a>.fX is negative, moves <a href="#Rect">Rect</a> to the left.
1807If <a href="#SkRect_offset_2_delta">delta</a>.fX is positive, moves <a href="#Rect">Rect</a> to the right.
1808If <a href="#SkRect_offset_2_delta">delta</a>.fY is negative, moves <a href="#Rect">Rect</a> upward.
1809If <a href="#SkRect_offset_2_delta">delta</a>.fY is positive, moves <a href="#Rect">Rect</a> downward.
1810
1811### Parameters
1812
1813<table>  <tr>    <td><a name="SkRect_offset_2_delta"> <code><strong>delta </strong></code> </a></td> <td>
1814added to <a href="#Rect">Rect</a></td>
1815  </tr>
1816</table>
1817
1818### Example
1819
1820<div><fiddle-embed name="b24cf65561c98c1858a06c39f10fb797">
1821
1822#### Example Output
1823
1824~~~~
1825rect: 15, 27, 55, 86
1826~~~~
1827
1828</fiddle-embed></div>
1829
1830### See Also
1831
1832<a href="#SkRect_offsetTo">offsetTo</a> <a href="#SkRect_makeOffset">makeOffset</a> <a href="#SkIRect_offset">SkIRect::offset</a><sup><a href="#SkIRect_offset_2">[2]</a></sup>
1833
1834---
1835
1836<a name="SkRect_offsetTo"></a>
1837## offsetTo
1838
1839<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1840void offsetTo(SkScalar newX, SkScalar newY)
1841</pre>
1842
1843Offsets <a href="#Rect">Rect</a> so that <a href="#SkRect_fLeft">fLeft</a> equals <a href="#SkRect_offsetTo_newX">newX</a>, and <a href="#SkRect_fTop">fTop</a> equals <a href="#SkRect_offsetTo_newY">newY</a>. width and height
1844are unchanged.
1845
1846### Parameters
1847
1848<table>  <tr>    <td><a name="SkRect_offsetTo_newX"> <code><strong>newX </strong></code> </a></td> <td>
1849stored in <a href="#SkRect_fLeft">fLeft</a>, preserving <a href="#SkRect_width">width</a></td>
1850  </tr>  <tr>    <td><a name="SkRect_offsetTo_newY"> <code><strong>newY </strong></code> </a></td> <td>
1851stored in <a href="#SkRect_fTop">fTop</a>, preserving <a href="#SkRect_height">height</a></td>
1852  </tr>
1853</table>
1854
1855### Example
1856
1857<div><fiddle-embed name="bedb04b7b3e1af3e8039f9cffe66989e">
1858
1859#### Example Output
1860
1861~~~~
1862rect: 15, 27, 55, 86
1863~~~~
1864
1865</fiddle-embed></div>
1866
1867### See Also
1868
1869<a href="#SkRect_offset">offset</a><sup><a href="#SkRect_offset_2">[2]</a></sup> <a href="#SkRect_makeOffset">makeOffset</a> <a href="#SkRect_setXYWH">setXYWH</a> <a href="#SkIRect_offsetTo">SkIRect::offsetTo</a>
1870
1871---
1872
1873<a name="SkRect_inset"></a>
1874## inset
1875
1876<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1877void inset(SkScalar dx, SkScalar dy)
1878</pre>
1879
1880Insets <a href="#Rect">Rect</a> by (<a href="#SkRect_inset_dx">dx</a>, <a href="#SkRect_inset_dy">dy</a>).
1881
1882If <a href="#SkRect_inset_dx">dx</a> is positive, makes <a href="#Rect">Rect</a> narrower.
1883If <a href="#SkRect_inset_dx">dx</a> is negative, makes <a href="#Rect">Rect</a> wider.
1884If <a href="#SkRect_inset_dy">dy</a> is positive, makes <a href="#Rect">Rect</a> shorter.
1885If <a href="#SkRect_inset_dy">dy</a> is negative, makes <a href="#Rect">Rect</a> taller.
1886
1887### Parameters
1888
1889<table>  <tr>    <td><a name="SkRect_inset_dx"> <code><strong>dx </strong></code> </a></td> <td>
1890added to <a href="#SkRect_fLeft">fLeft</a> and subtracted from <a href="#SkRect_fRight">fRight</a></td>
1891  </tr>  <tr>    <td><a name="SkRect_inset_dy"> <code><strong>dy </strong></code> </a></td> <td>
1892added to <a href="#SkRect_fTop">fTop</a> and subtracted from <a href="#SkRect_fBottom">fBottom</a></td>
1893  </tr>
1894</table>
1895
1896### Example
1897
1898<div><fiddle-embed name="dae21340941dc6e4d048816dfd9f204c">
1899
1900#### Example Output
1901
1902~~~~
1903rect: 15, 27, 45, 60
1904~~~~
1905
1906</fiddle-embed></div>
1907
1908### See Also
1909
1910<a href="#SkRect_outset">outset</a> <a href="#SkRect_makeInset">makeInset</a> <a href="#SkIRect_inset">SkIRect::inset</a>
1911
1912---
1913
1914<a name="SkRect_outset"></a>
1915## outset
1916
1917<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1918void outset(SkScalar dx, SkScalar dy)
1919</pre>
1920
1921Outsets <a href="#Rect">Rect</a> by (<a href="#SkRect_outset_dx">dx</a>, <a href="#SkRect_outset_dy">dy</a>).
1922
1923If <a href="#SkRect_outset_dx">dx</a> is positive, makes <a href="#Rect">Rect</a> wider.
1924If <a href="#SkRect_outset_dx">dx</a> is negative, makes <a href="#Rect">Rect</a> narrower.
1925If <a href="#SkRect_outset_dy">dy</a> is positive, makes <a href="#Rect">Rect</a> taller.
1926If <a href="#SkRect_outset_dy">dy</a> is negative, makes <a href="#Rect">Rect</a> shorter.
1927
1928### Parameters
1929
1930<table>  <tr>    <td><a name="SkRect_outset_dx"> <code><strong>dx </strong></code> </a></td> <td>
1931subtracted to <a href="#SkRect_fLeft">fLeft</a> and added from <a href="#SkRect_fRight">fRight</a></td>
1932  </tr>  <tr>    <td><a name="SkRect_outset_dy"> <code><strong>dy </strong></code> </a></td> <td>
1933subtracted to <a href="#SkRect_fTop">fTop</a> and added from <a href="#SkRect_fBottom">fBottom</a></td>
1934  </tr>
1935</table>
1936
1937### Example
1938
1939<div><fiddle-embed name="861f873ba660af8c8bf8b0b83d829cf4">
1940
1941#### Example Output
1942
1943~~~~
1944rect: 5, 1, 55, 86
1945~~~~
1946
1947</fiddle-embed></div>
1948
1949### See Also
1950
1951<a href="#SkRect_inset">inset</a> <a href="#SkRect_makeOutset">makeOutset</a> <a href="#SkIRect_outset">SkIRect::outset</a>
1952
1953---
1954
1955## <a name="Intersection"></a> Intersection
1956
1957<a href="#Rect">Rects</a> intersect when they enclose a common area. To intersect, each of the pair
1958must describe area; <a href="#SkRect_fLeft">fLeft</a> is less than <a href="#SkRect_fRight">fRight</a>, and <a href="#SkRect_fTop">fTop</a> is less than <a href="#SkRect_fBottom">fBottom</a>;
1959empty() returns false. The intersection of <a href="#Rect">Rect</a> pair can be described by:
1960
1961(max(a.fLeft, b.fLeft), max(a.fTop, b.fTop),
1962min(a.fRight, b.fRight), min(a.fBottom, b.fBottom)).
1963
1964The intersection is only meaningful if the resulting <a href="#Rect">Rect</a> is not empty and
1965describes an area: <a href="#SkRect_fLeft">fLeft</a> is less than <a href="#SkRect_fRight">fRight</a>, and <a href="#SkRect_fTop">fTop</a> is less than <a href="#SkRect_fBottom">fBottom</a>.
1966
1967| name | description |
1968| --- | ---  |
1969| <a href="#SkRect_Intersects">Intersects</a> | returns true if areas overlap |
1970| <a href="#SkRect_contains">contains</a> | returns true if points are equal or inside |
1971|  | bool <a href="#SkRect_contains">contains(const SkRect& r)</a> const |
1972|  | bool <a href="#SkRect_contains_2">contains(const SkIRect& r)</a> const |
1973| <a href="#SkRect_intersect">intersect</a> | sets to shared area; returns true if not empty |
1974|  | bool <a href="#SkRect_intersect_2">intersect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)</a> |
1975|  | bool <a href="#SkRect_intersect">intersect(const SkRect& r)</a> |
1976|  | bool <a href="#SkRect_intersect_3">intersect(const SkRect& a, const SkRect& b)</a> |
1977| <a href="#SkRect_intersects">intersects</a> | returns true if areas overlap |
1978|  | bool <a href="#SkRect_intersects">intersects(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)</a> const |
1979|  | bool <a href="#SkRect_intersects_2">intersects(const SkRect& r)</a> const |
1980
1981<a name="SkRect_contains"></a>
1982## contains
1983
1984<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
1985bool contains(const SkRect& r) const
1986</pre>
1987
1988Returns true if <a href="#Rect">Rect</a> contains <a href="#SkRect_contains_r">r</a>.
1989Returns false if <a href="#Rect">Rect</a> is empty or <a href="#SkRect_contains_r">r</a> is empty.
1990
1991<a href="#Rect">Rect</a> contains <a href="#SkRect_contains_r">r</a> when <a href="#Rect">Rect</a> area completely includes <a href="#SkRect_contains_r">r</a> area.
1992
1993### Parameters
1994
1995<table>  <tr>    <td><a name="SkRect_contains_r"> <code><strong>r </strong></code> </a></td> <td>
1996<a href="#Rect">Rect</a> contained</td>
1997  </tr>
1998</table>
1999
2000### Return Value
2001
2002true if all sides of <a href="#Rect">Rect</a> are outside <a href="#SkRect_contains_r">r</a>
2003
2004### Example
2005
2006<div><fiddle-embed name="92f9e6aa5bb76791139a24cf7d8df99e">
2007
2008#### Example Output
2009
2010~~~~
2011rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
2012rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
2013rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
2014~~~~
2015
2016</fiddle-embed></div>
2017
2018### See Also
2019
2020<a href="#SkIRect_contains">SkIRect::contains</a><sup><a href="#SkIRect_contains_2">[2]</a></sup><sup><a href="#SkIRect_contains_3">[3]</a></sup><sup><a href="#SkIRect_contains_4">[4]</a></sup>
2021
2022---
2023
2024<a name="SkRect_contains_2"></a>
2025
2026<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2027bool contains(const SkIRect& r) const
2028</pre>
2029
2030Returns true if <a href="#Rect">Rect</a> contains <a href="#SkRect_contains_2_r">r</a>.
2031Returns false if <a href="#Rect">Rect</a> is empty or <a href="#SkRect_contains_2_r">r</a> is empty.
2032
2033<a href="#Rect">Rect</a> contains <a href="#SkRect_contains_2_r">r</a> when <a href="#Rect">Rect</a> area completely includes <a href="#SkRect_contains_2_r">r</a> area.
2034
2035### Parameters
2036
2037<table>  <tr>    <td><a name="SkRect_contains_2_r"> <code><strong>r </strong></code> </a></td> <td>
2038<a href="SkIRect_Reference#IRect">IRect</a> contained</td>
2039  </tr>
2040</table>
2041
2042### Return Value
2043
2044true if all sides of <a href="#Rect">Rect</a> are outside <a href="#SkRect_contains_2_r">r</a>
2045
2046### Example
2047
2048<div><fiddle-embed name="dd58b699551dd44026a2c6386be27d88">
2049
2050#### Example Output
2051
2052~~~~
2053rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
2054rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
2055rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
2056~~~~
2057
2058</fiddle-embed></div>
2059
2060### See Also
2061
2062<a href="#SkIRect_contains">SkIRect::contains</a><sup><a href="#SkIRect_contains_2">[2]</a></sup><sup><a href="#SkIRect_contains_3">[3]</a></sup><sup><a href="#SkIRect_contains_4">[4]</a></sup>
2063
2064---
2065
2066<a name="SkRect_intersect"></a>
2067## intersect
2068
2069<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2070bool intersect(const SkRect& r)
2071</pre>
2072
2073Returns true if <a href="#Rect">Rect</a> intersects <a href="#SkRect_intersect_r">r</a>, and sets <a href="#Rect">Rect</a> to intersection.
2074Returns false if <a href="#Rect">Rect</a> does not intersect <a href="#SkRect_intersect_r">r</a>, and leaves <a href="#Rect">Rect</a> unchanged.
2075
2076Returns false if either <a href="#SkRect_intersect_r">r</a> or <a href="#Rect">Rect</a> is empty, leaving <a href="#Rect">Rect</a> unchanged.
2077
2078### Parameters
2079
2080<table>  <tr>    <td><a name="SkRect_intersect_r"> <code><strong>r </strong></code> </a></td> <td>
2081limit of result</td>
2082  </tr>
2083</table>
2084
2085### Return Value
2086
2087true if <a href="#SkRect_intersect_r">r</a> and <a href="#Rect">Rect</a> have area in common
2088
2089### Example
2090
2091<div><fiddle-embed name="70e5b3979fc8a31eda070cfed91bc271"><div>Two <a href="undocumented#SkDebugf">SkDebugf</a> calls are required. If the calls are combined, their arguments
2092may not be evaluated in left to right order: the printed intersection may
2093be before or after the call to intersect.</div>
2094
2095#### Example Output
2096
2097~~~~
2098intersection: 30, 60, 50, 80
2099~~~~
2100
2101</fiddle-embed></div>
2102
2103### See Also
2104
2105<a href="#SkRect_intersects">intersects</a><sup><a href="#SkRect_intersects_2">[2]</a></sup> <a href="#SkRect_Intersects">Intersects</a> <a href="#SkRect_join">join</a><sup><a href="#SkRect_join_2">[2]</a></sup> <a href="#SkIRect_intersect">SkIRect::intersect</a><sup><a href="#SkIRect_intersect_2">[2]</a></sup><sup><a href="#SkIRect_intersect_3">[3]</a></sup>
2106
2107---
2108
2109<a name="SkRect_intersect_2"></a>
2110
2111<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2112bool intersect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
2113</pre>
2114
2115Constructs <a href="#Rect">Rect</a> to intersect from (left, top, right, bottom). Does not sort
2116construction.
2117
2118Returns true if <a href="#Rect">Rect</a> intersects construction, and sets <a href="#Rect">Rect</a> to intersection.
2119Returns false if <a href="#Rect">Rect</a> does not intersect construction, and leaves <a href="#Rect">Rect</a> unchanged.
2120
2121Returns false if either construction or <a href="#Rect">Rect</a> is empty, leaving <a href="#Rect">Rect</a> unchanged.
2122
2123### Parameters
2124
2125<table>  <tr>    <td><a name="SkRect_intersect_2_left"> <code><strong>left </strong></code> </a></td> <td>
2126x minimum of constructed <a href="#Rect">Rect</a></td>
2127  </tr>  <tr>    <td><a name="SkRect_intersect_2_top"> <code><strong>top </strong></code> </a></td> <td>
2128y minimum of constructed <a href="#Rect">Rect</a></td>
2129  </tr>  <tr>    <td><a name="SkRect_intersect_2_right"> <code><strong>right </strong></code> </a></td> <td>
2130x maximum of constructed <a href="#Rect">Rect</a></td>
2131  </tr>  <tr>    <td><a name="SkRect_intersect_2_bottom"> <code><strong>bottom </strong></code> </a></td> <td>
2132y maximum of constructed <a href="#Rect">Rect</a></td>
2133  </tr>
2134</table>
2135
2136### Return Value
2137
2138true if construction and <a href="#Rect">Rect</a> have area in common
2139
2140### Example
2141
2142<div><fiddle-embed name="9f06dad5e6c712f7a2c149d075e816d2"><div>Two <a href="undocumented#SkDebugf">SkDebugf</a> calls are required. If the calls are combined, their arguments
2143may not be evaluated in left to right order: the printed intersection may
2144be before or after the call to intersect.</div>
2145
2146#### Example Output
2147
2148~~~~
2149intersection: 30, 60, 50, 80
2150~~~~
2151
2152</fiddle-embed></div>
2153
2154### See Also
2155
2156<a href="#SkRect_intersects">intersects</a><sup><a href="#SkRect_intersects_2">[2]</a></sup> <a href="#SkRect_Intersects">Intersects</a> <a href="#SkRect_join">join</a><sup><a href="#SkRect_join_2">[2]</a></sup> <a href="#SkIRect_intersect">SkIRect::intersect</a><sup><a href="#SkIRect_intersect_2">[2]</a></sup><sup><a href="#SkIRect_intersect_3">[3]</a></sup>
2157
2158---
2159
2160<a name="SkRect_intersect_3"></a>
2161
2162<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2163bool SK_WARN_UNUSED_RESULT intersect(const SkRect& a, const SkRect& b)
2164</pre>
2165
2166Returns true if <a href="#SkRect_intersect_3_a">a</a> intersects <a href="#SkRect_intersect_3_b">b</a>, and sets <a href="#Rect">Rect</a> to intersection.
2167Returns false if <a href="#SkRect_intersect_3_a">a</a> does not intersect <a href="#SkRect_intersect_3_b">b</a>, and leaves <a href="#Rect">Rect</a> unchanged.
2168
2169Returns false if either <a href="#SkRect_intersect_3_a">a</a> or <a href="#SkRect_intersect_3_b">b</a> is empty, leaving <a href="#Rect">Rect</a> unchanged.
2170
2171### Parameters
2172
2173<table>  <tr>    <td><a name="SkRect_intersect_3_a"> <code><strong>a </strong></code> </a></td> <td>
2174<a href="#Rect">Rect</a> to intersect</td>
2175  </tr>  <tr>    <td><a name="SkRect_intersect_3_b"> <code><strong>b </strong></code> </a></td> <td>
2176<a href="#Rect">Rect</a> to intersect</td>
2177  </tr>
2178</table>
2179
2180### Return Value
2181
2182true if <a href="#SkRect_intersect_3_a">a</a> and <a href="#SkRect_intersect_3_b">b</a> have area in common
2183
2184### Example
2185
2186<div><fiddle-embed name="d610437a65dd3e952719efe605cbd0c7">
2187
2188#### Example Output
2189
2190~~~~
2191intersection: 30, 60, 50, 80
2192~~~~
2193
2194</fiddle-embed></div>
2195
2196### See Also
2197
2198<a href="#SkRect_intersects">intersects</a><sup><a href="#SkRect_intersects_2">[2]</a></sup> <a href="#SkRect_Intersects">Intersects</a> <a href="#SkRect_join">join</a><sup><a href="#SkRect_join_2">[2]</a></sup> <a href="#SkIRect_intersect">SkIRect::intersect</a><sup><a href="#SkIRect_intersect_2">[2]</a></sup><sup><a href="#SkIRect_intersect_3">[3]</a></sup>
2199
2200---
2201
2202<a name="SkRect_intersects"></a>
2203## intersects
2204
2205<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2206bool intersects(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) const
2207</pre>
2208
2209Constructs <a href="#Rect">Rect</a> to intersect from (left, top, right, bottom). Does not sort
2210construction.
2211
2212Returns true if <a href="#Rect">Rect</a> intersects construction.
2213Returns false if either construction or <a href="#Rect">Rect</a> is empty, or do not intersect.
2214
2215### Parameters
2216
2217<table>  <tr>    <td><a name="SkRect_intersects_left"> <code><strong>left </strong></code> </a></td> <td>
2218x minimum of constructed <a href="#Rect">Rect</a></td>
2219  </tr>  <tr>    <td><a name="SkRect_intersects_top"> <code><strong>top </strong></code> </a></td> <td>
2220y minimum of constructed <a href="#Rect">Rect</a></td>
2221  </tr>  <tr>    <td><a name="SkRect_intersects_right"> <code><strong>right </strong></code> </a></td> <td>
2222x maximum of constructed <a href="#Rect">Rect</a></td>
2223  </tr>  <tr>    <td><a name="SkRect_intersects_bottom"> <code><strong>bottom </strong></code> </a></td> <td>
2224y maximum of constructed <a href="#Rect">Rect</a></td>
2225  </tr>
2226</table>
2227
2228### Return Value
2229
2230true if construction and <a href="#Rect">Rect</a> have area in common
2231
2232### Example
2233
2234<div><fiddle-embed name="7145dc17ebce4f54e892102f6c98e811">
2235
2236#### Example Output
2237
2238~~~~
2239intersection
2240~~~~
2241
2242</fiddle-embed></div>
2243
2244### See Also
2245
2246<a href="#SkRect_intersect">intersect</a><sup><a href="#SkRect_intersect_2">[2]</a></sup><sup><a href="#SkRect_intersect_3">[3]</a></sup> <a href="#SkRect_Intersects">Intersects</a> <a href="#SkIRect_Intersects">SkIRect::Intersects</a>
2247
2248---
2249
2250<a name="SkRect_intersects_2"></a>
2251
2252<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2253bool intersects(const SkRect& r) const
2254</pre>
2255
2256Returns true if <a href="#Rect">Rect</a> intersects <a href="#SkRect_intersects_2_r">r</a>.
2257Returns false if either <a href="#SkRect_intersects_2_r">r</a> or <a href="#Rect">Rect</a> is empty, or do not intersect.
2258
2259### Parameters
2260
2261<table>  <tr>    <td><a name="SkRect_intersects_2_r"> <code><strong>r </strong></code> </a></td> <td>
2262<a href="#Rect">Rect</a> to intersect</td>
2263  </tr>
2264</table>
2265
2266### Return Value
2267
2268true if <a href="#SkRect_intersects_2_r">r</a> and <a href="#Rect">Rect</a> have area in common
2269
2270### Example
2271
2272<div><fiddle-embed name="ca37b4231b21eb8296cb19ba9e0c781b">
2273
2274#### Example Output
2275
2276~~~~
2277intersection
2278~~~~
2279
2280</fiddle-embed></div>
2281
2282### See Also
2283
2284<a href="#SkRect_intersect">intersect</a><sup><a href="#SkRect_intersect_2">[2]</a></sup><sup><a href="#SkRect_intersect_3">[3]</a></sup> <a href="#SkRect_Intersects">Intersects</a> <a href="#SkIRect_Intersects">SkIRect::Intersects</a>
2285
2286---
2287
2288<a name="SkRect_Intersects"></a>
2289## Intersects
2290
2291<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2292static bool Intersects(const SkRect& a, const SkRect& b)
2293</pre>
2294
2295Returns true if <a href="#SkRect_Intersects_a">a</a> intersects <a href="#SkRect_Intersects_b">b</a>.
2296Returns false if either <a href="#SkRect_Intersects_a">a</a> or <a href="#SkRect_Intersects_b">b</a> is empty, or do not intersect.
2297
2298### Parameters
2299
2300<table>  <tr>    <td><a name="SkRect_Intersects_a"> <code><strong>a </strong></code> </a></td> <td>
2301<a href="#Rect">Rect</a> to intersect</td>
2302  </tr>  <tr>    <td><a name="SkRect_Intersects_b"> <code><strong>b </strong></code> </a></td> <td>
2303<a href="#Rect">Rect</a> to intersect</td>
2304  </tr>
2305</table>
2306
2307### Return Value
2308
2309true if <a href="#SkRect_Intersects_a">a</a> and <a href="#SkRect_Intersects_b">b</a> have area in common
2310
2311### Example
2312
2313<div><fiddle-embed name="795061764b10c9e05efb466c9cb60644">
2314
2315#### Example Output
2316
2317~~~~
2318intersection
2319~~~~
2320
2321</fiddle-embed></div>
2322
2323### See Also
2324
2325<a href="#SkRect_intersect">intersect</a><sup><a href="#SkRect_intersect_2">[2]</a></sup><sup><a href="#SkRect_intersect_3">[3]</a></sup> <a href="#SkRect_intersects">intersects</a><sup><a href="#SkRect_intersects_2">[2]</a></sup> <a href="#SkIRect_Intersects">SkIRect::Intersects</a>
2326
2327---
2328
2329## <a name="Join"></a> Join
2330
2331| name | description |
2332| --- | ---  |
2333| <a href="#SkRect_join">join</a> | sets to union of bounds |
2334|  | void <a href="#SkRect_join">join(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)</a> |
2335|  | void <a href="#SkRect_join_2">join(const SkRect& r)</a> |
2336| <a href="#SkRect_joinNonEmptyArg">joinNonEmptyArg</a> | sets to union of bounds, asserting that argument is not empty |
2337| <a href="#SkRect_joinPossiblyEmptyRect">joinPossiblyEmptyRect</a> | sets to union of bounds. Skips empty check for both |
2338
2339<a name="SkRect_join"></a>
2340## join
2341
2342<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2343void join(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
2344</pre>
2345
2346Constructs <a href="#Rect">Rect</a> to intersect from (left, top, right, bottom). Does not sort
2347construction.
2348
2349Sets <a href="#Rect">Rect</a> to the union of itself and the construction.
2350
2351Has no effect if construction is empty. Otherwise, if <a href="#Rect">Rect</a> is empty, sets
2352<a href="#Rect">Rect</a> to construction.
2353
2354### Parameters
2355
2356<table>  <tr>    <td><a name="SkRect_join_left"> <code><strong>left </strong></code> </a></td> <td>
2357x minimum of constructed <a href="#Rect">Rect</a></td>
2358  </tr>  <tr>    <td><a name="SkRect_join_top"> <code><strong>top </strong></code> </a></td> <td>
2359y minimum of constructed <a href="#Rect">Rect</a></td>
2360  </tr>  <tr>    <td><a name="SkRect_join_right"> <code><strong>right </strong></code> </a></td> <td>
2361x maximum of constructed <a href="#Rect">Rect</a></td>
2362  </tr>  <tr>    <td><a name="SkRect_join_bottom"> <code><strong>bottom </strong></code> </a></td> <td>
2363y maximum of constructed <a href="#Rect">Rect</a></td>
2364  </tr>
2365</table>
2366
2367### Example
2368
2369<div><fiddle-embed name="afa9c6b4d05bb669db07fe0b7b97e6aa">
2370
2371#### Example Output
2372
2373~~~~
2374join: 10, 20, 55, 65
2375~~~~
2376
2377</fiddle-embed></div>
2378
2379### See Also
2380
2381<a href="#SkRect_joinNonEmptyArg">joinNonEmptyArg</a> <a href="#SkRect_joinPossiblyEmptyRect">joinPossiblyEmptyRect</a> <a href="#SkIRect_join">SkIRect::join</a><sup><a href="#SkIRect_join_2">[2]</a></sup>
2382
2383---
2384
2385<a name="SkRect_join_2"></a>
2386
2387<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2388void join(const SkRect& r)
2389</pre>
2390
2391Sets <a href="#Rect">Rect</a> to the union of itself and <a href="#SkRect_join_2_r">r</a>.
2392
2393Has no effect if <a href="#SkRect_join_2_r">r</a> is empty. Otherwise, if <a href="#Rect">Rect</a> is empty, sets
2394<a href="#Rect">Rect</a> to <a href="#SkRect_join_2_r">r</a>.
2395
2396### Parameters
2397
2398<table>  <tr>    <td><a name="SkRect_join_2_r"> <code><strong>r </strong></code> </a></td> <td>
2399expansion <a href="#Rect">Rect</a></td>
2400  </tr>
2401</table>
2402
2403### Example
2404
2405<div><fiddle-embed name="26500032494cf93c5fa3423110fe82af">
2406
2407#### Example Output
2408
2409~~~~
2410join: 10, 20, 55, 65
2411~~~~
2412
2413</fiddle-embed></div>
2414
2415### See Also
2416
2417<a href="#SkRect_joinNonEmptyArg">joinNonEmptyArg</a> <a href="#SkRect_joinPossiblyEmptyRect">joinPossiblyEmptyRect</a> <a href="#SkIRect_join">SkIRect::join</a><sup><a href="#SkIRect_join_2">[2]</a></sup>
2418
2419---
2420
2421<a name="SkRect_joinNonEmptyArg"></a>
2422## joinNonEmptyArg
2423
2424<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2425void joinNonEmptyArg(const SkRect& r)
2426</pre>
2427
2428Sets <a href="#Rect">Rect</a> to the union of itself and <a href="#SkRect_joinNonEmptyArg_r">r</a>.
2429
2430Asserts if <a href="#SkRect_joinNonEmptyArg_r">r</a> is empty and SK_DEBUG is defined.
2431If <a href="#Rect">Rect</a> is empty, sets <a href="#Rect">Rect</a> to <a href="#SkRect_joinNonEmptyArg_r">r</a>.
2432
2433May produce incorrect results if <a href="#SkRect_joinNonEmptyArg_r">r</a> is empty.
2434
2435### Parameters
2436
2437<table>  <tr>    <td><a name="SkRect_joinNonEmptyArg_r"> <code><strong>r </strong></code> </a></td> <td>
2438expansion <a href="#Rect">Rect</a></td>
2439  </tr>
2440</table>
2441
2442### Example
2443
2444<div><fiddle-embed name="88439de2aa0911262c60c0eb506396cb"><div>Since <a href="#Rect">Rect</a> is not sorted, first result is copy of toJoin.</div>
2445
2446#### Example Output
2447
2448~~~~
2449rect: 50, 60, 55, 65
2450sorted: 10, 0, 55, 100
2451~~~~
2452
2453</fiddle-embed></div>
2454
2455### See Also
2456
2457<a href="#SkRect_join">join</a><sup><a href="#SkRect_join_2">[2]</a></sup> <a href="#SkRect_joinPossiblyEmptyRect">joinPossiblyEmptyRect</a> <a href="#SkIRect_join">SkIRect::join</a><sup><a href="#SkIRect_join_2">[2]</a></sup>
2458
2459---
2460
2461<a name="SkRect_joinPossiblyEmptyRect"></a>
2462## joinPossiblyEmptyRect
2463
2464<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2465void joinPossiblyEmptyRect(const SkRect& r)
2466</pre>
2467
2468Sets <a href="#Rect">Rect</a> to the union of itself and the construction.
2469
2470May produce incorrect results if <a href="#Rect">Rect</a> or <a href="#SkRect_joinPossiblyEmptyRect_r">r</a> is empty.
2471
2472### Parameters
2473
2474<table>  <tr>    <td><a name="SkRect_joinPossiblyEmptyRect_r"> <code><strong>r </strong></code> </a></td> <td>
2475expansion <a href="#Rect">Rect</a></td>
2476  </tr>
2477</table>
2478
2479### Example
2480
2481<div><fiddle-embed name="a476548d0001296afd8e58c1eba1b70b"><div>Since <a href="#Rect">Rect</a> is not sorted, first result is not useful.</div>
2482
2483#### Example Output
2484
2485~~~~
2486rect: 10, 60, 55, 65
2487sorted: 10, 0, 55, 100
2488~~~~
2489
2490</fiddle-embed></div>
2491
2492### See Also
2493
2494<a href="#SkRect_joinNonEmptyArg">joinNonEmptyArg</a> <a href="#SkRect_join">join</a><sup><a href="#SkRect_join_2">[2]</a></sup> <a href="#SkIRect_join">SkIRect::join</a><sup><a href="#SkIRect_join_2">[2]</a></sup>
2495
2496---
2497
2498## <a name="Rounding"></a> Rounding
2499
2500| name | description |
2501| --- | ---  |
2502| <a href="#SkRect_round_2">round</a> | sets members to nearest integer value |
2503|  | void <a href="#SkRect_round">round(SkIRect* dst)</a> const |
2504|  | <a href="SkIRect_Reference#SkIRect">SkIRect</a> <a href="#SkRect_round_2">round</a> const |
2505| <a href="#SkRect_roundIn">roundIn</a> | sets members to nearest integer value towards opposite |
2506| <a href="#SkRect_roundOut">roundOut</a> | sets members to nearest integer value away from opposite |
2507|  | void <a href="#SkRect_roundOut">roundOut(SkIRect* dst)</a> const |
2508|  | void <a href="#SkRect_roundOut_2">roundOut(SkRect* dst)</a> const |
2509|  | <a href="SkIRect_Reference#SkIRect">SkIRect</a> <a href="#SkRect_roundOut_3">roundOut</a> const |
2510
2511<a name="SkRect_round"></a>
2512## round
2513
2514<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2515void round(SkIRect* dst) const
2516</pre>
2517
2518Sets <a href="SkIRect_Reference#IRect">IRect</a> by adding 0.5 and discarding the fractional portion of <a href="#Rect">Rect</a>
2519members, using(.
2520
2521### Parameters
2522
2523<table>  <tr>    <td><a name="SkRect_round_dst"> <code><strong>dst </strong></code> </a></td> <td>
2524storage for <a href="SkIRect_Reference#IRect">IRect</a></td>
2525  </tr>
2526</table>
2527
2528### Example
2529
2530<div><fiddle-embed name="8b9e5a9af0a9b878f76919534d88f41e">
2531
2532#### Example Output
2533
2534~~~~
2535round: 31, 51, 41, 61
2536~~~~
2537
2538</fiddle-embed></div>
2539
2540### See Also
2541
2542<a href="#SkRect_roundIn">roundIn</a> <a href="#SkRect_roundOut">roundOut</a><sup><a href="#SkRect_roundOut_2">[2]</a></sup><sup><a href="#SkRect_roundOut_3">[3]</a></sup> <a href="undocumented#SkScalarRoundToInt">SkScalarRoundToInt</a>
2543
2544---
2545
2546<a name="SkRect_roundOut"></a>
2547## roundOut
2548
2549<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2550void roundOut(SkIRect* dst) const
2551</pre>
2552
2553Sets <a href="SkIRect_Reference#IRect">IRect</a> by discarding the fractional portion of <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fTop">fTop</a>; and
2554rounding up <a href="#SkRect_fRight">fRight</a> and FBottom, using(.
2555
2556### Parameters
2557
2558<table>  <tr>    <td><a name="SkRect_roundOut_dst"> <code><strong>dst </strong></code> </a></td> <td>
2559storage for <a href="SkIRect_Reference#IRect">IRect</a></td>
2560  </tr>
2561</table>
2562
2563### Example
2564
2565<div><fiddle-embed name="0bd13d7e6426ae7a3befa2ab151ac5fc">
2566
2567#### Example Output
2568
2569~~~~
2570round: 30, 50, 41, 61
2571~~~~
2572
2573</fiddle-embed></div>
2574
2575### See Also
2576
2577<a href="#SkRect_roundIn">roundIn</a> <a href="#SkRect_round">round</a><sup><a href="#SkRect_round_2">[2]</a></sup> <a href="undocumented#SkScalarRoundToInt">SkScalarRoundToInt</a>
2578
2579---
2580
2581<a name="SkRect_roundOut_2"></a>
2582
2583<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2584void roundOut(SkRect* dst) const
2585</pre>
2586
2587Sets <a href="#Rect">Rect</a> by discarding the fractional portion of <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fTop">fTop</a>; and
2588rounding up <a href="#SkRect_fRight">fRight</a> and FBottom, using(.
2589
2590### Parameters
2591
2592<table>  <tr>    <td><a name="SkRect_roundOut_2_dst"> <code><strong>dst </strong></code> </a></td> <td>
2593storage for <a href="#Rect">Rect</a></td>
2594  </tr>
2595</table>
2596
2597### Example
2598
2599<div><fiddle-embed name="e09a6a12869a8ac21e9c2af98a5bb686">
2600
2601#### Example Output
2602
2603~~~~
2604round: 30, 50, 41, 61
2605~~~~
2606
2607</fiddle-embed></div>
2608
2609### See Also
2610
2611<a href="#SkRect_roundIn">roundIn</a> <a href="#SkRect_round">round</a><sup><a href="#SkRect_round_2">[2]</a></sup> <a href="undocumented#SkScalarRoundToInt">SkScalarRoundToInt</a>
2612
2613---
2614
2615<a name="SkRect_roundIn"></a>
2616## roundIn
2617
2618<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2619void roundIn(SkIRect* dst) const
2620</pre>
2621
2622Sets <a href="#Rect">Rect</a> by rounding up <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fTop">fTop</a>; and
2623discarding the fractional portion of <a href="#SkRect_fRight">fRight</a> and FBottom, using(.
2624
2625### Parameters
2626
2627<table>  <tr>    <td><a name="SkRect_roundIn_dst"> <code><strong>dst </strong></code> </a></td> <td>
2628storage for <a href="SkIRect_Reference#IRect">IRect</a></td>
2629  </tr>
2630</table>
2631
2632### Example
2633
2634<div><fiddle-embed name="abb337da8fc1891f016c61258681c64c">
2635
2636#### Example Output
2637
2638~~~~
2639round: 31, 51, 40, 60
2640~~~~
2641
2642</fiddle-embed></div>
2643
2644### See Also
2645
2646<a href="#SkRect_roundOut">roundOut</a><sup><a href="#SkRect_roundOut_2">[2]</a></sup><sup><a href="#SkRect_roundOut_3">[3]</a></sup> <a href="#SkRect_round">round</a><sup><a href="#SkRect_round_2">[2]</a></sup> <a href="undocumented#SkScalarRoundToInt">SkScalarRoundToInt</a>
2647
2648---
2649
2650<a name="SkRect_round_2"></a>
2651
2652<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2653SkIRect round() const
2654</pre>
2655
2656Returns <a href="SkIRect_Reference#IRect">IRect</a> by adding 0.5 and discarding the fractional portion of <a href="#Rect">Rect</a>
2657members, using(.
2658
2659### Return Value
2660
2661rounded <a href="SkIRect_Reference#IRect">IRect</a>
2662
2663### Example
2664
2665<div><fiddle-embed name="ef7ae1dd522c235b0afe41b55a624f46">
2666
2667#### Example Output
2668
2669~~~~
2670round: 31, 51, 41, 61
2671~~~~
2672
2673</fiddle-embed></div>
2674
2675### See Also
2676
2677<a href="#SkRect_roundOut">roundOut</a><sup><a href="#SkRect_roundOut_2">[2]</a></sup><sup><a href="#SkRect_roundOut_3">[3]</a></sup> <a href="#SkRect_roundIn">roundIn</a> <a href="undocumented#SkScalarRoundToInt">SkScalarRoundToInt</a>
2678
2679---
2680
2681<a name="SkRect_roundOut_3"></a>
2682
2683<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2684SkIRect roundOut() const
2685</pre>
2686
2687Sets <a href="SkIRect_Reference#IRect">IRect</a> by discarding the fractional portion of <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fTop">fTop</a>; and
2688rounding up <a href="#SkRect_fRight">fRight</a> and FBottom, using(.
2689
2690### Return Value
2691
2692rounded <a href="SkIRect_Reference#IRect">IRect</a>
2693
2694### Example
2695
2696<div><fiddle-embed name="05f0f65ae148f192656cd87df90f1d57">
2697
2698#### Example Output
2699
2700~~~~
2701round: 30, 50, 41, 61
2702~~~~
2703
2704</fiddle-embed></div>
2705
2706### See Also
2707
2708<a href="#SkRect_round">round</a><sup><a href="#SkRect_round_2">[2]</a></sup> <a href="#SkRect_roundIn">roundIn</a> <a href="undocumented#SkScalarRoundToInt">SkScalarRoundToInt</a>
2709
2710---
2711
2712## <a name="Sorting"></a> Sorting
2713
2714| name | description |
2715| --- | ---  |
2716| <a href="#SkRect_makeSorted">makeSorted</a> | constructs, ordering sides from smaller to larger |
2717| <a href="#SkRect_sort">sort</a> | orders sides from smaller to larger |
2718
2719<a name="SkRect_sort"></a>
2720## sort
2721
2722<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2723void sort()
2724</pre>
2725
2726Swaps <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fRight">fRight</a> if <a href="#SkRect_fLeft">fLeft</a> is greater than <a href="#SkRect_fRight">fRight</a>; and swaps
2727<a href="#SkRect_fTop">fTop</a> and <a href="#SkRect_fBottom">fBottom</a> if <a href="#SkRect_fTop">fTop</a> is greater than <a href="#SkRect_fBottom">fBottom</a>. Result may be empty;
2728and <a href="#SkRect_width">width</a> and <a href="#SkRect_height">height</a> will be zero or positive.
2729
2730### Example
2731
2732<div><fiddle-embed name="e624fe398e3d770b573c09fc74c0c400">
2733
2734#### Example Output
2735
2736~~~~
2737rect: 30.5, 50.5, 20.5, 10.5
2738sorted: 20.5, 10.5, 30.5, 50.5
2739~~~~
2740
2741</fiddle-embed></div>
2742
2743### See Also
2744
2745<a href="#SkRect_makeSorted">makeSorted</a> <a href="#SkIRect_sort">SkIRect::sort</a> <a href="#SkRect_isSorted">isSorted</a>
2746
2747---
2748
2749<a name="SkRect_makeSorted"></a>
2750## makeSorted
2751
2752<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2753SkRect makeSorted() const
2754</pre>
2755
2756Returns <a href="#Rect">Rect</a> with <a href="#SkRect_fLeft">fLeft</a> and <a href="#SkRect_fRight">fRight</a> swapped if <a href="#SkRect_fLeft">fLeft</a> is greater than <a href="#SkRect_fRight">fRight</a>; and
2757with <a href="#SkRect_fTop">fTop</a> and <a href="#SkRect_fBottom">fBottom</a> swapped if <a href="#SkRect_fTop">fTop</a> is greater than <a href="#SkRect_fBottom">fBottom</a>. Result may be empty;
2758and <a href="#SkRect_width">width</a> and <a href="#SkRect_height">height</a> will be zero or positive.
2759
2760### Return Value
2761
2762sorted <a href="#Rect">Rect</a>
2763
2764### Example
2765
2766<div><fiddle-embed name="f59567042b87f6b26f9bfeeb04468032">
2767
2768#### Example Output
2769
2770~~~~
2771rect: 30.5, 50.5, 20.5, 10.5
2772sorted: 20.5, 10.5, 30.5, 50.5
2773~~~~
2774
2775</fiddle-embed></div>
2776
2777### See Also
2778
2779<a href="#SkRect_sort">sort</a> <a href="#SkIRect_makeSorted">SkIRect::makeSorted</a> <a href="#SkRect_isSorted">isSorted</a>
2780
2781---
2782
2783<a name="SkRect_asScalars"></a>
2784## asScalars
2785
2786<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2787const SkScalar* asScalars() const
2788</pre>
2789
2790Returns pointer to first <a href="#Scalar">Scalar</a> in <a href="#Rect">Rect</a>, to treat it as an array with four
2791entries.
2792
2793### Return Value
2794
2795pointer to <a href="#SkRect_fLeft">fLeft</a>
2796
2797### Example
2798
2799<div><fiddle-embed name="e1ea5f949d80276f3637931eae93a07c">
2800
2801#### Example Output
2802
2803~~~~
2804rect.asScalars() == &rect.fLeft
2805~~~~
2806
2807</fiddle-embed></div>
2808
2809### See Also
2810
2811<a href="#SkRect_toQuad">toQuad</a>
2812
2813---
2814
2815<a name="SkRect_dump"></a>
2816## dump
2817
2818<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2819void dump(bool asHex) const
2820</pre>
2821
2822Writes text representation of <a href="#Rect">Rect</a> to standard output. <a href="#Set">Set</a> <a href="#SkRect_dump_asHex">asHex</a> to true to
2823generate exact binary representations of floating point numbers.
2824
2825### Parameters
2826
2827<table>  <tr>    <td><a name="SkRect_dump_asHex"> <code><strong>asHex </strong></code> </a></td> <td>
2828true if <a href="undocumented#SkScalar">SkScalar</a> values are written as hexadecimal</td>
2829  </tr>
2830</table>
2831
2832### Example
2833
2834<div><fiddle-embed name="cea049ffff702a5923da41fe0ae0763b">
2835
2836#### Example Output
2837
2838~~~~
2839SkRect::MakeLTRB(20, 30, 40, 50);
2840SkRect::MakeLTRB(SkBits2Float(0x41a00000), /* 20.000000 */
2841SkBits2Float(0x41f00000), /* 30.000000 */
2842SkBits2Float(0x42200000), /* 40.000000 */
2843SkBits2Float(0x42480000)  /* 50.000000 */);
2844~~~~
2845
2846</fiddle-embed></div>
2847
2848### See Also
2849
2850<a href="#SkRect_dumpHex">dumpHex</a>
2851
2852---
2853
2854<a name="SkRect_dump_2"></a>
2855
2856<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2857void dump() const
2858</pre>
2859
2860Writes text representation of <a href="#Rect">Rect</a> to standard output. The representation may be
2861directly compiled as C++ code. Floating point values are written
2862with limited precision; it may not be possible to reconstruct original <a href="#Rect">Rect</a>
2863from output.
2864
2865### Example
2866
2867<div><fiddle-embed name="9fb76971b1a104a2a59816e0392267a7">
2868
2869#### Example Output
2870
2871~~~~
2872SkRect::MakeLTRB(0.857143f, 0.666667f, 2.6f, 7);
2873rect is not equal to copy
2874~~~~
2875
2876</fiddle-embed></div>
2877
2878### See Also
2879
2880<a href="#SkRect_dumpHex">dumpHex</a>
2881
2882---
2883
2884<a name="SkRect_dumpHex"></a>
2885## dumpHex
2886
2887<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2888void dumpHex() const
2889</pre>
2890
2891Writes text representation of <a href="#Rect">Rect</a> to standard output. The representation may be
2892directly compiled as C++ code. Floating point values are written
2893in hexadecimal to preserve their exact bit pattern. The output reconstructs the
2894original <a href="#Rect">Rect</a>.
2895
2896Use instead of <a href="#SkRect_dump_2">dump</a> when submitting <a href="http://bug.skia.org">bug reports against Skia</a> .
2897
2898### Example
2899
2900<div><fiddle-embed name="824b5a3fcfd46a7e1c5f9e3c16e6bb39">
2901
2902#### Example Output
2903
2904~~~~
2905SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
2906SkBits2Float(0x3f2aaaab), /* 0.666667 */
2907SkBits2Float(0x40266666), /* 2.600000 */
2908SkBits2Float(0x40e00000)  /* 7.000000 */);
2909rect is equal to copy
2910~~~~
2911
2912</fiddle-embed></div>
2913
2914### See Also
2915
2916<a href="#SkRect_dump">dump</a><sup><a href="#SkRect_dump_2">[2]</a></sup>
2917
2918---
2919
2920<a name="SkRect_MakeLargest"></a>
2921## MakeLargest
2922
2923<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
2924static SkRect SK_WARN_UNUSED_RESULT MakeLargest()
2925</pre>
2926
2927Returns constructed <a href="#SkRect">SkRect</a> setting left and top to most negative finite value, and
2928setting right and bottom to most positive finite value.
2929
2930### Return Value
2931
2932bounds (<a href="undocumented#SK_ScalarMin">SK ScalarMin</a>, <a href="undocumented#SK_ScalarMin">SK ScalarMin</a>, <a href="undocumented#SK_ScalarMax">SK ScalarMax</a>, <a href="undocumented#SK_ScalarMax">SK ScalarMax</a>)
2933
2934---
2935
2936