blob: ddebdb104ff8dcf31869d24ba478dc9cc12536d9 [file] [log] [blame]
Cary Clarkbc5697d2017-10-04 14:31:33 -04001#Topic Rect
2#Alias Rects
3#Alias Rect_Reference
4
5#Struct SkRect
6
Cary Clark7fc1d122017-10-09 14:07:42 -04007SkRect holds four SkScalar coordinates describing the upper and
8lower bounds of a rectangle. SkRect may be created from outer bounds or
9from position, width, and height. SkRect describes an area; if its right
10is less than or equal to its left, or if its bottom is less than or equal to
11its top, it is considered empty.
12
13# move to topic about MakeIWH and friends
14SkRect can be constructed from int values to avoid compiler warnings that
15integer input cannot convert to SkScalar without loss of precision.
16
Cary Clarkbc5697d2017-10-04 14:31:33 -040017#Topic Overview
18
19#Subtopic Subtopics
20#ToDo manually add subtopics ##
21#Table
22#Legend
23# topics # description ##
24#Legend ##
25#Table ##
26##
27
28#Subtopic Operators
29#Table
30#Legend
Cary Clark884dd7d2017-10-11 10:37:52 -040031# description # function ##
Cary Clarkbc5697d2017-10-04 14:31:33 -040032#Legend ##
Cary Clarka560c472017-11-27 10:44:06 -050033# bool operator!=(const SkRect& a, const SkRect& b) # Returns true if members are unequal. ##
34# bool operator==(const SkRect& a, const SkRect& b) # Returns true if members are equal. ##
Cary Clarkbc5697d2017-10-04 14:31:33 -040035#Table ##
36#Subtopic ##
37
38#Subtopic Member_Functions
39#Table
40#Legend
Cary Clark7fc1d122017-10-09 14:07:42 -040041# description # function ##
Cary Clarkbc5697d2017-10-04 14:31:33 -040042#Legend ##
Cary Clark7fc1d122017-10-09 14:07:42 -040043# Intersects # Returns true if areas overlap. ##
44# Make # Constructs from ISize returning (0, 0, width, height). ##
45# MakeEmpty # Constructs from bounds of (0, 0, 0, 0). ##
46# MakeFromIRect # Deprecated. ##
47# MakeIWH # Constructs from int input returning (0, 0, width, height). ##
48# MakeLTRB # Constructs from SkScalar left, top, right, bottom. ##
Cary Clark7fc1d122017-10-09 14:07:42 -040049# MakeSize # Constructs from Size returning (0, 0, width, height). ##
50# MakeWH # Constructs from SkScalar input returning (0, 0, width, height). ##
51# MakeXYWH # Constructs from SkScalar input returning (x, y, width, height). ##
52# asScalars # Returns pointer to members as array. ##
53# bottom() # Returns larger bounds in y, if sorted. ##
54# centerX # Returns midpoint in x. ##
55# centerY # Returns midpoint in y. ##
56# contains() # Returns true if points are equal or inside. ##
57# dump() # Sends text representation using floats to standard output. ##
58# dumpHex # Sends text representation using hexadecimal to standard output. ##
Cary Clark7fc1d122017-10-09 14:07:42 -040059# height # Returns span in y. ##
60# inset() # Moves the sides symmetrically about the center. ##
61# intersect() # Sets to shared area; returns true if not empty. ##
62# intersects() # Returns true if areas overlap. ##
63# isEmpty # Returns true if width or height are zero or negative. ##
64# isFinite # Returns true if no member is infinite or NaN. ##
Cary Clark7fc1d122017-10-09 14:07:42 -040065# isSorted # Returns true if width or height are zero or positive. ##
66# iset() # Sets to int input (left, top, right, bottom). ##
67# isetWH # Sets to int input (0, 0, width, height). ##
68# join() # Sets to union of bounds. ##
69# joinNonEmptyArg # Sets to union of bounds, asserting that argument is not empty. ##
70# joinPossiblyEmptyRect # Sets to union of bounds. Skips empty check for both. ##
71# left() # Returns smaller bounds in x, if sorted. ##
72# makeInset # Constructs from sides moved symmetrically about the center. ##
73# makeOffset # Constructs from translated sides. ##
74# makeOutset # Constructs from sides moved symmetrically about the center. ##
75# makeSorted # Constructs, ordering sides from smaller to larger. ##
76# offset() # Translates sides without changing width and height. ##
77# offsetTo # Translates to (x, y) without changing width and height. ##
78# outset() # Moves the sides symmetrically about the center. ##
79# right() # Returns larger bounds in x, if sorted. ##
80# round() # Sets members to nearest integer value. ##
81# roundIn # Sets members to nearest integer value towards opposite. ##
82# roundOut # Sets members to nearest integer value away from opposite. ##
83# set() # Sets to SkScalar input (left, top, right, bottom) and others. ##
84# setBounds # Sets to upper and lower limits of Point array. ##
85# setBoundsCheck # Sets to upper and lower limits of Point array. ##
86# setEmpty # Sets to (0, 0, 0, 0). ##
87# setLTRB # Sets to SkScalar input (left, top, right, bottom). ##
Cary Clark7fc1d122017-10-09 14:07:42 -040088# setWH # Sets to SkScalar input (0, 0, width, height). ##
89# setXYWH # Sets to SkScalar input (x, y, width, height). ##
90# sort() # Orders sides from smaller to larger. ##
91# toQuad # Returns four corners as Point. ##
92# top() # Returns smaller bounds in y, if sorted. ##
93# width() # Returns span in x. ##
94# x() # Returns bounds left. ##
95# y() # Returns bounds top. ##
Cary Clarkbc5697d2017-10-04 14:31:33 -040096#Table ##
97#Subtopic ##
98
99#Topic ##
100
101#Member SkScalar fLeft
Cary Clark7fc1d122017-10-09 14:07:42 -0400102May contain any value, including infinities and NaN. The smaller of the
103horizontal values when sorted. When equal to or greater than fRight, Rect is empty.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400104##
105
106#Member SkScalar fTop
Cary Clark7fc1d122017-10-09 14:07:42 -0400107May contain any value, including infinities and NaN. The smaller of the
108vertical values when sorted. When equal to or greater than fBottom, Rect is empty.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400109##
110
111#Member SkScalar fRight
Cary Clark7fc1d122017-10-09 14:07:42 -0400112May contain any value, including infinities and NaN. The larger of the
113horizontal values when sorted. When equal to or less than fLeft, Rect is empty.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400114##
115
116#Member SkScalar fBottom
Cary Clark7fc1d122017-10-09 14:07:42 -0400117May contain any value, including infinities and NaN. The larger of the
118vertical values when sorted. When equal to or less than fTop, Rect is empty.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400119##
120
121# ------------------------------------------------------------------------------
122
123#Method static constexpr SkRect SK_WARN_UNUSED_RESULT MakeEmpty()
124
Cary Clark7fc1d122017-10-09 14:07:42 -0400125Returns constructed Rect set to (0, 0, 0, 0).
126Many other rectangles are empty; if left is equal to or greater than right,
127or if top is equal to or greater than bottom. Setting all members to zero
128is a convenience, but does not designate a special empty rectangle.
129
130#Return bounds (0, 0, 0, 0) ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400131
132#Example
Cary Clark154beea2017-10-26 07:58:48 -0400133 SkRect rect = SkRect::MakeEmpty();
134 SkDebugf("MakeEmpty isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
135 rect.offset(10, 10);
136 SkDebugf("offset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
137 rect.inset(10, 10);
138 SkDebugf("inset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
139 rect.outset(20, 20);
140 SkDebugf("outset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
141#StdOut
142MakeEmpty isEmpty: true
143offset rect isEmpty: true
144inset rect isEmpty: true
145outset rect isEmpty: false
146##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400147##
148
Mike Reed274218e2018-01-08 15:05:02 -0500149#SeeAlso isEmpty setEmpty SkIRect::MakeEmpty
Cary Clark884dd7d2017-10-11 10:37:52 -0400150
151##
152
153# ------------------------------------------------------------------------------
154
155#Method static constexpr SkRect SK_WARN_UNUSED_RESULT MakeWH(SkScalar w, SkScalar h)
Cary Clarkbc5697d2017-10-04 14:31:33 -0400156
Cary Clark7fc1d122017-10-09 14:07:42 -0400157Returns constructed Rect set to SkScalar values (0, 0, w, h). Does not
158validate input; w or h may be negative.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400159
Cary Clark7fc1d122017-10-09 14:07:42 -0400160Passing integer values may generate a compiler warning since Rect cannot
161represent 32-bit integers exactly. Use SkIRect for an exact integer rectangle.
162
163#Param w SkScalar width of constructed Rect ##
164#Param h SkScalar height of constructed Rect ##
165
166#Return bounds (0, 0, w, h) ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400167
168#Example
Cary Clark154beea2017-10-26 07:58:48 -0400169 SkRect rect1 = SkRect::MakeWH(25, 35);
170 SkRect rect2 = SkRect::MakeIWH(25, 35);
171 SkRect rect3 = SkRect::MakeXYWH(0, 0, 25, 35);
172 SkRect rect4 = SkRect::MakeLTRB(0, 0, 25, 35);
173 SkDebugf("all %s" "equal\n", rect1 == rect2 && rect2 == rect3 && rect3 == rect4 ?
Cary Clark7fc1d122017-10-09 14:07:42 -0400174 "" : "not ");
175#StdOut
176all equal
177##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400178##
179
Cary Clark7fc1d122017-10-09 14:07:42 -0400180#SeeAlso MakeSize MakeXYWH MakeIWH setWH SkIRect::MakeWH
Cary Clarkbc5697d2017-10-04 14:31:33 -0400181
182##
183
184# ------------------------------------------------------------------------------
185
186#Method static SkRect SK_WARN_UNUSED_RESULT MakeIWH(int w, int h)
187
Cary Clark7fc1d122017-10-09 14:07:42 -0400188Returns constructed Rect set to integer values (0, 0, w, h). Does not validate
189input; w or h may be negative.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400190
Cary Clark7fc1d122017-10-09 14:07:42 -0400191Use to avoid a compiler warning that input may lose precision when stored.
192Use SkIRect for an exact integer rectangle.
193
194#Param w integer width of constructed Rect ##
195#Param h integer height of constructed Rect ##
196
197#Return bounds (0, 0, w, h) ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400198
199#Example
Cary Clark154beea2017-10-26 07:58:48 -0400200 SkIRect i_rect = SkIRect::MakeWH(25, 35);
201 SkRect f_rect = SkRect::MakeIWH(25, 35);
202 SkDebugf("i_rect width: %d f_rect width:%g\n", i_rect.width(), f_rect.width());
203 i_rect = SkIRect::MakeWH(125000111, 0);
204 f_rect = SkRect::MakeIWH(125000111, 0);
205 SkDebugf("i_rect width: %d f_rect width:%.0f\n", i_rect.width(), f_rect.width());
Cary Clark7fc1d122017-10-09 14:07:42 -0400206#StdOut
Cary Clark154beea2017-10-26 07:58:48 -0400207i_rect width: 25 f_rect width:25
Cary Clark7fc1d122017-10-09 14:07:42 -0400208i_rect width: 125000111 f_rect width:125000112
209##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400210##
211
Cary Clark7fc1d122017-10-09 14:07:42 -0400212#SeeAlso MakeXYWH MakeWH isetWH SkIRect::MakeWH
Cary Clarkbc5697d2017-10-04 14:31:33 -0400213
214##
215
216# ------------------------------------------------------------------------------
217
Cary Clark884dd7d2017-10-11 10:37:52 -0400218#Method static constexpr SkRect SK_WARN_UNUSED_RESULT MakeSize(const SkSize& size)
Cary Clarkbc5697d2017-10-04 14:31:33 -0400219
Cary Clark7fc1d122017-10-09 14:07:42 -0400220Returns constructed Rect set to (0, 0, size.width(), size.height()). Does not
221validate input; size.width() or size.height() may be negative.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400222
Cary Clark7fc1d122017-10-09 14:07:42 -0400223#Param size SkScalar values for Rect width and height ##
224
225#Return bounds (0, 0, size.width(), size.height()) ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400226
227#Example
Cary Clark154beea2017-10-26 07:58:48 -0400228 SkSize size = {25.5f, 35.5f};
229 SkRect rect = SkRect::MakeSize(size);
230 SkDebugf("rect width: %g height: %g\n", rect.width(), rect.height());
231 SkISize floor = size.toFloor();
232 rect = SkRect::MakeSize(SkSize::Make(floor));
233 SkDebugf("floor width: %g height: %g\n", rect.width(), rect.height());
Cary Clark7fc1d122017-10-09 14:07:42 -0400234#StdOut
Cary Clark154beea2017-10-26 07:58:48 -0400235rect width: 25.5 height: 35.5
Cary Clark7fc1d122017-10-09 14:07:42 -0400236floor width: 25 height: 35
237##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400238##
239
Cary Clark7fc1d122017-10-09 14:07:42 -0400240#SeeAlso MakeWH MakeXYWH MakeIWH setWH SkIRect::MakeWH
Cary Clarkbc5697d2017-10-04 14:31:33 -0400241
242##
243
244# ------------------------------------------------------------------------------
245
246#Method static constexpr SkRect SK_WARN_UNUSED_RESULT MakeLTRB(SkScalar l, SkScalar t, SkScalar r,
247 SkScalar b)
248
Cary Clark7fc1d122017-10-09 14:07:42 -0400249Returns constructed Rect set to (l, t, r, b). Does not sort input; Rect may
250result in fLeft greater than fRight, or fTop greater than fBottom.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400251
Cary Clark7fc1d122017-10-09 14:07:42 -0400252#Param l SkScalar stored in fLeft ##
253#Param t SkScalar stored in fTop ##
254#Param r SkScalar stored in fRight ##
255#Param b SkScalar stored in fBottom ##
256
257#Return bounds (l, t, r, b) ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400258
259#Example
Cary Clark154beea2017-10-26 07:58:48 -0400260 SkRect rect = SkRect::MakeLTRB(5, 35, 15, 25);
261 SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
262 rect.bottom(), rect.isEmpty() ? "true" : "false");
263 rect.sort();
264 SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
265 rect.bottom(), rect.isEmpty() ? "true" : "false");
Cary Clark7fc1d122017-10-09 14:07:42 -0400266#StdOut
Cary Clark154beea2017-10-26 07:58:48 -0400267rect: 5, 35, 15, 25 isEmpty: true
Cary Clark7fc1d122017-10-09 14:07:42 -0400268rect: 5, 25, 15, 35 isEmpty: false
269##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400270##
271
Cary Clark7fc1d122017-10-09 14:07:42 -0400272#SeeAlso MakeXYWH SkIRect::MakeLTRB
Cary Clarkbc5697d2017-10-04 14:31:33 -0400273
274##
275
276# ------------------------------------------------------------------------------
277
Cary Clark884dd7d2017-10-11 10:37:52 -0400278#Method static constexpr SkRect SK_WARN_UNUSED_RESULT MakeXYWH(SkScalar x, SkScalar y, SkScalar w, SkScalar h)
Cary Clarkbc5697d2017-10-04 14:31:33 -0400279
Cary Clark7fc1d122017-10-09 14:07:42 -0400280Returns constructed Rect set to
281#Formula
282(x, y, x + w, y + h)
283##
284. Does not validate input;
285w or h may be negative.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400286
Cary Clark7fc1d122017-10-09 14:07:42 -0400287#Param x stored in fLeft ##
288#Param y stored in fTop ##
289#Param w added to x and stored in fRight ##
290#Param h added to y and stored in fBottom ##
291
Cary Clark884dd7d2017-10-11 10:37:52 -0400292#Return bounds at (x, y) with width w and height h ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400293
294#Example
Cary Clark154beea2017-10-26 07:58:48 -0400295 SkRect rect = SkRect::MakeXYWH(5, 35, -15, 25);
296 SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
297 rect.bottom(), rect.isEmpty() ? "true" : "false");
298 rect.sort();
299 SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
300 rect.bottom(), rect.isEmpty() ? "true" : "false");
Cary Clark7fc1d122017-10-09 14:07:42 -0400301#StdOut
Cary Clark154beea2017-10-26 07:58:48 -0400302rect: 5, 35, -10, 60 isEmpty: true
Cary Clark7fc1d122017-10-09 14:07:42 -0400303rect: -10, 35, 5, 60 isEmpty: false
304##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400305##
306
Cary Clark7fc1d122017-10-09 14:07:42 -0400307#SeeAlso MakeLTRB SkIRect::MakeXYWH
Cary Clarkbc5697d2017-10-04 14:31:33 -0400308
309##
310
311# ------------------------------------------------------------------------------
312
313#Method static SkRect SK_WARN_UNUSED_RESULT MakeFromIRect(const SkIRect& irect)
314
Cary Clark7fc1d122017-10-09 14:07:42 -0400315Deprecated.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400316
Cary Clark7fc1d122017-10-09 14:07:42 -0400317#Deprecated
Cary Clarkbc5697d2017-10-04 14:31:33 -0400318##
319
Cary Clark7fc1d122017-10-09 14:07:42 -0400320#Param irect integer rect ##
321
322#Return irect as SkRect ##
323
324#NoExample
325##
326
327#SeeAlso Make
Cary Clarkbc5697d2017-10-04 14:31:33 -0400328
329##
330
331# ------------------------------------------------------------------------------
332
333#Method static SkRect Make(const SkISize& size)
334
Cary Clark7fc1d122017-10-09 14:07:42 -0400335Returns constructed IRect set to (0, 0, size.width(), size.height()).
336Does not validate input; size.width() or size.height() may be negative.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400337
Cary Clark7fc1d122017-10-09 14:07:42 -0400338#Param size integer values for Rect width and height ##
339
340#Return bounds (0, 0, size.width(), size.height()) ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400341
342#Example
Cary Clark154beea2017-10-26 07:58:48 -0400343 SkRect rect1 = SkRect::MakeSize({2, 35});
344 SkRect rect2 = SkRect::MakeIWH(2, 35);
345 SkDebugf("rect1 %c= rect2\n", rect1 == rect2 ? '=' : '!');
Cary Clark7fc1d122017-10-09 14:07:42 -0400346#StdOut
347rect1 == rect2
348##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400349##
350
Cary Clark7fc1d122017-10-09 14:07:42 -0400351#SeeAlso MakeWH MakeXYWH SkRect::MakeIWH SkIRect::MakeSize
Cary Clarkbc5697d2017-10-04 14:31:33 -0400352
353##
354
355# ------------------------------------------------------------------------------
356
357#Method static SkRect SK_WARN_UNUSED_RESULT Make(const SkIRect& irect)
358
Cary Clark7fc1d122017-10-09 14:07:42 -0400359Returns constructed IRect set to irect, promoting integers to Scalar.
360Does not validate input; fLeft may be greater than fRight, fTop may be greater
361than fBottom.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400362
Cary Clark7fc1d122017-10-09 14:07:42 -0400363#Param irect integer unsorted bounds ##
364
365#Return irect members converted to SkScalar ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400366
367#Example
Cary Clark154beea2017-10-26 07:58:48 -0400368 SkIRect i_rect1 = {2, 35, 22, 53};
369 SkRect f_rect = SkRect::Make(i_rect1);
370 f_rect.offset(0.49f, 0.49f);
371 SkIRect i_rect2;
372 f_rect.round(&i_rect2);
373 SkDebugf("i_rect1 %c= i_rect2\n", i_rect1 == i_rect2? '=' : '!');
Cary Clarkbc5697d2017-10-04 14:31:33 -0400374##
375
Cary Clark7fc1d122017-10-09 14:07:42 -0400376#SeeAlso MakeLTRB
Cary Clarkbc5697d2017-10-04 14:31:33 -0400377
378##
379
380# ------------------------------------------------------------------------------
381
382#Method bool isEmpty() const
383
Cary Clark7fc1d122017-10-09 14:07:42 -0400384Returns true if fLeft is equal to or greater than fRight, or if fTop is equal
385to or greater than fBottom. Call sort() to reverse rectangles with negative
386width() or height().
Cary Clarkbc5697d2017-10-04 14:31:33 -0400387
Cary Clark7fc1d122017-10-09 14:07:42 -0400388#Return true if width() or height() are zero or negative ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400389
390#Example
Cary Clark154beea2017-10-26 07:58:48 -0400391 SkRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}};
392 for (auto rect : tests) {
393 SkDebugf("rect: {%g, %g, %g, %g} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
394 rect.bottom(), rect.isEmpty() ? "" : " not");
395 rect.sort();
396 SkDebugf("sorted: {%g, %g, %g, %g} is" "%s empty\n", rect.left(), rect.top(), rect.right(),
397 rect.bottom(), rect.isEmpty() ? "" : " not");
398 }
399#StdOut
400rect: {20, 40, 10, 50} is empty
401sorted: {10, 40, 20, 50} is not empty
402rect: {20, 40, 20, 50} is empty
403sorted: {20, 40, 20, 50} is empty
404##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400405##
406
Cary Clark7fc1d122017-10-09 14:07:42 -0400407#SeeAlso MakeEmpty sort SkIRect::isEmpty
Cary Clarkbc5697d2017-10-04 14:31:33 -0400408
409##
410
411# ------------------------------------------------------------------------------
412
413#Method bool isSorted() const
414
Cary Clark7fc1d122017-10-09 14:07:42 -0400415Returns true if fLeft is equal to or less than fRight, or if fTop is equal
416to or less than fBottom. Call sort() to reverse rectangles with negative
417width() or height().
Cary Clarkbc5697d2017-10-04 14:31:33 -0400418
Cary Clark7fc1d122017-10-09 14:07:42 -0400419#Return true if width() or height() are zero or positive ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400420
421#Example
Cary Clark154beea2017-10-26 07:58:48 -0400422 SkRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}};
423 for (auto rect : tests) {
424 SkDebugf("rect: {%g, %g, %g, %g} is" "%s sorted\n", rect.left(), rect.top(), rect.right(),
425 rect.bottom(), rect.isSorted() ? "" : " not");
426 rect.sort();
427 SkDebugf("sorted: {%g, %g, %g, %g} is" "%s sorted\n", rect.left(), rect.top(), rect.right(),
428 rect.bottom(), rect.isSorted() ? "" : " not");
429 }
430#StdOut
431rect: {20, 40, 10, 50} is not sorted
432sorted: {10, 40, 20, 50} is sorted
433rect: {20, 40, 20, 50} is sorted
434sorted: {20, 40, 20, 50} is sorted
435##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400436##
437
Cary Clark7fc1d122017-10-09 14:07:42 -0400438#SeeAlso sort makeSorted isEmpty
Cary Clarkbc5697d2017-10-04 14:31:33 -0400439
440##
441
442# ------------------------------------------------------------------------------
443
Cary Clarkbc5697d2017-10-04 14:31:33 -0400444#Method bool isFinite() const
445
Cary Clark7fc1d122017-10-09 14:07:42 -0400446Returns true if all values in the rectangle are finite: SK_ScalarMin or larger,
447and SK_ScalarMax or smaller.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400448
Cary Clark7fc1d122017-10-09 14:07:42 -0400449#Return true if no member is infinite or NaN ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400450
451#Example
Mike Reed274218e2018-01-08 15:05:02 -0500452SkRect largest = { SK_ScalarMin, SK_ScalarMin, SK_ScalarMax, SK_ScalarMax };
Cary Clark154beea2017-10-26 07:58:48 -0400453 SkDebugf("largest is finite: %s\n", largest.isFinite() ? "true" : "false");
454 SkDebugf("large width %g\n", largest.width());
455 SkRect widest = SkRect::MakeWH(largest.width(), largest.height());
456 SkDebugf("widest is finite: %s\n", widest.isFinite() ? "true" : "false");
457#StdOut
458largest is finite: true
459large width inf
Cary Clark7fc1d122017-10-09 14:07:42 -0400460widest is finite: false
461##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400462##
463
Cary Clark7fc1d122017-10-09 14:07:42 -0400464#SeeAlso SkScalarIsFinite SkScalarIsNaN
Cary Clarkbc5697d2017-10-04 14:31:33 -0400465
466##
467
468# ------------------------------------------------------------------------------
469
470#Method SkScalar x() const
471
Cary Clark7fc1d122017-10-09 14:07:42 -0400472Returns left edge of Rect, if sorted. Call isSorted to see if Rect is valid.
473Call sort() to reverse fLeft and fRight if needed.
474
475#Return fLeft ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400476
477#Example
Cary Clark154beea2017-10-26 07:58:48 -0400478 SkRect unsorted = { 15, 5, 10, 25 };
479 SkDebugf("unsorted.fLeft: %g unsorted.x(): %g\n", unsorted.fLeft, unsorted.x());
480 SkRect sorted = unsorted.makeSorted();
481 SkDebugf("sorted.fLeft: %g sorted.x(): %g\n", sorted.fLeft, sorted.x());
Cary Clark7fc1d122017-10-09 14:07:42 -0400482#StdOut
Cary Clark154beea2017-10-26 07:58:48 -0400483unsorted.fLeft: 15 unsorted.x(): 15
Cary Clark7fc1d122017-10-09 14:07:42 -0400484sorted.fLeft: 10 sorted.x(): 10
485##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400486##
487
Cary Clark7fc1d122017-10-09 14:07:42 -0400488#SeeAlso fLeft left() y() SkIRect::x()
Cary Clarkbc5697d2017-10-04 14:31:33 -0400489
490##
491
492# ------------------------------------------------------------------------------
493
494#Method SkScalar y() const
495
Cary Clark7fc1d122017-10-09 14:07:42 -0400496Returns top edge of Rect, if sorted. Call isEmpty to see if Rect may be invalid,
497and sort() to reverse fTop and fBottom if needed.
498
499#Return fTop ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400500
501#Example
Cary Clark154beea2017-10-26 07:58:48 -0400502 SkRect unsorted = { 15, 25, 10, 5 };
503 SkDebugf("unsorted.fTop: %g unsorted.y(): %g\n", unsorted.fTop, unsorted.y());
504 SkRect sorted = unsorted.makeSorted();
Cary Clark7fc1d122017-10-09 14:07:42 -0400505 SkDebugf("sorted.fTop: %g sorted.y(): %g\n", sorted.fTop, sorted.y());
506#StdOut
Cary Clark154beea2017-10-26 07:58:48 -0400507unsorted.fTop: 25 unsorted.y(): 25
Cary Clark7fc1d122017-10-09 14:07:42 -0400508sorted.fTop: 5 sorted.y(): 5
509##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400510##
511
Cary Clark7fc1d122017-10-09 14:07:42 -0400512#SeeAlso fTop top() x() SkIRect::y()
Cary Clarkbc5697d2017-10-04 14:31:33 -0400513
514##
515
516# ------------------------------------------------------------------------------
517
518#Method SkScalar left() const
519
Cary Clark7fc1d122017-10-09 14:07:42 -0400520Returns left edge of Rect, if sorted. Call isSorted to see if Rect is valid.
521Call sort() to reverse fLeft and fRight if needed.
522
523#Return fLeft ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400524
525#Example
Cary Clark154beea2017-10-26 07:58:48 -0400526 SkRect unsorted = { 15, 5, 10, 25 };
527 SkDebugf("unsorted.fLeft: %g unsorted.left(): %g\n", unsorted.fLeft, unsorted.left());
528 SkRect sorted = unsorted.makeSorted();
529 SkDebugf("sorted.fLeft: %g sorted.left(): %g\n", sorted.fLeft, sorted.left());
Cary Clark7fc1d122017-10-09 14:07:42 -0400530#StdOut
Cary Clark154beea2017-10-26 07:58:48 -0400531unsorted.fLeft: 15 unsorted.left(): 15
Cary Clark7fc1d122017-10-09 14:07:42 -0400532sorted.fLeft: 10 sorted.left(): 10
533##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400534##
535
Cary Clark7fc1d122017-10-09 14:07:42 -0400536#SeeAlso fLeft x() SkIRect::left()
Cary Clarkbc5697d2017-10-04 14:31:33 -0400537
538##
539
540# ------------------------------------------------------------------------------
541
542#Method SkScalar top() const
543
Cary Clark7fc1d122017-10-09 14:07:42 -0400544Returns top edge of Rect, if sorted. Call isEmpty to see if Rect may be invalid,
545and sort() to reverse fTop and fBottom if needed.
546
547#Return fTop ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400548
549#Example
Cary Clark154beea2017-10-26 07:58:48 -0400550 SkRect unsorted = { 15, 25, 10, 5 };
551 SkDebugf("unsorted.fTop: %g unsorted.top(): %g\n", unsorted.fTop, unsorted.top());
552 SkRect sorted = unsorted.makeSorted();
Cary Clark7fc1d122017-10-09 14:07:42 -0400553 SkDebugf("sorted.fTop: %g sorted.top(): %g\n", sorted.fTop, sorted.top());
554#StdOut
Cary Clark154beea2017-10-26 07:58:48 -0400555unsorted.fTop: 25 unsorted.top(): 25
Cary Clark7fc1d122017-10-09 14:07:42 -0400556sorted.fTop: 5 sorted.top(): 5
557##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400558##
559
Cary Clark7fc1d122017-10-09 14:07:42 -0400560#SeeAlso fTop y() SkIRect::top()
Cary Clarkbc5697d2017-10-04 14:31:33 -0400561
562##
563
564# ------------------------------------------------------------------------------
565
566#Method SkScalar right() const
567
Cary Clark7fc1d122017-10-09 14:07:42 -0400568Returns right edge of Rect, if sorted. Call isSorted to see if Rect is valid.
569Call sort() to reverse fLeft and fRight if needed.
570
571#Return fRight ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400572
573#Example
Cary Clark154beea2017-10-26 07:58:48 -0400574 SkRect unsorted = { 15, 25, 10, 5 };
575 SkDebugf("unsorted.fRight: %g unsorted.right(): %g\n", unsorted.fRight, unsorted.right());
576 SkRect sorted = unsorted.makeSorted();
577 SkDebugf("sorted.fRight: %g sorted.right(): %g\n", sorted.fRight, sorted.right());
Cary Clark7fc1d122017-10-09 14:07:42 -0400578#StdOut
Cary Clark154beea2017-10-26 07:58:48 -0400579unsorted.fRight: 10 unsorted.right(): 10
Cary Clark7fc1d122017-10-09 14:07:42 -0400580sorted.fRight: 15 sorted.right(): 15
581##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400582##
583
Cary Clark7fc1d122017-10-09 14:07:42 -0400584#SeeAlso fRight SkIRect::right()
Cary Clarkbc5697d2017-10-04 14:31:33 -0400585
586##
587
588# ------------------------------------------------------------------------------
589
590#Method SkScalar bottom() const
591
Cary Clark7fc1d122017-10-09 14:07:42 -0400592Returns bottom edge of Rect, if sorted. Call isEmpty to see if Rect may be invalid,
593and sort() to reverse fTop and fBottom if needed.
594
595#Return fBottom ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400596
597#Example
Cary Clark154beea2017-10-26 07:58:48 -0400598 SkRect unsorted = { 15, 25, 10, 5 };
599 SkDebugf("unsorted.fBottom: %g unsorted.bottom(): %g\n", unsorted.fBottom, unsorted.bottom());
600 SkRect sorted = unsorted.makeSorted();
601 SkDebugf("sorted.fBottom: %g sorted.bottom(): %g\n", sorted.fBottom, sorted.bottom());
Cary Clark7fc1d122017-10-09 14:07:42 -0400602#StdOut
Cary Clark154beea2017-10-26 07:58:48 -0400603unsorted.fBottom: 5 unsorted.bottom(): 5
Cary Clark7fc1d122017-10-09 14:07:42 -0400604sorted.fBottom: 25 sorted.bottom(): 25
605##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400606##
607
Cary Clark7fc1d122017-10-09 14:07:42 -0400608#SeeAlso fBottom SkIRect::bottom()
Cary Clarkbc5697d2017-10-04 14:31:33 -0400609
610##
611
612# ------------------------------------------------------------------------------
613
614#Method SkScalar width() const
615
Cary Clark7fc1d122017-10-09 14:07:42 -0400616Returns span on the x-axis. This does not check if Rect is sorted, or if
617result fits in 32-bit float; result may be negative or infinity.
618
619#Return fRight minus fLeft ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400620
621#Example
Cary Clark7fc1d122017-10-09 14:07:42 -0400622#Description
623Compare with SkIRect::width() example.
624##
Cary Clark154beea2017-10-26 07:58:48 -0400625 SkRect unsorted = { 15, 25, 10, 5 };
626 SkDebugf("unsorted width: %g\n", unsorted.width());
627 SkRect large = { -2147483647.f, 1, 2147483644.f, 2 };
628 SkDebugf("large width: %.0f\n", large.width());
Cary Clark7fc1d122017-10-09 14:07:42 -0400629#StdOut
Cary Clark154beea2017-10-26 07:58:48 -0400630unsorted width: -5
Cary Clark7fc1d122017-10-09 14:07:42 -0400631large width: 4294967296
632##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400633##
634
Cary Clark7fc1d122017-10-09 14:07:42 -0400635#SeeAlso height() SkIRect::width()
Cary Clarkbc5697d2017-10-04 14:31:33 -0400636
637##
638
639# ------------------------------------------------------------------------------
640
641#Method SkScalar height() const
642
Cary Clark7fc1d122017-10-09 14:07:42 -0400643Returns span on the y-axis. This does not check if IRect is sorted, or if
644result fits in 32-bit float; result may be negative or infinity.
645
646#Return fBottom minus fTop ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400647
648#Example
Cary Clark7fc1d122017-10-09 14:07:42 -0400649#Description
650Compare with SkIRect::height() example.
651##
Cary Clark154beea2017-10-26 07:58:48 -0400652 SkRect unsorted = { 15, 25, 10, 20 };
653 SkDebugf("unsorted height: %g\n", unsorted.height());
654 SkRect large = { 1, -2147483647.f, 2, 2147483644.f };
655 SkDebugf("large height: %.0f\n", large.height());
Cary Clark7fc1d122017-10-09 14:07:42 -0400656#StdOut
Cary Clark154beea2017-10-26 07:58:48 -0400657unsorted height: -5
Cary Clark7fc1d122017-10-09 14:07:42 -0400658large height: 4294967296
659##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400660##
661
Cary Clark7fc1d122017-10-09 14:07:42 -0400662#SeeAlso width() SkIRect::height()
Cary Clarkbc5697d2017-10-04 14:31:33 -0400663
664##
665
666# ------------------------------------------------------------------------------
667
668#Method SkScalar centerX() const
669
Cary Clark7fc1d122017-10-09 14:07:42 -0400670Returns average of left edge and right edge. Result does not change if Rect
671is sorted. Result may overflow to infinity if Rect is far from the origin.
672
673#Return midpoint in x ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400674
675#Example
Cary Clark154beea2017-10-26 07:58:48 -0400676 SkRect tests[] = {{20, 30, 41, 51}, {-20, -30, -41, -51}};
677 for (auto rect : tests) {
678 SkDebugf("left: %3g right: %3g centerX: %3g\n", rect.left(), rect.right(), rect.centerX());
679 rect.sort();
680 SkDebugf("left: %3g right: %3g centerX: %3g\n", rect.left(), rect.right(), rect.centerX());
681 }
Cary Clark7fc1d122017-10-09 14:07:42 -0400682#StdOut
Cary Clark154beea2017-10-26 07:58:48 -0400683left: 20 right: 41 centerX: 30.5
684left: 20 right: 41 centerX: 30.5
685left: -20 right: -41 centerX: -30.5
Cary Clark7fc1d122017-10-09 14:07:42 -0400686left: -41 right: -20 centerX: -30.5
687##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400688##
689
Cary Clark7fc1d122017-10-09 14:07:42 -0400690#SeeAlso centerY SkIRect::centerX
Cary Clarkbc5697d2017-10-04 14:31:33 -0400691
692##
693
694# ------------------------------------------------------------------------------
695
696#Method SkScalar centerY() const
697
Cary Clark7fc1d122017-10-09 14:07:42 -0400698Returns average of top edge and bottom edge. Result does not change if Rect
699is sorted. Result may overflow to infinity if Rect is far from the origin.
700
701#Return midpoint in y ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400702
703#Example
Cary Clark154beea2017-10-26 07:58:48 -0400704 SkRect rect = { 2e+38, 2e+38, 3e+38, 3e+38 };
705 SkDebugf("left: %g right: %g centerX: %g ", rect.left(), rect.right(), rect.centerX());
706 SkDebugf("safe mid x: %g\n", rect.left() / 2 + rect.right() / 2);
Cary Clark7fc1d122017-10-09 14:07:42 -0400707#StdOut
708left: 2e+38 right: 3e+38 centerX: inf safe mid x: 2.5e+38
709##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400710##
711
Cary Clark7fc1d122017-10-09 14:07:42 -0400712#SeeAlso centerX SkIRect::centerY
Cary Clarkbc5697d2017-10-04 14:31:33 -0400713
714##
715
716# ------------------------------------------------------------------------------
717
Cary Clark884dd7d2017-10-11 10:37:52 -0400718#Method bool operator==(const SkRect& a, const SkRect& b)
Cary Clarkbc5697d2017-10-04 14:31:33 -0400719
Cary Clark7fc1d122017-10-09 14:07:42 -0400720Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are
721equal to the corresponding members in b.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400722
Cary Clark7fc1d122017-10-09 14:07:42 -0400723a and b are not equal if either contain NaN. a and b are equal if members
724contain zeroes width different signs.
725
726#Param a Rect to compare ##
727#Param b Rect to compare ##
728
729#Return true if members are equal ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400730
731#Example
Cary Clark154beea2017-10-26 07:58:48 -0400732 auto debugster = [](const SkRect& test) -> void {
733 SkRect negZero = {-0.0f, -0.0f, 2, 2};
734 SkDebugf("{%g, %g, %g, %g} %c= {%g, %g, %g, %g} %s numerically equal\n",
735 test.fLeft, test.fTop, test.fRight, test.fBottom,
736 negZero.fLeft, negZero.fTop, negZero.fRight, negZero.fBottom,
737 test == negZero ? '=' : '!',
738 test.fLeft == negZero.fLeft && test.fTop == negZero.fTop &&
739 test.fRight == negZero.fRight && test.fBottom == negZero.fBottom ?
740 "and are" : "yet are not");
741 };
742 SkRect tests[] = {{0, 0, 2, 2}, {-0, -0, 2, 2}, {0.0f, 0.0f, 2, 2}};
743 SkDebugf("tests are %s" "equal\n", tests[0] == tests[1] && tests[1] == tests[2] ? "" : "not ");
744 for (auto rect : tests) {
745 debugster(rect);
Cary Clark7fc1d122017-10-09 14:07:42 -0400746 }
Cary Clark154beea2017-10-26 07:58:48 -0400747#StdOut
748tests are equal
749{0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal
750{0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal
Cary Clark7fc1d122017-10-09 14:07:42 -0400751{0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal
752##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400753##
754
Cary Clark7fc1d122017-10-09 14:07:42 -0400755#SeeAlso operator!=(const SkRect& a, const SkRect& b)
Cary Clarkbc5697d2017-10-04 14:31:33 -0400756
757##
758
759# ------------------------------------------------------------------------------
760
Cary Clark884dd7d2017-10-11 10:37:52 -0400761#Method bool operator!=(const SkRect& a, const SkRect& b)
Cary Clarkbc5697d2017-10-04 14:31:33 -0400762
Cary Clark7fc1d122017-10-09 14:07:42 -0400763Returns true if any in a: fLeft, fTop, fRight, and fBottom; does not
764equal the corresponding members in b.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400765
Cary Clark7fc1d122017-10-09 14:07:42 -0400766a and b are not equal if either contain NaN. a and b are equal if members
767contain zeroes width different signs.
768
769#Param a Rect to compare ##
770#Param b Rect to compare ##
771
772#Return true if members are not equal ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400773
774#Example
Cary Clark154beea2017-10-26 07:58:48 -0400775 SkRect test = {0, 0, 2, SK_ScalarNaN};
776 SkDebugf("test with NaN is %s" "equal to itself\n", test == test ? "" : "not ");
777#StdOut
Cary Clark7fc1d122017-10-09 14:07:42 -0400778test with NaN is not equal to itself
779##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400780##
781
Cary Clark7fc1d122017-10-09 14:07:42 -0400782#SeeAlso operator==(const SkRect& a, const SkRect& b)
Cary Clarkbc5697d2017-10-04 14:31:33 -0400783
784##
785
786# ------------------------------------------------------------------------------
787
788#Method void toQuad(SkPoint quad[4]) const
789
Cary Clark7fc1d122017-10-09 14:07:42 -0400790Returns four points in quad that enclose Rect ordered as: top-left, top-right,
791bottom-right, bottom-left.
792
793#Private
Cary Clarkbc5697d2017-10-04 14:31:33 -0400794Consider adding param to control whether quad is CW or CCW.
795##
796
Cary Clark7fc1d122017-10-09 14:07:42 -0400797#Param quad storage for corners of Rect ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400798
799#Example
Cary Clark154beea2017-10-26 07:58:48 -0400800 SkRect rect = {1, 2, 3, 4};
801 SkPoint corners[4];
802 rect.toQuad(corners);
803 SkDebugf("rect: {%g, %g, %g, %g}\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
804 SkDebugf("corners:");
805 for (auto corner : corners) {
806 SkDebugf(" {%g, %g}", corner.fX, corner.fY);
807 }
808 SkDebugf("\n");
809#StdOut
810rect: {1, 2, 3, 4}
Cary Clark7fc1d122017-10-09 14:07:42 -0400811corners: {1, 2} {3, 2} {3, 4} {1, 4}
812##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400813##
814
Cary Clark7fc1d122017-10-09 14:07:42 -0400815#SeeAlso SkPath::addRect
Cary Clarkbc5697d2017-10-04 14:31:33 -0400816
817##
818
819# ------------------------------------------------------------------------------
820
821#Method void setEmpty()
822
Cary Clark7fc1d122017-10-09 14:07:42 -0400823Sets Rect to (0, 0, 0, 0).
824
825Many other rectangles are empty; if left is equal to or greater than right,
826or if top is equal to or greater than bottom. Setting all members to zero
827is a convenience, but does not designate a special empty rectangle.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400828
829#Example
Cary Clark154beea2017-10-26 07:58:48 -0400830 SkRect rect = {3, 4, 1, 2};
831 for (int i = 0; i < 2; ++i) {
832 SkDebugf("rect: {%g, %g, %g, %g} is %s" "empty\n", rect.fLeft, rect.fTop,
833 rect.fRight, rect.fBottom, rect.isEmpty() ? "" : "not ");
834 rect.setEmpty();
835 }
836#StdOut
837rect: {3, 4, 1, 2} is empty
838rect: {0, 0, 0, 0} is empty
839##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400840##
841
Cary Clark7fc1d122017-10-09 14:07:42 -0400842#SeeAlso MakeEmpty SkIRect::setEmpty
Cary Clarkbc5697d2017-10-04 14:31:33 -0400843
844##
845
846# ------------------------------------------------------------------------------
847
848#Method void set(const SkIRect& src)
849
Cary Clark7fc1d122017-10-09 14:07:42 -0400850Sets Rect to src, promoting src members from integer to Scalar.
851Very large values in src may lose precision.
852
853#Param src integer Rect ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400854
855#Example
Cary Clark154beea2017-10-26 07:58:48 -0400856 SkIRect i_rect = {3, 4, 1, 2};
857 SkDebugf("i_rect: {%d, %d, %d, %d}\n", i_rect.fLeft, i_rect.fTop, i_rect.fRight, i_rect.fBottom);
858 SkRect f_rect;
859 f_rect.set(i_rect);
860 SkDebugf("f_rect: {%g, %g, %g, %g}\n", f_rect.fLeft, f_rect.fTop, f_rect.fRight, f_rect.fBottom);
861#StdOut
862i_rect: {3, 4, 1, 2}
863f_rect: {3, 4, 1, 2}
864##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400865##
866
Cary Clark7fc1d122017-10-09 14:07:42 -0400867#SeeAlso setLTRB SkIntToScalar
Cary Clarkbc5697d2017-10-04 14:31:33 -0400868
869##
870
871# ------------------------------------------------------------------------------
872
873#Method void set(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
874
Cary Clark7fc1d122017-10-09 14:07:42 -0400875Sets Rect to (left, top, right, bottom).
876left and right are not sorted; left is not necessarily less than right.
877top and bottom are not sorted; top is not necessarily less than bottom.
878
879#Param left stored in fLeft ##
880#Param top stored in fTop ##
881#Param right stored in fRight ##
882#Param bottom stored in fBottom ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400883
884#Example
Cary Clark154beea2017-10-26 07:58:48 -0400885 SkRect rect1 = {3, 4, 1, 2};
886 SkDebugf("rect1: {%g, %g, %g, %g}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
887 SkRect rect2;
888 rect2.set(3, 4, 1, 2);
889 SkDebugf("rect2: {%g, %g, %g, %g}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
890#StdOut
891rect1: {3, 4, 1, 2}
892rect2: {3, 4, 1, 2}
893##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400894##
895
Cary Clark7fc1d122017-10-09 14:07:42 -0400896#SeeAlso setLTRB setXYWH SkIRect::set
Cary Clarkbc5697d2017-10-04 14:31:33 -0400897
898##
899
900# ------------------------------------------------------------------------------
901
902#Method void setLTRB(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
903
Cary Clark7fc1d122017-10-09 14:07:42 -0400904Sets Rect to (left, top, right, bottom).
905left and right are not sorted; left is not necessarily less than right.
906top and bottom are not sorted; top is not necessarily less than bottom.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400907
Cary Clark7fc1d122017-10-09 14:07:42 -0400908#Param left stored in fLeft ##
909#Param top stored in fTop ##
910#Param right stored in fRight ##
911#Param bottom stored in fBottom ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400912
913#Example
Cary Clark154beea2017-10-26 07:58:48 -0400914 SkRect rect1 = {3, 4, 1, 2};
915 SkDebugf("rect1: {%g, %g, %g, %g}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
916 SkRect rect2;
917 rect2.setLTRB(3, 4, 1, 2);
918 SkDebugf("rect2: {%g, %g, %g, %g}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
919#StdOut
920rect1: {3, 4, 1, 2}
921rect2: {3, 4, 1, 2}
922##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400923##
924
Cary Clark7fc1d122017-10-09 14:07:42 -0400925#SeeAlso set setXYWH SkIRect::set
Cary Clarkbc5697d2017-10-04 14:31:33 -0400926
927##
928
929# ------------------------------------------------------------------------------
930
931#Method void iset(int left, int top, int right, int bottom)
932
Cary Clark7fc1d122017-10-09 14:07:42 -0400933Sets Rect to (left, top, right, bottom).
934All parameters are promoted from integer to Scalar.
935left and right are not sorted; left is not necessarily less than right.
936top and bottom are not sorted; top is not necessarily less than bottom.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400937
Cary Clark7fc1d122017-10-09 14:07:42 -0400938#Param left promoted to SkScalar and stored in fLeft ##
939#Param top promoted to SkScalar and stored in fTop ##
940#Param right promoted to SkScalar and stored in fRight ##
941#Param bottom promoted to SkScalar and stored in fBottom ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400942
943#Example
Cary Clark154beea2017-10-26 07:58:48 -0400944 SkRect rect1 = {3, 4, 1, 2};
945 SkDebugf("rect1: {%g, %g, %g, %g}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
946 SkRect rect2;
947 rect2.iset(3, 4, 1, 2);
948 SkDebugf("rect2: {%g, %g, %g, %g}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
949#StdOut
950rect1: {3, 4, 1, 2}
951rect2: {3, 4, 1, 2}
952##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400953##
954
Cary Clark7fc1d122017-10-09 14:07:42 -0400955#SeeAlso set setLTRB SkIRect::set SkIntToScalar
Cary Clarkbc5697d2017-10-04 14:31:33 -0400956
957##
958
959# ------------------------------------------------------------------------------
960
961#Method void isetWH(int width, int height)
962
Cary Clark7fc1d122017-10-09 14:07:42 -0400963Sets Rect to (0, 0, width, height).
964width and height may be zero or negative. width and height are promoted from
965integer to SkScalar, large values may lose precision.
Cary Clarkbc5697d2017-10-04 14:31:33 -0400966
Cary Clark7fc1d122017-10-09 14:07:42 -0400967#Param width promoted to SkScalar and stored in fRight ##
968#Param height promoted to SkScalar and stored in fBottom ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400969
970#Example
Cary Clark154beea2017-10-26 07:58:48 -0400971 SkRect rect1 = {0, 0, 1, 2};
972 SkDebugf("rect1: {%g, %g, %g, %g}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom);
973 SkRect rect2;
974 rect2.isetWH(1, 2);
Cary Clark7fc1d122017-10-09 14:07:42 -0400975 SkDebugf("rect2: {%g, %g, %g, %g}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom);
Cary Clark154beea2017-10-26 07:58:48 -0400976#StdOut
977rect1: {0, 0, 1, 2}
978rect2: {0, 0, 1, 2}
979##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400980##
981
Cary Clark7fc1d122017-10-09 14:07:42 -0400982#SeeAlso MakeWH MakeXYWH iset() SkIRect:MakeWH
Cary Clarkbc5697d2017-10-04 14:31:33 -0400983
984##
985
986# ------------------------------------------------------------------------------
987
988#Method void set(const SkPoint pts[], int count)
989
Cary Clark7fc1d122017-10-09 14:07:42 -0400990Sets to bounds of Point array with count entries. If count is zero or smaller,
991or if Point array contains an infinity or NaN, sets Rect to (0, 0, 0, 0).
Cary Clarkbc5697d2017-10-04 14:31:33 -0400992
Cary Clark7fc1d122017-10-09 14:07:42 -0400993Result is either empty or sorted: fLeft is less than or equal to fRight, and
994fTop is less than or equal to fBottom.
995
996#Param pts Point array ##
997#Param count entries in array ##
Cary Clarkbc5697d2017-10-04 14:31:33 -0400998
999#Example
Cary Clark154beea2017-10-26 07:58:48 -04001000 SkPoint points[] = {{3, 4}, {1, 2}, {5, 6}, {SK_ScalarNaN, 8}};
1001 for (int count = 0; count <= (int) SK_ARRAY_COUNT(points); ++count) {
1002 SkRect rect;
1003 rect.set(points, count);
1004 if (count > 0) {
1005 SkDebugf("added: %3g, %g ", points[count - 1].fX, points[count - 1].fY);
1006 } else {
1007 SkDebugf("%14s", " ");
1008 }
1009 SkDebugf("count: %d rect: %g, %g, %g, %g\n", count,
1010 rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1011 }
1012#StdOut
1013 count: 0 rect: 0, 0, 0, 0
1014added: 3, 4 count: 1 rect: 3, 4, 3, 4
1015added: 1, 2 count: 2 rect: 1, 2, 3, 4
1016added: 5, 6 count: 3 rect: 1, 2, 5, 6
1017added: nan, 8 count: 4 rect: 0, 0, 0, 0
1018##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001019##
1020
Cary Clark7fc1d122017-10-09 14:07:42 -04001021#SeeAlso setBounds setBoundsCheck SkPath::addPoly
Cary Clarkbc5697d2017-10-04 14:31:33 -04001022
1023##
1024
1025# ------------------------------------------------------------------------------
1026
1027#Method void setBounds(const SkPoint pts[], int count)
1028
Cary Clark7fc1d122017-10-09 14:07:42 -04001029Sets to bounds of Point array with count entries. If count is zero or smaller,
1030or if Point array contains an infinity or NaN, sets to (0, 0, 0, 0).
Cary Clarkbc5697d2017-10-04 14:31:33 -04001031
Cary Clark7fc1d122017-10-09 14:07:42 -04001032Result is either empty or sorted: fLeft is less than or equal to fRight, and
1033fTop is less than or equal to fBottom.
1034
1035#Param pts Point array ##
1036#Param count entries in array ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001037
1038#Example
Cary Clark154beea2017-10-26 07:58:48 -04001039 SkPoint points[] = {{3, 4}, {1, 2}, {5, 6}, {SK_ScalarNaN, 8}};
1040 for (int count = 0; count <= (int) SK_ARRAY_COUNT(points); ++count) {
1041 SkRect rect;
1042 rect.setBounds(points, count);
1043 if (count > 0) {
1044 SkDebugf("added: %3g, %g ", points[count - 1].fX, points[count - 1].fY);
1045 } else {
1046 SkDebugf("%14s", " ");
1047 }
1048 SkDebugf("count: %d rect: %g, %g, %g, %g\n", count,
1049 rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1050 }
1051#StdOut
1052 count: 0 rect: 0, 0, 0, 0
1053added: 3, 4 count: 1 rect: 3, 4, 3, 4
1054added: 1, 2 count: 2 rect: 1, 2, 3, 4
1055added: 5, 6 count: 3 rect: 1, 2, 5, 6
1056added: nan, 8 count: 4 rect: 0, 0, 0, 0
1057##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001058##
1059
Cary Clark7fc1d122017-10-09 14:07:42 -04001060#SeeAlso set setBoundsCheck SkPath::addPoly
Cary Clarkbc5697d2017-10-04 14:31:33 -04001061
1062##
1063
1064# ------------------------------------------------------------------------------
1065
1066#Method bool setBoundsCheck(const SkPoint pts[], int count)
1067
Cary Clark7fc1d122017-10-09 14:07:42 -04001068Sets to bounds of Point array with count entries. Returns false if count is
1069zero or smaller, or if Point array contains an infinity or NaN; in these cases
1070sets Rect to (0, 0, 0, 0).
Cary Clarkbc5697d2017-10-04 14:31:33 -04001071
Cary Clark7fc1d122017-10-09 14:07:42 -04001072Result is either empty or sorted: fLeft is less than or equal to fRight, and
1073fTop is less than or equal to fBottom.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001074
Cary Clark7fc1d122017-10-09 14:07:42 -04001075#Param pts Point array ##
1076#Param count entries in array ##
1077
1078#Return true if all Point values are finite ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001079
1080#Example
Cary Clark154beea2017-10-26 07:58:48 -04001081 SkPoint points[] = {{3, 4}, {1, 2}, {5, 6}, {SK_ScalarNaN, 8}};
1082 for (int count = 0; count <= (int) SK_ARRAY_COUNT(points); ++count) {
1083 SkRect rect;
1084 bool success = rect.setBoundsCheck(points, count);
1085 if (count > 0) {
1086 SkDebugf("added: %3g, %g ", points[count - 1].fX, points[count - 1].fY);
1087 } else {
1088 SkDebugf("%14s", " ");
1089 }
1090 SkDebugf("count: %d rect: %g, %g, %g, %g success: %s\n", count,
1091 rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, success ? "true" : "false");
1092 }
1093#StdOut
1094 count: 0 rect: 0, 0, 0, 0 success: true
1095added: 3, 4 count: 1 rect: 3, 4, 3, 4 success: true
1096added: 1, 2 count: 2 rect: 1, 2, 3, 4 success: true
1097added: 5, 6 count: 3 rect: 1, 2, 5, 6 success: true
1098added: nan, 8 count: 4 rect: 0, 0, 0, 0 success: false
1099##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001100##
1101
Cary Clark7fc1d122017-10-09 14:07:42 -04001102#SeeAlso set setBounds SkPath::addPoly
Cary Clarkbc5697d2017-10-04 14:31:33 -04001103
1104##
1105
1106# ------------------------------------------------------------------------------
1107
1108#Method void set(const SkPoint& p0, const SkPoint& p1)
1109
Cary Clark7fc1d122017-10-09 14:07:42 -04001110Sets bounds to the smallest Rect enclosing Points p0 and p1. The result is
1111sorted and may be empty. Does not check to see if values are finite.
1112
1113#Param p0 corner to include ##
1114#Param p1 corner to include ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001115
1116#Example
Cary Clark7fc1d122017-10-09 14:07:42 -04001117#Description
1118p0 and p1 may be swapped and have the same effect unless one contains NaN.
1119##
Cary Clark154beea2017-10-26 07:58:48 -04001120 SkPoint point1 = {SK_ScalarNaN, 8};
1121 SkPoint point2 = {3, 4};
1122 SkRect rect;
1123 rect.set(point1, point2);
1124 SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1125 rect.set(point2, point1);
1126 SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
Cary Clarkbc5697d2017-10-04 14:31:33 -04001127##
1128
Cary Clark7fc1d122017-10-09 14:07:42 -04001129#SeeAlso setBounds setBoundsCheck
Cary Clarkbc5697d2017-10-04 14:31:33 -04001130
1131##
1132
1133# ------------------------------------------------------------------------------
1134
1135#Method void setXYWH(SkScalar x, SkScalar y, SkScalar width, SkScalar height)
1136
Cary Clark7fc1d122017-10-09 14:07:42 -04001137Sets Rect to
1138#Formula
1139(x, y, x + width, y + height)
1140##
1141. Does not validate input;
1142width or height may be negative.
1143
1144#Param x stored in fLeft ##
1145#Param y stored in fTop ##
1146#Param width added to x and stored in fRight ##
1147#Param height added to y and stored in fBottom ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001148
1149#Example
Cary Clark154beea2017-10-26 07:58:48 -04001150 SkRect rect;
1151 rect.setXYWH(5, 35, -15, 25);
1152 SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
1153 rect.bottom(), rect.isEmpty() ? "true" : "false");
1154 rect.sort();
1155 SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
1156 rect.bottom(), rect.isEmpty() ? "true" : "false");
Cary Clark7fc1d122017-10-09 14:07:42 -04001157#StdOut
Cary Clark154beea2017-10-26 07:58:48 -04001158rect: 5, 35, -10, 60 isEmpty: true
Cary Clark7fc1d122017-10-09 14:07:42 -04001159rect: -10, 35, 5, 60 isEmpty: false
1160##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001161##
1162
Cary Clark7fc1d122017-10-09 14:07:42 -04001163#SeeAlso MakeXYWH setLTRB set SkIRect::setXYWH
Cary Clarkbc5697d2017-10-04 14:31:33 -04001164
1165##
1166
1167# ------------------------------------------------------------------------------
1168
1169#Method void setWH(SkScalar width, SkScalar height)
1170
Cary Clark7fc1d122017-10-09 14:07:42 -04001171Sets Rect to (0, 0, width, height). Does not validate input;
1172width or height may be negative.
1173
1174#Param width stored in fRight ##
1175#Param height stored in fBottom ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001176
1177#Example
Cary Clark154beea2017-10-26 07:58:48 -04001178 SkRect rect;
1179 rect.setWH(-15, 25);
1180 SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
1181 rect.bottom(), rect.isEmpty() ? "true" : "false");
1182 rect.sort();
1183 SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
1184 rect.bottom(), rect.isEmpty() ? "true" : "false");
Cary Clark7fc1d122017-10-09 14:07:42 -04001185#StdOut
Cary Clark154beea2017-10-26 07:58:48 -04001186rect: 0, 0, -15, 25 isEmpty: true
Cary Clark7fc1d122017-10-09 14:07:42 -04001187rect: -15, 0, 0, 25 isEmpty: false
1188##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001189##
1190
Cary Clark7fc1d122017-10-09 14:07:42 -04001191#SeeAlso MakeWH setXYWH isetWH
Cary Clarkbc5697d2017-10-04 14:31:33 -04001192
1193##
1194
1195# ------------------------------------------------------------------------------
1196
Cary Clarkbc5697d2017-10-04 14:31:33 -04001197#Method SkRect makeOffset(SkScalar dx, SkScalar dy) const
1198
Cary Clark7fc1d122017-10-09 14:07:42 -04001199Returns Rect offset by (dx, dy).
Cary Clarkbc5697d2017-10-04 14:31:33 -04001200
Cary Clark7fc1d122017-10-09 14:07:42 -04001201If dx is negative, Rect returned is moved to the left.
1202If dx is positive, Rect returned is moved to the right.
1203If dy is negative, Rect returned is moved upward.
1204If dy is positive, Rect returned is moved downward.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001205
Cary Clark7fc1d122017-10-09 14:07:42 -04001206#Param dx added to fLeft and fRight ##
1207#Param dy added to fTop and fBottom ##
1208
1209#Return Rect offset in x or y, with original width and height ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001210
1211#Example
Cary Clark154beea2017-10-26 07:58:48 -04001212 SkRect rect = { 10, 50, 20, 60 };
1213 SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
1214 rect.bottom(), rect.isEmpty() ? "true" : "false");
1215 rect = rect.makeOffset(15, 32);
1216 SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
1217 rect.bottom(), rect.isEmpty() ? "true" : "false");
1218#StdOut
1219rect: 10, 50, 20, 60 isEmpty: false
1220rect: 25, 82, 35, 92 isEmpty: false
1221##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001222##
1223
Cary Clark7fc1d122017-10-09 14:07:42 -04001224#SeeAlso offset() makeInset makeOutset SkIRect::makeOffset
Cary Clarkbc5697d2017-10-04 14:31:33 -04001225
1226##
1227
1228# ------------------------------------------------------------------------------
1229
1230#Method SkRect makeInset(SkScalar dx, SkScalar dy) const
1231
Cary Clark7fc1d122017-10-09 14:07:42 -04001232Returns Rect, inset by (dx, dy).
Cary Clarkbc5697d2017-10-04 14:31:33 -04001233
Cary Clark7fc1d122017-10-09 14:07:42 -04001234If dx is negative, Rect returned is wider.
1235If dx is positive, Rect returned is narrower.
1236If dy is negative, Rect returned is taller.
1237If dy is positive, Rect returned is shorter.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001238
Cary Clark7fc1d122017-10-09 14:07:42 -04001239#Param dx added to fLeft and subtracted from fRight ##
1240#Param dy added to fTop and subtracted from fBottom ##
1241
1242#Return Rect inset symmetrically left and right, top and bottom ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001243
1244#Example
Cary Clark154beea2017-10-26 07:58:48 -04001245 SkRect rect = { 10, 50, 20, 60 };
1246 SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
1247 rect.bottom(), rect.isEmpty() ? "true" : "false");
1248 rect = rect.makeInset(15, 32);
1249 SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
1250 rect.bottom(), rect.isEmpty() ? "true" : "false");
1251#StdOut
1252rect: 10, 50, 20, 60 isEmpty: false
1253rect: 25, 82, 5, 28 isEmpty: true
1254##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001255##
1256
Cary Clark7fc1d122017-10-09 14:07:42 -04001257#SeeAlso inset() makeOffset makeOutset SkIRect::makeInset
Cary Clarkbc5697d2017-10-04 14:31:33 -04001258
1259##
1260
1261# ------------------------------------------------------------------------------
1262
1263#Method SkRect makeOutset(SkScalar dx, SkScalar dy) const
1264
Cary Clark7fc1d122017-10-09 14:07:42 -04001265Returns Rect, outset by (dx, dy).
Cary Clarkbc5697d2017-10-04 14:31:33 -04001266
Cary Clark7fc1d122017-10-09 14:07:42 -04001267If dx is negative, Rect returned is narrower.
1268If dx is positive, Rect returned is wider.
1269If dy is negative, Rect returned is shorter.
1270If dy is positive, Rect returned is taller.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001271
Cary Clark7fc1d122017-10-09 14:07:42 -04001272#Param dx subtracted to fLeft and added from fRight ##
1273#Param dy subtracted to fTop and added from fBottom ##
1274
1275#Return Rect outset symmetrically left and right, top and bottom ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001276
1277#Example
Cary Clark154beea2017-10-26 07:58:48 -04001278 SkRect rect = { 10, 50, 20, 60 };
1279 SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
1280 rect.bottom(), rect.isEmpty() ? "true" : "false");
1281 rect = rect.makeOutset(15, 32);
1282 SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
1283 rect.bottom(), rect.isEmpty() ? "true" : "false");
1284#StdOut
1285rect: 10, 50, 20, 60 isEmpty: false
1286rect: -5, 18, 35, 92 isEmpty: false
1287##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001288##
1289
Cary Clark7fc1d122017-10-09 14:07:42 -04001290#SeeAlso outset() makeOffset makeInset SkIRect::makeOutset
Cary Clarkbc5697d2017-10-04 14:31:33 -04001291
1292##
1293
1294# ------------------------------------------------------------------------------
1295
1296#Method void offset(SkScalar dx, SkScalar dy)
1297
Cary Clark7fc1d122017-10-09 14:07:42 -04001298Offsets Rect by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001299
Cary Clark7fc1d122017-10-09 14:07:42 -04001300If dx is negative, moves Rect to the left.
1301If dx is positive, moves Rect to the right.
1302If dy is negative, moves Rect upward.
1303If dy is positive, moves Rect downward.
1304
1305#Param dx offset added to fLeft and fRight ##
1306#Param dy offset added to fTop and fBottom ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001307
1308#Example
Cary Clark154beea2017-10-26 07:58:48 -04001309 SkRect rect = { 10, 14, 50, 73 };
1310 rect.offset(5, 13);
1311 SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1312#StdOut
1313rect: 15, 27, 55, 86
1314##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001315##
1316
Cary Clark7fc1d122017-10-09 14:07:42 -04001317#SeeAlso offsetTo makeOffset SkIRect::offset
Cary Clarkbc5697d2017-10-04 14:31:33 -04001318
1319##
1320
1321# ------------------------------------------------------------------------------
1322
1323#Method void offset(const SkPoint& delta)
1324
Cary Clark7fc1d122017-10-09 14:07:42 -04001325Offsets Rect by adding delta.fX to fLeft, fRight; and by adding delta.fY to
1326fTop, fBottom.
1327
1328If delta.fX is negative, moves Rect to the left.
1329If delta.fX is positive, moves Rect to the right.
1330If delta.fY is negative, moves Rect upward.
1331If delta.fY is positive, moves Rect downward.
1332
1333#Param delta added to Rect ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001334
1335#Example
Cary Clark154beea2017-10-26 07:58:48 -04001336 SkRect rect = { 10, 14, 50, 73 };
1337 rect.offset({5, 13});
1338 SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1339#StdOut
1340rect: 15, 27, 55, 86
1341##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001342##
1343
Cary Clark7fc1d122017-10-09 14:07:42 -04001344#SeeAlso offsetTo makeOffset SkIRect::offset
Cary Clarkbc5697d2017-10-04 14:31:33 -04001345
1346##
1347
1348# ------------------------------------------------------------------------------
1349
1350#Method void offsetTo(SkScalar newX, SkScalar newY)
1351
Cary Clark7fc1d122017-10-09 14:07:42 -04001352Offsets Rect so that fLeft equals newX, and fTop equals newY. width and height
1353are unchanged.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001354
Cary Clark7fc1d122017-10-09 14:07:42 -04001355#Param newX stored in fLeft, preserving width() ##
1356#Param newY stored in fTop, preserving height() ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001357
1358#Example
Cary Clark154beea2017-10-26 07:58:48 -04001359 SkRect rect = { 10, 14, 50, 73 };
1360 rect.offsetTo(15, 27);
1361 SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1362#StdOut
1363rect: 15, 27, 55, 86
1364##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001365##
1366
Cary Clark7fc1d122017-10-09 14:07:42 -04001367#SeeAlso offset makeOffset setXYWH SkIRect::offsetTo
Cary Clarkbc5697d2017-10-04 14:31:33 -04001368
1369##
1370
1371# ------------------------------------------------------------------------------
1372
1373#Method void inset(SkScalar dx, SkScalar dy)
1374
Cary Clark7fc1d122017-10-09 14:07:42 -04001375Insets Rect by (dx, dy).
Cary Clarkbc5697d2017-10-04 14:31:33 -04001376
Cary Clark7fc1d122017-10-09 14:07:42 -04001377If dx is positive, makes Rect narrower.
1378If dx is negative, makes Rect wider.
1379If dy is positive, makes Rect shorter.
1380If dy is negative, makes Rect taller.
1381
1382#Param dx added to fLeft and subtracted from fRight ##
1383#Param dy added to fTop and subtracted from fBottom ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001384
1385#Example
Cary Clark154beea2017-10-26 07:58:48 -04001386 SkRect rect = { 10, 14, 50, 73 };
1387 rect.inset(5, 13);
1388 SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1389#StdOut
1390rect: 15, 27, 45, 60
1391##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001392##
1393
Cary Clark7fc1d122017-10-09 14:07:42 -04001394#SeeAlso outset makeInset SkIRect::inset
Cary Clarkbc5697d2017-10-04 14:31:33 -04001395
1396##
1397
1398# ------------------------------------------------------------------------------
1399
1400#Method void outset(SkScalar dx, SkScalar dy)
1401
Cary Clark7fc1d122017-10-09 14:07:42 -04001402Outsets Rect by (dx, dy).
Cary Clarkbc5697d2017-10-04 14:31:33 -04001403
Cary Clark7fc1d122017-10-09 14:07:42 -04001404If dx is positive, makes Rect wider.
1405If dx is negative, makes Rect narrower.
1406If dy is positive, makes Rect taller.
1407If dy is negative, makes Rect shorter.
1408
1409#Param dx subtracted to fLeft and added from fRight ##
1410#Param dy subtracted to fTop and added from fBottom ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001411
1412#Example
Cary Clark154beea2017-10-26 07:58:48 -04001413 SkRect rect = { 10, 14, 50, 73 };
1414 rect.outset(5, 13);
1415 SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1416#StdOut
1417rect: 5, 1, 55, 86
1418##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001419##
1420
Cary Clark7fc1d122017-10-09 14:07:42 -04001421#SeeAlso inset makeOutset SkIRect::outset
Cary Clarkbc5697d2017-10-04 14:31:33 -04001422
1423##
1424
Cary Clark7fc1d122017-10-09 14:07:42 -04001425#Topic Intersection
1426
1427Rects intersect when they enclose a common area. To intersect, each of the pair
1428must describe area; fLeft is less than fRight, and fTop is less than fBottom;
Cary Clark154beea2017-10-26 07:58:48 -04001429empty() returns false. The intersection of Rect pair can be described by:
1430
Cary Clark7fc1d122017-10-09 14:07:42 -04001431#Formula
1432(max(a.fLeft, b.fLeft), max(a.fTop, b.fTop),
1433 min(a.fRight, b.fRight), min(a.fBottom, b.fBottom))
1434##
Cary Clark154beea2017-10-26 07:58:48 -04001435.
1436
Cary Clark7fc1d122017-10-09 14:07:42 -04001437The intersection is only meaningful if the resulting Rect is not empty and
1438describes an area: fLeft is less than fRight, and fTop is less than fBottom.
1439
Cary Clarkbc5697d2017-10-04 14:31:33 -04001440# ------------------------------------------------------------------------------
1441
1442#Method bool intersect(const SkRect& r)
1443
Cary Clark7fc1d122017-10-09 14:07:42 -04001444Returns true if Rect intersects r, and sets Rect to intersection.
1445Returns false if Rect does not intersect r, and leaves Rect unchanged.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001446
Cary Clark7fc1d122017-10-09 14:07:42 -04001447Returns false if either r or Rect is empty, leaving Rect unchanged.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001448
Cary Clark7fc1d122017-10-09 14:07:42 -04001449#Param r limit of result ##
1450
1451#Return true if r and Rect have area in common ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001452
1453#Example
Cary Clark7fc1d122017-10-09 14:07:42 -04001454#Description
1455Two SkDebugf calls are required. If the calls are combined, their arguments
1456may not be evaluated in left to right order: the printed intersection may
1457be before or after the call to intersect.
1458##
Cary Clark154beea2017-10-26 07:58:48 -04001459 SkRect leftRect = { 10, 40, 50, 80 };
1460 SkRect rightRect = { 30, 60, 70, 90 };
1461 SkDebugf("%s intersection: ", leftRect.intersect(rightRect) ? "" : "no ");
1462 SkDebugf("%g, %g, %g, %g\n", leftRect.left(), leftRect.top(),
Cary Clark7fc1d122017-10-09 14:07:42 -04001463 leftRect.right(), leftRect.bottom());
1464#StdOut
1465 intersection: 30, 60, 50, 80
1466##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001467##
1468
Cary Clark7fc1d122017-10-09 14:07:42 -04001469#SeeAlso intersects Intersects join SkIRect::intersect
Cary Clarkbc5697d2017-10-04 14:31:33 -04001470
1471##
1472
1473# ------------------------------------------------------------------------------
1474
1475#Method bool intersect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
1476
Cary Clark7fc1d122017-10-09 14:07:42 -04001477Constructs Rect to intersect from (left, top, right, bottom). Does not sort
1478construction.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001479
Cary Clark7fc1d122017-10-09 14:07:42 -04001480Returns true if Rect intersects construction, and sets Rect to intersection.
1481Returns false if Rect does not intersect construction, and leaves Rect unchanged.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001482
Cary Clark7fc1d122017-10-09 14:07:42 -04001483Returns false if either construction or Rect is empty, leaving Rect unchanged.
1484
1485#Param left x minimum of constructed Rect ##
1486#Param top y minimum of constructed Rect ##
1487#Param right x maximum of constructed Rect ##
1488#Param bottom y maximum of constructed Rect ##
1489
1490#Return true if construction and Rect have area in common ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001491
1492#Example
Cary Clark7fc1d122017-10-09 14:07:42 -04001493#Description
1494Two SkDebugf calls are required. If the calls are combined, their arguments
1495may not be evaluated in left to right order: the printed intersection may
1496be before or after the call to intersect.
1497##
Cary Clark154beea2017-10-26 07:58:48 -04001498 SkRect leftRect = { 10, 40, 50, 80 };
1499 SkDebugf("%s intersection: ", leftRect.intersect(30, 60, 70, 90) ? "" : "no ");
1500 SkDebugf("%g, %g, %g, %g\n", leftRect.left(), leftRect.top(),
Cary Clark7fc1d122017-10-09 14:07:42 -04001501 leftRect.right(), leftRect.bottom());
1502#StdOut
1503 intersection: 30, 60, 50, 80
1504##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001505##
1506
Cary Clark7fc1d122017-10-09 14:07:42 -04001507#SeeAlso intersects Intersects join SkIRect::intersect
Cary Clarkbc5697d2017-10-04 14:31:33 -04001508
1509##
1510
1511# ------------------------------------------------------------------------------
1512
1513#Method bool SK_WARN_UNUSED_RESULT intersect(const SkRect& a, const SkRect& b)
1514
Cary Clark7fc1d122017-10-09 14:07:42 -04001515Returns true if a intersects b, and sets Rect to intersection.
1516Returns false if a does not intersect b, and leaves Rect unchanged.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001517
Cary Clark7fc1d122017-10-09 14:07:42 -04001518Returns false if either a or b is empty, leaving Rect unchanged.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001519
Cary Clark7fc1d122017-10-09 14:07:42 -04001520#Param a Rect to intersect ##
1521#Param b Rect to intersect ##
1522
1523#Return true if a and b have area in common ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001524
1525#Example
Cary Clark154beea2017-10-26 07:58:48 -04001526 SkRect result;
1527 bool intersected = result.intersect({ 10, 40, 50, 80 }, { 30, 60, 70, 90 });
1528 SkDebugf("%s intersection: %g, %g, %g, %g\n", intersected ? "" : "no ",
1529 result.left(), result.top(), result.right(), result.bottom());
Cary Clark7fc1d122017-10-09 14:07:42 -04001530#StdOut
1531 intersection: 30, 60, 50, 80
1532##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001533##
1534
Cary Clark7fc1d122017-10-09 14:07:42 -04001535#SeeAlso intersects Intersects join SkIRect::intersect
Cary Clarkbc5697d2017-10-04 14:31:33 -04001536
1537##
1538
Cary Clark7fc1d122017-10-09 14:07:42 -04001539# ------------------------------------------------------------------------------
1540
Cary Clarkbc5697d2017-10-04 14:31:33 -04001541#Method bool intersects(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) const
1542
Cary Clark7fc1d122017-10-09 14:07:42 -04001543Constructs Rect to intersect from (left, top, right, bottom). Does not sort
1544construction.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001545
Cary Clark7fc1d122017-10-09 14:07:42 -04001546Returns true if Rect intersects construction.
1547Returns false if either construction or Rect is empty, or do not intersect.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001548
Cary Clark7fc1d122017-10-09 14:07:42 -04001549#Param left x minimum of constructed Rect ##
1550#Param top y minimum of constructed Rect ##
1551#Param right x maximum of constructed Rect ##
1552#Param bottom y maximum of constructed Rect ##
1553
1554#Return true if construction and Rect have area in common ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001555
1556#Example
Cary Clark154beea2017-10-26 07:58:48 -04001557 SkRect rect = { 10, 40, 50, 80 };
1558 SkDebugf("%s intersection", rect.intersects(30, 60, 70, 90) ? "" : "no ");
Cary Clark7fc1d122017-10-09 14:07:42 -04001559#StdOut
1560 intersection
1561##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001562##
1563
Cary Clark7fc1d122017-10-09 14:07:42 -04001564#SeeAlso intersect Intersects SkIRect::Intersects
Cary Clarkbc5697d2017-10-04 14:31:33 -04001565
1566##
1567
Cary Clark7fc1d122017-10-09 14:07:42 -04001568# ------------------------------------------------------------------------------
1569
Cary Clarkbc5697d2017-10-04 14:31:33 -04001570#Method bool intersects(const SkRect& r) const
1571
Cary Clark7fc1d122017-10-09 14:07:42 -04001572Returns true if Rect intersects r.
1573Returns false if either r or Rect is empty, or do not intersect.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001574
Cary Clark7fc1d122017-10-09 14:07:42 -04001575#Param r Rect to intersect ##
1576
1577#Return true if r and Rect have area in common ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001578
1579#Example
Cary Clark154beea2017-10-26 07:58:48 -04001580 SkRect rect = { 10, 40, 50, 80 };
1581 SkDebugf("%s intersection", rect.intersects({30, 60, 70, 90}) ? "" : "no ");
Cary Clark7fc1d122017-10-09 14:07:42 -04001582#StdOut
1583 intersection
1584##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001585##
1586
Cary Clark7fc1d122017-10-09 14:07:42 -04001587#SeeAlso intersect Intersects SkIRect::Intersects
Cary Clarkbc5697d2017-10-04 14:31:33 -04001588
1589##
1590
Cary Clark7fc1d122017-10-09 14:07:42 -04001591# ------------------------------------------------------------------------------
1592
Cary Clarkbc5697d2017-10-04 14:31:33 -04001593#Method static bool Intersects(const SkRect& a, const SkRect& b)
1594
Cary Clark7fc1d122017-10-09 14:07:42 -04001595Returns true if a intersects b.
1596Returns false if either a or b is empty, or do not intersect.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001597
Cary Clark7fc1d122017-10-09 14:07:42 -04001598#Param a Rect to intersect ##
1599#Param b Rect to intersect ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001600
Cary Clark7fc1d122017-10-09 14:07:42 -04001601#Return true if a and b have area in common ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001602
1603#Example
Cary Clark154beea2017-10-26 07:58:48 -04001604 SkDebugf("%s intersection", SkRect::Intersects({10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no ");
Cary Clark7fc1d122017-10-09 14:07:42 -04001605#StdOut
1606 intersection
1607##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001608##
1609
Cary Clark7fc1d122017-10-09 14:07:42 -04001610#SeeAlso intersect intersects SkIRect::Intersects
Cary Clarkbc5697d2017-10-04 14:31:33 -04001611
1612##
1613
Cary Clark7fc1d122017-10-09 14:07:42 -04001614#Topic Intersection ##
1615
1616
1617# ------------------------------------------------------------------------------
Cary Clarkbc5697d2017-10-04 14:31:33 -04001618
1619#Method void join(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
1620
Cary Clark7fc1d122017-10-09 14:07:42 -04001621Constructs Rect to intersect from (left, top, right, bottom). Does not sort
1622construction.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001623
Cary Clark7fc1d122017-10-09 14:07:42 -04001624Sets Rect to the union of itself and the construction.
1625
1626Has no effect if construction is empty. Otherwise, if Rect is empty, sets
1627Rect to construction.
1628
1629#Param left x minimum of constructed Rect ##
1630#Param top y minimum of constructed Rect ##
1631#Param right x maximum of constructed Rect ##
1632#Param bottom y maximum of constructed Rect ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001633
1634#Example
Cary Clark154beea2017-10-26 07:58:48 -04001635 SkRect rect = { 10, 20, 15, 25};
1636 rect.join(50, 60, 55, 65);
1637 SkDebugf("join: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
Cary Clark7fc1d122017-10-09 14:07:42 -04001638#StdOut
1639 join: 10, 20, 55, 65
1640##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001641##
1642
Cary Clark7fc1d122017-10-09 14:07:42 -04001643#SeeAlso joinNonEmptyArg joinPossiblyEmptyRect SkIRect::join
Cary Clarkbc5697d2017-10-04 14:31:33 -04001644
1645##
1646
Cary Clark7fc1d122017-10-09 14:07:42 -04001647# ------------------------------------------------------------------------------
1648
Cary Clarkbc5697d2017-10-04 14:31:33 -04001649#Method void join(const SkRect& r)
1650
Cary Clark7fc1d122017-10-09 14:07:42 -04001651Sets Rect to the union of itself and r.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001652
Cary Clark7fc1d122017-10-09 14:07:42 -04001653Has no effect if r is empty. Otherwise, if Rect is empty, sets
1654Rect to r.
1655
1656#Param r expansion Rect ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001657
1658#Example
Cary Clark154beea2017-10-26 07:58:48 -04001659 SkRect rect = { 10, 20, 15, 25};
1660 rect.join({50, 60, 55, 65});
1661 SkDebugf("join: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
Cary Clark7fc1d122017-10-09 14:07:42 -04001662#StdOut
1663 join: 10, 20, 55, 65
1664##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001665##
1666
Cary Clark7fc1d122017-10-09 14:07:42 -04001667#SeeAlso joinNonEmptyArg joinPossiblyEmptyRect SkIRect::join
Cary Clarkbc5697d2017-10-04 14:31:33 -04001668
1669##
1670
Cary Clark7fc1d122017-10-09 14:07:42 -04001671# ------------------------------------------------------------------------------
1672
Cary Clarkbc5697d2017-10-04 14:31:33 -04001673#Method void joinNonEmptyArg(const SkRect& r)
1674
Cary Clark7fc1d122017-10-09 14:07:42 -04001675Sets Rect to the union of itself and r.
1676
1677Asserts if r is empty and SK_DEBUG is defined.
1678If Rect is empty, sets Rect to r.
1679
1680May produce incorrect results if r is empty.
1681
1682#Param r expansion Rect ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001683
1684#Example
Cary Clark7fc1d122017-10-09 14:07:42 -04001685#Description
1686Since Rect is not sorted, first result is copy of toJoin.
1687##
Cary Clark154beea2017-10-26 07:58:48 -04001688 SkRect rect = { 10, 100, 15, 0};
1689 SkRect sorted = rect.makeSorted();
1690 SkRect toJoin = { 50, 60, 55, 65 };
1691 rect.joinNonEmptyArg(toJoin);
1692 SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1693 sorted.joinNonEmptyArg(toJoin);
Cary Clark7fc1d122017-10-09 14:07:42 -04001694 SkDebugf("sorted: %g, %g, %g, %g\n", sorted.fLeft, sorted.fTop, sorted.fRight, sorted.fBottom);
1695#StdOut
Cary Clark154beea2017-10-26 07:58:48 -04001696rect: 50, 60, 55, 65
Cary Clark7fc1d122017-10-09 14:07:42 -04001697sorted: 10, 0, 55, 100
1698##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001699##
1700
Cary Clark7fc1d122017-10-09 14:07:42 -04001701#SeeAlso join joinPossiblyEmptyRect SkIRect::join
Cary Clarkbc5697d2017-10-04 14:31:33 -04001702
1703##
1704
Cary Clark7fc1d122017-10-09 14:07:42 -04001705# ------------------------------------------------------------------------------
1706
Cary Clarkbc5697d2017-10-04 14:31:33 -04001707#Method void joinPossiblyEmptyRect(const SkRect& r)
1708
Cary Clark7fc1d122017-10-09 14:07:42 -04001709Sets Rect to the union of itself and the construction.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001710
Cary Clark7fc1d122017-10-09 14:07:42 -04001711May produce incorrect results if Rect or r is empty.
1712
1713#Param r expansion Rect ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001714
1715#Example
Cary Clark7fc1d122017-10-09 14:07:42 -04001716#Description
1717Since Rect is not sorted, first result is not useful.
1718##
Cary Clark154beea2017-10-26 07:58:48 -04001719 SkRect rect = { 10, 100, 15, 0};
1720 SkRect sorted = rect.makeSorted();
1721 SkRect toJoin = { 50, 60, 55, 65 };
1722 rect.joinPossiblyEmptyRect(toJoin);
1723 SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1724 sorted.joinPossiblyEmptyRect(toJoin);
1725 SkDebugf("sorted: %g, %g, %g, %g\n", sorted.fLeft, sorted.fTop, sorted.fRight, sorted.fBottom);
Cary Clark7fc1d122017-10-09 14:07:42 -04001726#StdOut
Cary Clark154beea2017-10-26 07:58:48 -04001727rect: 10, 60, 55, 65
Cary Clark7fc1d122017-10-09 14:07:42 -04001728sorted: 10, 0, 55, 100
1729##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001730##
1731
Cary Clark7fc1d122017-10-09 14:07:42 -04001732#SeeAlso joinNonEmptyArg join SkIRect::join
Cary Clarkbc5697d2017-10-04 14:31:33 -04001733
1734##
1735
Cary Clark7fc1d122017-10-09 14:07:42 -04001736# ------------------------------------------------------------------------------
1737
Cary Clark884dd7d2017-10-11 10:37:52 -04001738#Method bool contains(const SkRect& r) const
Cary Clarkbc5697d2017-10-04 14:31:33 -04001739
Cary Clark7fc1d122017-10-09 14:07:42 -04001740Returns true if Rect contains r.
1741Returns false if Rect is empty or r is empty.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001742
Cary Clark7fc1d122017-10-09 14:07:42 -04001743Rect contains r when Rect area completely includes r area.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001744
Cary Clark7fc1d122017-10-09 14:07:42 -04001745#Param r Rect contained ##
1746
1747#Return true if all sides of Rect are outside r ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001748
1749#Example
Cary Clark154beea2017-10-26 07:58:48 -04001750 SkRect rect = { 30, 50, 40, 60 };
1751 SkRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1752 for (auto contained : tests) {
1753 SkDebugf("rect: (%g, %g, %g, %g) %s (%g, %g, %g, %g)\n",
1754 rect.left(), rect.top(), rect.right(), rect.bottom(),
1755 rect.contains(contained) ? "contains" : "does not contain",
1756 contained.left(), contained.top(), contained.right(), contained.bottom());
1757 }
1758#StdOut
1759rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1760rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1761rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1762##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001763##
1764
Cary Clark7fc1d122017-10-09 14:07:42 -04001765#SeeAlso SkIRect::contains
Cary Clarkbc5697d2017-10-04 14:31:33 -04001766
1767##
1768
Cary Clark7fc1d122017-10-09 14:07:42 -04001769# ------------------------------------------------------------------------------
1770
Cary Clarkbc5697d2017-10-04 14:31:33 -04001771#Method bool contains(const SkIRect& r) const
1772
Cary Clark7fc1d122017-10-09 14:07:42 -04001773Returns true if Rect contains r.
1774Returns false if Rect is empty or r is empty.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001775
Cary Clark7fc1d122017-10-09 14:07:42 -04001776Rect contains r when Rect area completely includes r area.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001777
Cary Clark7fc1d122017-10-09 14:07:42 -04001778#Param r IRect contained ##
1779
1780#Return true if all sides of Rect are outside r ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001781
1782#Example
Cary Clark154beea2017-10-26 07:58:48 -04001783 SkRect rect = { 30, 50, 40, 60 };
1784 SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
1785 for (auto contained : tests) {
1786 SkDebugf("rect: (%g, %g, %g, %g) %s (%d, %d, %d, %d)\n",
1787 rect.left(), rect.top(), rect.right(), rect.bottom(),
1788 rect.contains(contained) ? "contains" : "does not contain",
1789 contained.left(), contained.top(), contained.right(), contained.bottom());
1790 }
1791#StdOut
1792rect: (30, 50, 40, 60) contains (30, 50, 31, 51)
1793rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50)
1794rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60)
1795##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001796##
1797
Cary Clark7fc1d122017-10-09 14:07:42 -04001798#SeeAlso SkIRect::contains
Cary Clarkbc5697d2017-10-04 14:31:33 -04001799
1800##
1801
Cary Clark7fc1d122017-10-09 14:07:42 -04001802#Topic Round
1803
1804# ------------------------------------------------------------------------------
1805
Cary Clarkbc5697d2017-10-04 14:31:33 -04001806#Method void round(SkIRect* dst) const
1807
Cary Clark7fc1d122017-10-09 14:07:42 -04001808Sets IRect by adding 0.5 and discarding the fractional portion of Rect
1809members, using
1810#Formula
1811(SkScalarRoundToInt(fLeft), SkScalarRoundToInt(fTop),
1812 SkScalarRoundToInt(fRight), SkScalarRoundToInt(fBottom))
1813##
1814.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001815
Cary Clark7fc1d122017-10-09 14:07:42 -04001816#Param dst storage for IRect ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001817
1818#Example
Cary Clark154beea2017-10-26 07:58:48 -04001819 SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f };
1820 SkIRect round;
1821 rect.round(&round);
1822 SkDebugf("round: %d, %d, %d, %d\n", round.fLeft, round.fTop, round.fRight, round.fBottom);
Cary Clark7fc1d122017-10-09 14:07:42 -04001823#StdOut
1824round: 31, 51, 41, 61
1825##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001826##
1827
Cary Clark7fc1d122017-10-09 14:07:42 -04001828#SeeAlso roundIn roundOut SkScalarRoundToInt
Cary Clarkbc5697d2017-10-04 14:31:33 -04001829
1830##
1831
Cary Clark7fc1d122017-10-09 14:07:42 -04001832# ------------------------------------------------------------------------------
1833
Cary Clarkbc5697d2017-10-04 14:31:33 -04001834#Method void roundOut(SkIRect* dst) const
1835
Cary Clark7fc1d122017-10-09 14:07:42 -04001836Sets IRect by discarding the fractional portion of fLeft and fTop; and
1837rounding up fRight and FBottom, using
1838#Formula
1839(SkScalarFloorToInt(fLeft), SkScalarFloorToInt(fTop),
1840 SkScalarCeilToInt(fRight), SkScalarCeilToInt(fBottom))
1841##
1842.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001843
Cary Clark7fc1d122017-10-09 14:07:42 -04001844#Param dst storage for IRect ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001845
1846#Example
Cary Clark154beea2017-10-26 07:58:48 -04001847 SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f };
1848 SkIRect round;
1849 rect.roundOut(&round);
1850 SkDebugf("round: %d, %d, %d, %d\n", round.fLeft, round.fTop, round.fRight, round.fBottom);
Cary Clark7fc1d122017-10-09 14:07:42 -04001851#StdOut
1852round: 30, 50, 41, 61
1853##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001854##
1855
Cary Clark7fc1d122017-10-09 14:07:42 -04001856#SeeAlso roundIn round SkScalarRoundToInt
Cary Clarkbc5697d2017-10-04 14:31:33 -04001857
1858##
1859
Cary Clark7fc1d122017-10-09 14:07:42 -04001860# ------------------------------------------------------------------------------
1861
Cary Clarkbc5697d2017-10-04 14:31:33 -04001862#Method void roundOut(SkRect* dst) const
1863
Cary Clark7fc1d122017-10-09 14:07:42 -04001864Sets Rect by discarding the fractional portion of fLeft and fTop; and
1865rounding up fRight and FBottom, using
1866#Formula
1867(SkScalarFloorToInt(fLeft), SkScalarFloorToInt(fTop),
1868 SkScalarCeilToInt(fRight), SkScalarCeilToInt(fBottom))
1869##
1870.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001871
Cary Clark7fc1d122017-10-09 14:07:42 -04001872#Param dst storage for Rect ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001873
1874#Example
Cary Clark154beea2017-10-26 07:58:48 -04001875 SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f };
1876 SkRect round;
1877 rect.roundOut(&round);
1878 SkDebugf("round: %g, %g, %g, %g\n", round.fLeft, round.fTop, round.fRight, round.fBottom);
Cary Clark7fc1d122017-10-09 14:07:42 -04001879#StdOut
1880round: 30, 50, 41, 61
1881##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001882##
1883
Cary Clark7fc1d122017-10-09 14:07:42 -04001884#SeeAlso roundIn round SkScalarRoundToInt
Cary Clarkbc5697d2017-10-04 14:31:33 -04001885
1886##
1887
Cary Clark7fc1d122017-10-09 14:07:42 -04001888# ------------------------------------------------------------------------------
1889
Cary Clarkbc5697d2017-10-04 14:31:33 -04001890#Method void roundIn(SkIRect* dst) const
1891
Cary Clark7fc1d122017-10-09 14:07:42 -04001892Sets Rect by rounding up fLeft and fTop; and
1893discarding the fractional portion of fRight and FBottom, using
Cary Clark154beea2017-10-26 07:58:48 -04001894
Cary Clark7fc1d122017-10-09 14:07:42 -04001895#Formula
1896(SkScalarCeilToInt(fLeft), SkScalarCeilToInt(fTop),
1897 SkScalarFloorToInt(fRight), SkScalarFloorToInt(fBottom))
1898##
1899.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001900
Cary Clark7fc1d122017-10-09 14:07:42 -04001901#Param dst storage for IRect ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001902
1903#Example
Cary Clark154beea2017-10-26 07:58:48 -04001904 SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f };
1905 SkIRect round;
1906 rect.roundIn(&round);
1907 SkDebugf("round: %d, %d, %d, %d\n", round.fLeft, round.fTop, round.fRight, round.fBottom);
Cary Clark7fc1d122017-10-09 14:07:42 -04001908#StdOut
Cary Clark154beea2017-10-26 07:58:48 -04001909round: 31, 51, 40, 60
Cary Clark7fc1d122017-10-09 14:07:42 -04001910##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001911##
1912
Cary Clark7fc1d122017-10-09 14:07:42 -04001913#SeeAlso roundOut round SkScalarRoundToInt
Cary Clarkbc5697d2017-10-04 14:31:33 -04001914
1915##
1916
Cary Clark7fc1d122017-10-09 14:07:42 -04001917# ------------------------------------------------------------------------------
1918
Cary Clarkbc5697d2017-10-04 14:31:33 -04001919#Method SkIRect round() const
1920
Cary Clark7fc1d122017-10-09 14:07:42 -04001921Returns IRect by adding 0.5 and discarding the fractional portion of Rect
1922members, using
1923#Formula
1924(SkScalarRoundToInt(fLeft), SkScalarRoundToInt(fTop),
1925 SkScalarRoundToInt(fRight), SkScalarRoundToInt(fBottom))
1926##
1927.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001928
Cary Clark7fc1d122017-10-09 14:07:42 -04001929#Return rounded IRect ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001930
1931#Example
Cary Clark154beea2017-10-26 07:58:48 -04001932 SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f };
1933 SkIRect round = rect.round();
1934 SkDebugf("round: %d, %d, %d, %d\n", round.fLeft, round.fTop, round.fRight, round.fBottom);
Cary Clark7fc1d122017-10-09 14:07:42 -04001935#StdOut
Cary Clark154beea2017-10-26 07:58:48 -04001936round: 31, 51, 41, 61
Cary Clark7fc1d122017-10-09 14:07:42 -04001937##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001938##
1939
Cary Clark7fc1d122017-10-09 14:07:42 -04001940#SeeAlso roundOut roundIn SkScalarRoundToInt
Cary Clarkbc5697d2017-10-04 14:31:33 -04001941
1942##
1943
Cary Clark7fc1d122017-10-09 14:07:42 -04001944# ------------------------------------------------------------------------------
1945
Cary Clarkbc5697d2017-10-04 14:31:33 -04001946#Method SkIRect roundOut() const
1947
Cary Clark7fc1d122017-10-09 14:07:42 -04001948Sets IRect by discarding the fractional portion of fLeft and fTop; and
1949rounding up fRight and FBottom, using
1950#Formula
1951(SkScalarFloorToInt(fLeft), SkScalarFloorToInt(fTop),
1952 SkScalarCeilToInt(fRight), SkScalarCeilToInt(fBottom))
1953##
1954.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001955
Cary Clark7fc1d122017-10-09 14:07:42 -04001956#Return rounded IRect ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001957
1958#Example
Cary Clark154beea2017-10-26 07:58:48 -04001959 SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f };
1960 SkIRect round = rect.roundOut();
1961 SkDebugf("round: %d, %d, %d, %d\n", round.fLeft, round.fTop, round.fRight, round.fBottom);
Cary Clark7fc1d122017-10-09 14:07:42 -04001962#StdOut
Cary Clark154beea2017-10-26 07:58:48 -04001963round: 30, 50, 41, 61
Cary Clark7fc1d122017-10-09 14:07:42 -04001964##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001965##
1966
Cary Clark7fc1d122017-10-09 14:07:42 -04001967#SeeAlso round roundIn SkScalarRoundToInt
Cary Clarkbc5697d2017-10-04 14:31:33 -04001968
1969##
1970
Cary Clark7fc1d122017-10-09 14:07:42 -04001971#Topic Round ##
1972
1973# ------------------------------------------------------------------------------
1974
Cary Clarkbc5697d2017-10-04 14:31:33 -04001975#Method void sort()
1976
Cary Clark7fc1d122017-10-09 14:07:42 -04001977Swaps fLeft and fRight if fLeft is greater than fRight; and swaps
1978fTop and fBottom if fTop is greater than fBottom. Result may be empty;
1979and width() and height() will be zero or positive.
Cary Clarkbc5697d2017-10-04 14:31:33 -04001980
1981#Example
Cary Clark154beea2017-10-26 07:58:48 -04001982 SkRect rect = { 30.5f, 50.5f, 20.5f, 10.5f };
1983 SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
1984 rect.sort();
1985 SkDebugf("sorted: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
Cary Clark7fc1d122017-10-09 14:07:42 -04001986#StdOut
Cary Clark154beea2017-10-26 07:58:48 -04001987rect: 30.5, 50.5, 20.5, 10.5
Cary Clark7fc1d122017-10-09 14:07:42 -04001988sorted: 20.5, 10.5, 30.5, 50.5
1989##
Cary Clarkbc5697d2017-10-04 14:31:33 -04001990##
1991
Cary Clark7fc1d122017-10-09 14:07:42 -04001992#SeeAlso makeSorted SkIRect::sort
Cary Clarkbc5697d2017-10-04 14:31:33 -04001993
1994##
1995
Cary Clark7fc1d122017-10-09 14:07:42 -04001996# ------------------------------------------------------------------------------
1997
Cary Clarkbc5697d2017-10-04 14:31:33 -04001998#Method SkRect makeSorted() const
1999
Cary Clark7fc1d122017-10-09 14:07:42 -04002000Returns Rect with fLeft and fRight swapped if fLeft is greater than fRight; and
2001with fTop and fBottom swapped if fTop is greater than fBottom. Result may be empty;
2002and width() and height() will be zero or positive.
Cary Clarkbc5697d2017-10-04 14:31:33 -04002003
Cary Clark7fc1d122017-10-09 14:07:42 -04002004#Return sorted Rect ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04002005
2006#Example
Cary Clark154beea2017-10-26 07:58:48 -04002007 SkRect rect = { 30.5f, 50.5f, 20.5f, 10.5f };
2008 SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
2009 SkRect sort = rect.makeSorted();
2010 SkDebugf("sorted: %g, %g, %g, %g\n", sort.fLeft, sort.fTop, sort.fRight, sort.fBottom);
Cary Clark7fc1d122017-10-09 14:07:42 -04002011#StdOut
Cary Clark154beea2017-10-26 07:58:48 -04002012rect: 30.5, 50.5, 20.5, 10.5
Cary Clark7fc1d122017-10-09 14:07:42 -04002013sorted: 20.5, 10.5, 30.5, 50.5
2014##
Cary Clarkbc5697d2017-10-04 14:31:33 -04002015##
2016
Cary Clark7fc1d122017-10-09 14:07:42 -04002017#SeeAlso sort SkIRect::makeSorted
Cary Clarkbc5697d2017-10-04 14:31:33 -04002018
2019##
2020
Cary Clark7fc1d122017-10-09 14:07:42 -04002021# ------------------------------------------------------------------------------
2022
Cary Clarkbc5697d2017-10-04 14:31:33 -04002023#Method const SkScalar* asScalars() const
2024
Cary Clark7fc1d122017-10-09 14:07:42 -04002025Returns pointer to first Scalar in Rect, to treat it as an array with four
2026entries.
Cary Clarkbc5697d2017-10-04 14:31:33 -04002027
Cary Clark7fc1d122017-10-09 14:07:42 -04002028#Return pointer to fLeft ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04002029
2030#Example
Cary Clark154beea2017-10-26 07:58:48 -04002031 SkRect rect = {7, 11, 13, 17};
2032SkDebugf("rect.asScalars() %c= &rect.fLeft\n", rect.asScalars() == &rect.fLeft? '=' : '!');
2033#StdOut
2034rect.asScalars() == &rect.fLeft
2035##
Cary Clarkbc5697d2017-10-04 14:31:33 -04002036##
2037
Cary Clark7fc1d122017-10-09 14:07:42 -04002038#SeeAlso toQuad
2039
Cary Clarkbc5697d2017-10-04 14:31:33 -04002040##
2041
Cary Clark7fc1d122017-10-09 14:07:42 -04002042# ------------------------------------------------------------------------------
2043
Cary Clarkbc5697d2017-10-04 14:31:33 -04002044#Method void dump(bool asHex) const
2045
Cary Clark7fc1d122017-10-09 14:07:42 -04002046Writes text representation of Rect to standard output. Set asHex to true to
2047generate exact binary representations of floating point numbers.
2048
2049#Param asHex true if SkScalar values are written as hexadecimal ##
Cary Clarkbc5697d2017-10-04 14:31:33 -04002050
2051#Example
Cary Clark7fc1d122017-10-09 14:07:42 -04002052 SkRect rect = {20, 30, 40, 50};
2053 for (bool dumpAsHex : { false, true } ) {
2054 rect.dump(dumpAsHex);
2055 SkDebugf("\n");
2056 }
2057#StdOut
Cary Clark154beea2017-10-26 07:58:48 -04002058SkRect::MakeLTRB(20, 30, 40, 50);
2059
2060SkRect::MakeLTRB(SkBits2Float(0x41a00000), /* 20.000000 */
2061 SkBits2Float(0x41f00000), /* 30.000000 */
2062 SkBits2Float(0x42200000), /* 40.000000 */
2063 SkBits2Float(0x42480000) /* 50.000000 */);
Cary Clark7fc1d122017-10-09 14:07:42 -04002064##
Cary Clarkbc5697d2017-10-04 14:31:33 -04002065##
2066
Cary Clark7fc1d122017-10-09 14:07:42 -04002067#SeeAlso dumpHex
2068
Cary Clarkbc5697d2017-10-04 14:31:33 -04002069##
2070
Cary Clark7fc1d122017-10-09 14:07:42 -04002071# ------------------------------------------------------------------------------
2072
Cary Clarkbc5697d2017-10-04 14:31:33 -04002073#Method void dump() const
2074
Cary Clark7fc1d122017-10-09 14:07:42 -04002075Writes text representation of Rect to standard output. The representation may be
2076directly compiled as C++ code. Floating point values are written
2077with limited precision; it may not be possible to reconstruct original Rect
2078from output.
2079
Cary Clarkbc5697d2017-10-04 14:31:33 -04002080#Example
Cary Clark154beea2017-10-26 07:58:48 -04002081SkRect rect = {6.f / 7, 2.f / 3, 26.f / 10, 42.f / 6};
2082rect.dump();
2083SkRect copy = SkRect::MakeLTRB(0.857143f, 0.666667f, 2.6f, 7);
2084SkDebugf("rect is " "%s" "equal to copy\n", rect == copy ? "" : "not ");
Cary Clark7fc1d122017-10-09 14:07:42 -04002085#StdOut
Cary Clark154beea2017-10-26 07:58:48 -04002086SkRect::MakeLTRB(0.857143f, 0.666667f, 2.6f, 7);
Cary Clark7fc1d122017-10-09 14:07:42 -04002087rect is not equal to copy
2088##
Cary Clarkbc5697d2017-10-04 14:31:33 -04002089##
2090
Cary Clark7fc1d122017-10-09 14:07:42 -04002091#SeeAlso dumpHex
2092
Cary Clarkbc5697d2017-10-04 14:31:33 -04002093##
2094
Cary Clark7fc1d122017-10-09 14:07:42 -04002095# ------------------------------------------------------------------------------
2096
Cary Clarkbc5697d2017-10-04 14:31:33 -04002097#Method void dumpHex() const
2098
Cary Clark7fc1d122017-10-09 14:07:42 -04002099Writes text representation of Rect to standard output. The representation may be
2100directly compiled as C++ code. Floating point values are written
2101in hexadecimal to preserve their exact bit pattern. The output reconstructs the
2102original Rect.
2103
2104Use instead of dump() when submitting
2105#A bug reports against Skia # http://bug.skia.org ##
2106.
2107
Cary Clarkbc5697d2017-10-04 14:31:33 -04002108#Example
Cary Clark154beea2017-10-26 07:58:48 -04002109 SkRect rect = {6.f / 7, 2.f / 3, 26.f / 10, 42.f / 6};
2110rect.dumpHex();
2111SkRect copy = SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
2112 SkBits2Float(0x3f2aaaab), /* 0.666667 */
2113 SkBits2Float(0x40266666), /* 2.600000 */
2114 SkBits2Float(0x40e00000) /* 7.000000 */);
Cary Clark7fc1d122017-10-09 14:07:42 -04002115SkDebugf("rect is " "%s" "equal to copy\n", rect == copy ? "" : "not ");
2116#StdOut
Cary Clark154beea2017-10-26 07:58:48 -04002117SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
2118 SkBits2Float(0x3f2aaaab), /* 0.666667 */
2119 SkBits2Float(0x40266666), /* 2.600000 */
2120 SkBits2Float(0x40e00000) /* 7.000000 */);
Cary Clark7fc1d122017-10-09 14:07:42 -04002121rect is equal to copy
Cary Clarkbc5697d2017-10-04 14:31:33 -04002122##
Cary Clark7fc1d122017-10-09 14:07:42 -04002123##
2124
2125#SeeAlso dump
Cary Clarkbc5697d2017-10-04 14:31:33 -04002126
2127##
2128
Cary Clark0c95aab2018-01-08 16:20:59 -05002129#Method static SkRect SK_WARN_UNUSED_RESULT MakeLargest()
2130
2131#Deprecated
2132##
2133
2134##
2135
Cary Clarkbc5697d2017-10-04 14:31:33 -04002136#Struct SkRect ##
2137
2138#Topic Rect ##