blob: a96237cdc53146f6eb38cac1b546ab0859936fd5 [file] [log] [blame]
Cary Clark224c7002018-06-27 11:00:21 -04001#Topic RRect
2#Alias Round_Rect ##
3#Alias RRect_Reference ##
4
5#Class SkRRect
6
7#Private
8Path forward:
9 core work
10 add contains(SkRect&) - for clip stack
11 add contains(SkRRect&) - for clip stack
12 add heart rect computation (max rect inside RR)
13 add 9patch rect computation
14 add growToInclude(SkPath&)
15 analysis
16 use growToInclude to fit skp round rects & generate stats (RRs vs. real paths)
17 check on # of rectorus's the RRs could handle
18 rendering work
19 update SkPath.addRRect() to only use quads
20 add GM and bench
21 further out
22 detect and triangulate RRectorii rather than falling back to SW in Ganesh
23##
24
25The SkRRect class represents a rounded rect with a potentially different
26radii for each corner. It does not have a constructor so must be
27initialized with one of the initialization functions (e.g., setEmpty,
28setRectRadii, etc.)
29
30This class allows implementing CSS properties that describe rounded corners.
31A rectangle may have up to eight radii, one for each axis on each of its four
32corners.
33
34If either corner's radii are zero, the corner is square.
35Negative radii are treated as zero.
36If corner curves overlap, they are proportionally reduced to fit.
37
38#Subtopic Overview
39#Populate
40##
41
42#Subtopic Constructor
43#Populate
44##
45
46#Subtopic Operator
47#Populate
48##
49
50#Subtopic Member_Function
51#Populate
52##
53
54# ------------------------------------------------------------------------------
55
Cary Clark82f1f742018-06-28 08:50:35 -040056#Method SkRRect()
Cary Clark224c7002018-06-27 11:00:21 -040057#In Constructor
Cary Clark82f1f742018-06-28 08:50:35 -040058#Line # creates with zeroed bounds and corner radii ##
Cary Clark224c7002018-06-27 11:00:21 -040059
Cary Clark82f1f742018-06-28 08:50:35 -040060Initializes bounds at (0, 0), the origin, with zero width and height.
61Initializes corner radii to (0, 0), and sets type of kEmpty_Type.
Cary Clark224c7002018-06-27 11:00:21 -040062
Cary Clark82f1f742018-06-28 08:50:35 -040063#Return empty Round_Rect ##
Cary Clark224c7002018-06-27 11:00:21 -040064
65#Example
Cary Clark82f1f742018-06-28 08:50:35 -040066#Height 60
67 SkRRect rrect;
68 SkPaint p;
69 p.setStyle(SkPaint::kStroke_Style);
70 p.setStrokeWidth(10);
71 canvas->drawRRect(rrect, p);
72 rrect.setRect({10, 10, 100, 50});
73 canvas->drawRRect(rrect, p);
Cary Clark224c7002018-06-27 11:00:21 -040074##
75
Cary Clark82f1f742018-06-28 08:50:35 -040076#SeeAlso setEmpty isEmpty
Cary Clark224c7002018-06-27 11:00:21 -040077
78#Method ##
79
80# ------------------------------------------------------------------------------
81
Cary Clark82f1f742018-06-28 08:50:35 -040082#Method SkRRect(const SkRRect& rrect)
Cary Clark224c7002018-06-27 11:00:21 -040083#In Constructor
Cary Clark82f1f742018-06-28 08:50:35 -040084#Line # copies bounds and corner radii ##
Cary Clark224c7002018-06-27 11:00:21 -040085
Cary Clark82f1f742018-06-28 08:50:35 -040086Initializes to copy of rrect bounds and corner radii.
Cary Clark224c7002018-06-27 11:00:21 -040087
Cary Clark82f1f742018-06-28 08:50:35 -040088#Param rrect bounds and corner to copy ##
Cary Clark224c7002018-06-27 11:00:21 -040089
Cary Clark82f1f742018-06-28 08:50:35 -040090#Return copy of rrect ##
91
92#Bug 8115
Cary Clark224c7002018-06-27 11:00:21 -040093#Example
Cary Clark82f1f742018-06-28 08:50:35 -040094 SkRRect rrect = SkRRect::MakeRect({10, 10, 100, 50});
95 SkRRect rrect2(rrect);
96 rrect2.inset(20, 20);
97 SkPaint p;
98 p.setStyle(SkPaint::kStroke_Style);
99 p.setStrokeWidth(10);
100 canvas->drawRRect(rrect, p);
101 canvas->drawRRect(rrect2, p);
Cary Clark224c7002018-06-27 11:00:21 -0400102##
103
Cary Clark82f1f742018-06-28 08:50:35 -0400104#SeeAlso operator=(const SkRRect& rrect) MakeRect
Cary Clark224c7002018-06-27 11:00:21 -0400105
106#Method ##
107
108# ------------------------------------------------------------------------------
109
Cary Clark82f1f742018-06-28 08:50:35 -0400110#Method SkRRect& operator=(const SkRRect& rrect)
Cary Clark224c7002018-06-27 11:00:21 -0400111#In Operator
Cary Clark82f1f742018-06-28 08:50:35 -0400112#Line # copies bounds and corner radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400113
Cary Clark82f1f742018-06-28 08:50:35 -0400114Copies rrect bounds and corner radii.
Cary Clark224c7002018-06-27 11:00:21 -0400115
Cary Clark82f1f742018-06-28 08:50:35 -0400116#Param rrect bounds and corner to copy ##
117
118#Return copy of rrect ##
Cary Clark224c7002018-06-27 11:00:21 -0400119
120#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400121 SkRRect rrect = SkRRect::MakeRect({40, 40, 100, 70});
122 SkRRect rrect2 = rrect;
123 rrect2.inset(-20, -20);
124 SkPaint p;
125 p.setStyle(SkPaint::kStroke_Style);
126 p.setStrokeWidth(10);
127 canvas->drawRRect(rrect, p);
128 canvas->drawRRect(rrect2, p);
Cary Clark224c7002018-06-27 11:00:21 -0400129##
130
Cary Clark82f1f742018-06-28 08:50:35 -0400131#SeeAlso SkRRect(const SkRRect& rrect) MakeRect
Cary Clark224c7002018-06-27 11:00:21 -0400132
133#Method ##
134
135# ------------------------------------------------------------------------------
Cary Clark82f1f742018-06-28 08:50:35 -0400136#Subtopic Type
137#Line # specialization of Round_Rect geometry ##
138
139#PhraseDef list_of_rrect_types
140kEmpty_Type, kRect_Type, kOval_Type, kSimple_Type, kNinePatch_Type,
141kComplex_Type
142##
Cary Clark224c7002018-06-27 11:00:21 -0400143
144#Enum Type
Cary Clark82f1f742018-06-28 08:50:35 -0400145#Line # specialization of Round_Rect geometry ##
Cary Clark224c7002018-06-27 11:00:21 -0400146
147#Code
148 enum Type {
149 kEmpty_Type,
150 kRect_Type,
151 kOval_Type,
152 kSimple_Type,
153 kNinePatch_Type,
154 kComplex_Type,
155 kLastType = kComplex_Type,
156 };
157##
158
Cary Clark82f1f742018-06-28 08:50:35 -0400159Type describes possible specializations of Round_Rect. Each Type is
160exclusive; a Round_Rect may only have one type.
161
162The enum members become progressively less restrictive; larger values of
163Type have more degrees of freedom than smaller values.
Cary Clark224c7002018-06-27 11:00:21 -0400164
165#Const kEmpty_Type
Cary Clark82f1f742018-06-28 08:50:35 -0400166#Line # zero width or height ##
Cary Clark224c7002018-06-27 11:00:21 -0400167Round_Rect has zero width or height. All radii are zero.
168##
169#Const kRect_Type
Cary Clark82f1f742018-06-28 08:50:35 -0400170#Line # non-zero width and height, and zeroed radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400171Round_Rect has width and height. All radii are zero.
172##
173#Const kOval_Type
Cary Clark82f1f742018-06-28 08:50:35 -0400174#Line # non-zero width and height filled with radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400175Round_Rect has width and height. All four x-radii are equal,
176and at least half the width. All four y-radii are equal,
177and at least half the height.
178##
179#Const kSimple_Type
Cary Clark82f1f742018-06-28 08:50:35 -0400180#Line # non-zero width and height with equal radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400181Round_Rect has width and height. All four x-radii are equal and
182greater than zero, and all four y-radii are equal and greater than
183zero. Either x-radii are less than half the width, or y-radii is
184less than half the height, or both.
185##
186#Const kNinePatch_Type
Cary Clark82f1f742018-06-28 08:50:35 -0400187#Line # non-zero width and height with axis-aligned radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400188Round_Rect has width and height. Left x-radii are equal, top
189y-radii are equal, right x-radii are equal, and bottom y-radii
Cary Clark82f1f742018-06-28 08:50:35 -0400190are equal. The radii do not describe a rect, oval, or simple type.
Cary Clark224c7002018-06-27 11:00:21 -0400191
192The centers of the corner ellipses form an axis-aligned rectangle
193that divides the Round_Rect into nine rectangular patches; an
194interior rectangle, four edges, and four corners.
195##
196#Const kComplex_Type
Cary Clark82f1f742018-06-28 08:50:35 -0400197#Line # non-zero width and height with arbitrary radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400198both radii are non-zero.
199##
200#Const kLastType = kComplex_Type
Cary Clark82f1f742018-06-28 08:50:35 -0400201#Line # largest Type value ##
Cary Clark224c7002018-06-27 11:00:21 -0400202##
203
204#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400205#Height 128
206 struct Radii { SkVector data[4]; };
207 auto drawRRectType = [=](const SkRect& rect, const Radii& radii) {
208 SkRRect rrect;
209 rrect.setRectRadii(rect, radii.data);
210 SkPaint paint;
211 paint.setAntiAlias(true);
212 const char* typeStr[] = { "empty", "rect", "oval", "simple", "nine patch", "complex" };
213 paint.setTextAlign(SkPaint::kCenter_Align);
214 canvas->drawString(typeStr[(int) rrect.type()], rect.centerX(), rect.bottom() + 20, paint);
215 paint.setStyle(SkPaint::kStroke_Style);
216 canvas->drawRRect(rrect, paint);
217 };
218 drawRRectType({ 45, 30, 45, 30}, {{{ 5, 5}, { 5, 5}, { 5, 5}, { 5, 5}}});
219 drawRRectType({ 90, 10, 140, 30}, {{{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}}});
220 drawRRectType({160, 10, 210, 30}, {{{25, 10}, {25, 10}, {25, 10}, {25, 10}}});
221 drawRRectType({ 20, 80, 70, 100}, {{{ 5, 5}, { 5, 5}, { 5, 5}, { 5, 5}}});
222 drawRRectType({ 90, 80, 140, 100}, {{{ 5, 5}, {10, 5}, {10, 5}, { 5, 5}}});
223 drawRRectType({160, 80, 210, 100}, {{{ 5, 5}, {10, 5}, { 5, 5}, { 5, 5}}});
Cary Clark224c7002018-06-27 11:00:21 -0400224##
225
Cary Clark82f1f742018-06-28 08:50:35 -0400226#SeeAlso Rect Path
Cary Clark224c7002018-06-27 11:00:21 -0400227
228#Enum ##
229
230# ------------------------------------------------------------------------------
231
232#Method Type getType() const
Cary Clark82f1f742018-06-28 08:50:35 -0400233#In Property
234#Line # returns Type ##
Cary Clark224c7002018-06-27 11:00:21 -0400235
Cary Clark82f1f742018-06-28 08:50:35 -0400236Returns Type, one of: #list_of_rrect_types#.
Cary Clark224c7002018-06-27 11:00:21 -0400237
Cary Clark82f1f742018-06-28 08:50:35 -0400238#Return Type ##
Cary Clark224c7002018-06-27 11:00:21 -0400239
240#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400241#Description
242rrect2 is not a Rect; inset() has made it empty.
243##
244 SkRRect rrect = SkRRect::MakeRect({10, 10, 100, 50});
245 SkRRect rrect2(rrect);
246 rrect2.inset(20, 20);
247 SkPaint p;
248 p.setStyle(SkPaint::kStroke_Style);
249 p.setStrokeWidth(10);
250 std::string str("Type ");
251 str += SkRRect::kRect_Type == rrect2.getType() ? "=" : "!";
252 str += "= SkRRect::kRect_Type";
253 canvas->drawString(str.c_str(), 20, 80, SkPaint());
254 canvas->drawRRect(rrect2, p);
Cary Clark224c7002018-06-27 11:00:21 -0400255##
256
Cary Clark82f1f742018-06-28 08:50:35 -0400257#SeeAlso Type type
Cary Clark224c7002018-06-27 11:00:21 -0400258
259#Method ##
260
261# ------------------------------------------------------------------------------
262
263#Method Type type() const
Cary Clark82f1f742018-06-28 08:50:35 -0400264#In Property
265#Line # returns Type ##
Cary Clark224c7002018-06-27 11:00:21 -0400266
Cary Clark82f1f742018-06-28 08:50:35 -0400267Returns Type, one of: #list_of_rrect_types#.
268
269#Return Type ##
Cary Clark224c7002018-06-27 11:00:21 -0400270
271#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400272#Description
273inset() has made rrect2 empty.
274##
275 SkRRect rrect = SkRRect::MakeRect({10, 10, 100, 50});
276 SkRRect rrect2(rrect);
277 rrect2.inset(20, 20);
278 SkPaint p;
279 p.setStyle(SkPaint::kStroke_Style);
280 p.setStrokeWidth(10);
281 std::string str("Type ");
282 str += SkRRect::kEmpty_Type == rrect2.type() ? "=" : "!";
283 str += "= SkRRect::kEmpty_Type";
284 canvas->drawString(str.c_str(), 20, 80, SkPaint());
285 canvas->drawRRect(rrect2, p);
Cary Clark224c7002018-06-27 11:00:21 -0400286##
287
Cary Clark82f1f742018-06-28 08:50:35 -0400288#SeeAlso Type getType
Cary Clark224c7002018-06-27 11:00:21 -0400289
290#Method ##
291
Cary Clark82f1f742018-06-28 08:50:35 -0400292#Subtopic Type ##
293
Cary Clark224c7002018-06-27 11:00:21 -0400294# ------------------------------------------------------------------------------
295
296#Method inline bool isEmpty() const
297#In Property
298#Line # returns true if width or height are zero ##
299Returns true if rect().fLeft is equal to rect().fRight, or if rect().fTop is equal
300to rect().fBottom.
301
302#Return true if width() or height() are zero ##
303
304#Example
305#Height 100
306 SkPaint paint;
307 paint.setAntiAlias(true);
308 paint.setTextAlign(SkPaint::kCenter_Align);
309 paint.setTextSize(16);
310 SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 10, 5);
311 canvas->drawRRect(rrect, paint);
312 canvas->drawString(rrect.isEmpty() ? "empty" : "not empty", 64, 90, paint);
313 rrect.inset(40, 0);
314 canvas->translate(128, 0);
315 canvas->drawRRect(rrect, paint);
316 canvas->drawString(rrect.isEmpty() ? "empty" : "not empty", 64, 90, paint);
317##
318
319#SeeAlso SkRect::isEmpty height width
320
321#Method ##
322
323# ------------------------------------------------------------------------------
324
325#Method inline bool isRect() const
326#In Property
327#Line # returns true if not empty, and one radius at each corner is zero ##
328Returns true if not empty, and if either x or y radius at each corner is zero.
329
330#Return true if not empty, and one radius at each corner is zero ##
331
332#Example
333#Height 100
334 SkPaint paint;
335 paint.setAntiAlias(true);
336 paint.setTextAlign(SkPaint::kCenter_Align);
337 paint.setTextSize(16);
338 SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
339 canvas->drawRRect(rrect, paint);
340 canvas->drawString(rrect.isRect() ? "rect" : "not rect", 64, 90, paint);
341 SkVector radii[] = {{10, 10}, {0, 0}, {0, 0}, {0, 0}};
342 rrect.setRectRadii(rrect.getBounds(), radii);
343 canvas->translate(128, 0);
344 canvas->drawRRect(rrect, paint);
345 canvas->drawString(rrect.isRect() ? "rect" : "not rect", 64, 90, paint);
346##
347
348#SeeAlso isEmpty radii
349
350#Method ##
351
352# ------------------------------------------------------------------------------
353
354#Method inline bool isOval() const
355#In Property
356#Line # returns true if not empty, axes radii are equal, radii fill bounds ##
357Returns true if not empty, if all x-axis radii are equal, if all y-axis radii
358are equal, x-axis radii are at least half the width, and y-axis radii are at
359least half the height.
360
361#Return true if has identical geometry to Oval ##
362
363#Example
364#Height 100
365#Description
366The first radii are scaled down proportionately until both x-axis and y-axis fit
367within the bounds. After scaling, x-axis radius is smaller than half the width;
368left round rect is not an oval. The second radii are equal to half the
369dimensions; right round rect is an oval.
370##
371 SkPaint paint;
372 paint.setAntiAlias(true);
373 paint.setTextAlign(SkPaint::kCenter_Align);
374 paint.setTextSize(16);
375 SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 40, 30);
376 canvas->drawRRect(rrect, paint);
377 canvas->drawString(rrect.isOval() ? "oval" : "not oval", 64, 90, paint);
378 rrect.setRectXY(rrect.getBounds(), 35, 25);
379 canvas->translate(128, 0);
380 canvas->drawRRect(rrect, paint);
381 canvas->drawString(rrect.isOval() ? "oval" : "not oval", 64, 90, paint);
382##
383
384#SeeAlso isEmpty isSimple SkCanvas::drawOval
385
386#Method ##
387
388# ------------------------------------------------------------------------------
389
390#Method inline bool isSimple() const
391#In Property
392#Line # returns true if not empty, rect or oval; and axes radii are equal ##
393Returns true if not empty, if all x-axis radii are equal but not zero,
394if all y-axis radii are equal but not zero; and x-axis radius is less than half
395width(), or y-axis radius is less than half height().
396
397#Return true if not empty, rect or oval; and axes radii are equal ##
398
399#Bug 8107
400#Example
401#Height 100
402 SkPaint paint;
403 paint.setAntiAlias(true);
404 paint.setTextAlign(SkPaint::kCenter_Align);
405 paint.setTextSize(16);
406 SkVector radii[] = {{40, 30}, {40, 30}, {40, 30}, {40, 30}};
407 SkRRect rrect;
408 rrect.setRectRadii({30, 10, 100, 60}, radii);
409 canvas->drawRRect(rrect, paint);
410 canvas->drawString(rrect.isSimple() ? "simple" : "not simple", 64, 90, paint);
411 radii[0].fX = 35;
412 rrect.setRectRadii(rrect.getBounds(), radii);
413 canvas->translate(128, 0);
414 canvas->drawRRect(rrect, paint);
415 canvas->drawString(rrect.isSimple() ? "simple" : "not simple", 64, 90, paint);
416##
417
418#SeeAlso isEmpty isRect isOval isNinePatch
419
420#Method ##
421
422# ------------------------------------------------------------------------------
423
424#Method inline bool isNinePatch() const
425#In Property
426#Line # returns true if not empty, rect, oval or simple; and radii are axis-aligned ##
427Returns true if isEmpty, isRect, isOval, and isSimple return false; and if
428left x-axis radii are equal, right x-axis radii are equal, top y-axis radii are
429equal, and bottom y-axis radii are equal.
430
431#Return true if not empty, rect, oval or simple; and radii are axis-aligned ##
432
433#Bug 8107
434#Example
435#Height 100
436 SkPaint paint;
437 paint.setAntiAlias(true);
438 paint.setTextAlign(SkPaint::kCenter_Align);
439 paint.setTextSize(16);
440 SkVector radii[] = {{20, 30}, {40, 30}, {40, 30}, {20, 30}};
441 SkRRect rrect;
442 rrect.setRectRadii({30, 10, 100, 60}, radii);
443 canvas->drawRRect(rrect, paint);
444 canvas->drawString(rrect.isNinePatch() ? "9 patch" : "not 9 patch", 64, 90, paint);
445 radii[0].fX = 35;
446 rrect.setRectRadii(rrect.getBounds(), radii);
447 canvas->translate(128, 0);
448 canvas->drawRRect(rrect, paint);
449 canvas->drawString(rrect.isNinePatch() ? "9 patch" : "not 9 patch", 64, 90, paint);
450##
451
452#SeeAlso isEmpty isRect isOval isSimple isComplex
453
454#Method ##
455
456# ------------------------------------------------------------------------------
457
458#Method inline bool isComplex() const
459#In Property
460#Line # returns true if not empty, rect, oval, simple, or nine-patch ##
461
462Returns true if isEmpty, isRect, isOval, isSimple, and isNinePatch return false.
463If true: width and height are greater than zero, at least one corner radii are
464both greater than zero; left x-axis radii are not equal, or right x-axis radii
465are not equal, or top y-axis radii are not equal, or bottom y-axis radii are not
466equal.
467
468#Return true if not empty, rect, oval, simple, or nine-patch ##
469
470#Example
471 SkPaint paint;
472 paint.setAntiAlias(true);
473 paint.setTextAlign(SkPaint::kCenter_Align);
474 paint.setTextSize(16);
475 SkVector radii[] = {{25, 30}, {40, 30}, {40, 30}, {20, 30}};
476 SkRRect rrect;
477 rrect.setRectRadii({30, 10, 100, 60}, radii);
478 canvas->drawRRect(rrect, paint);
479 canvas->drawString(rrect.isComplex() ? "complex" : "not complex", 64, 90, paint);
480 radii[0].fX = 20;
481 rrect.setRectRadii(rrect.getBounds(), radii);
482 canvas->translate(128, 0);
483 canvas->drawRRect(rrect, paint);
484 canvas->drawString(rrect.isComplex() ? "complex" : "not complex", 64, 90, paint);
485##
486
487#SeeAlso isEmpty isRect isOval isSimple isNinePatch
488
489#Method ##
490
491# ------------------------------------------------------------------------------
492
493#Method SkScalar width() const
494#In Property
495#Line # returns span in x ##
496Returns span on the x-axis. This does not check if result fits in 32-bit float;
497result may be infinity.
498
499#Return bounds().fRight minus bounds().fLeft ##
500
501#Example
502#Description
503SkRRect::MakeRect sorts its input, so width() is always zero or larger.
504##
505 SkRRect unsorted = SkRRect::MakeRect({ 15, 25, 10, 5 });
506 SkDebugf("unsorted width: %g\n", unsorted.width());
507 SkRRect large = SkRRect::MakeRect({ -FLT_MAX, 1, FLT_MAX, 2 });
508 SkDebugf("large width: %.0f\n", large.width());
509#StdOut
510unsorted width: 5
511large width: inf
512##
513##
514
515#SeeAlso SkRect::width height getBounds
516
517#Method ##
518
519# ------------------------------------------------------------------------------
520
521#Method SkScalar height() const
522#In Property
523#Line # returns span in y ##
524Returns span on the y-axis. This does not check if result fits in 32-bit float;
525result may be infinity.
526
527#Return bounds().fBottom minus bounds().fTop ##
528
529#Example
530#Description
531SkRRect::MakeRect sorts its input, so height() is always zero or larger.
532##
533 SkRRect unsorted = SkRRect::MakeRect({ 15, 25, 10, 20 });
534 SkDebugf("unsorted height: %g\n", unsorted.height());
535 SkRRect large = SkRRect::MakeRect({ 1, -FLT_MAX, 2, FLT_MAX });
536 SkDebugf("large height: %.0f\n", large.height());
537#StdOut
538unsorted height: 5
539large height: inf
540##
541##
542
543#SeeAlso SkRect.height width getBounds
544
545#Method ##
546
547# ------------------------------------------------------------------------------
548
549#Method SkVector getSimpleRadii() const
550#In Property
551#Line # returns corner radii for simple types ##
552
553Returns top-left corner x-radii. If type() returns kEmpty_Type, kRect_Type,
554kOval_Type, or kSimple_Type, returns a value representative of all corner radii.
555If type() returns kNinePatch_Type or kComplex_Type, at least one of the
556remaining three corners has a different value.
557
558#Return corner radii for simple types ##
559
560#Example
561 auto drawDetails = [=](const SkRRect& rrect) {
562 SkPaint paint;
563 paint.setAntiAlias(true);
564 paint.setTextAlign(SkPaint::kCenter_Align);
565 paint.setTextSize(12);
566 canvas->drawRRect(rrect, paint);
567 SkVector corner = rrect.getSimpleRadii();
568 std::string label = "corner: " + std::to_string(corner.fX).substr(0, 3) + ", " +
569 std::to_string(corner.fY).substr(0, 3);
570 canvas->drawString(label.c_str(), 64, 90, paint);
571 canvas->translate(128, 0);
572 };
573 SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
574 drawDetails(rrect);
575 rrect.setRectXY(rrect.getBounds(), 5, 8);
576 drawDetails(rrect);
577##
578
579#SeeAlso radii getBounds getType isSimple
580
581#Method ##
582
583# ------------------------------------------------------------------------------
584
585#Method void setEmpty()
586#In Set
587#Line # zeroes width, height, and corner radii ##
588
589Sets bounds to zero width and height at (0, 0), the origin. Sets
590corner radii to zero and sets type to kEmpty_Type.
591
592#Example
593#Description
594Nothing blue is drawn because rrect is set to empty.
595##
596 SkPaint paint;
597 SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
598 canvas->drawRRect(rrect, paint);
599 rrect.setEmpty();
600 paint.setColor(SK_ColorBLUE);
601 canvas->drawRRect(rrect, paint);
602##
603
604#SeeAlso MakeEmpty setRect
605
606#Method ##
607
608# ------------------------------------------------------------------------------
609
610#Method void setRect(const SkRect& rect)
611#In Set
612#Line # sets rect bounds with zeroed corners ##
613
614Sets bounds to sorted rect, and sets corner radii to zero.
615If set bounds has width and height, and sets type to kRect_Type;
616otherwise, sets type to kEmpty_Type.
617
618#Param rect bounds to set ##
619
620#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400621#Height 90
Cary Clark224c7002018-06-27 11:00:21 -0400622 SkPaint paint;
623 SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
624 canvas->drawRRect(rrect, paint);
625 rrect.setRect({60, 30, 120, 80});
626 paint.setColor(SK_ColorBLUE);
627 canvas->drawRRect(rrect, paint);
628##
629
630#SeeAlso MakeRect setRectXY
631
632#Method ##
633
634# ------------------------------------------------------------------------------
635
636#Method static SkRRect MakeEmpty()
637#In Constructor
Cary Clark82f1f742018-06-28 08:50:35 -0400638#Line # creates with zeroed bounds and corner radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400639
Cary Clark82f1f742018-06-28 08:50:35 -0400640Initializes bounds at (0, 0), the origin, with zero width and height.
641Initializes corner radii to (0, 0), and sets type of kEmpty_Type.
Cary Clark224c7002018-06-27 11:00:21 -0400642
Cary Clark82f1f742018-06-28 08:50:35 -0400643#Return empty Round_Rect ##
Cary Clark224c7002018-06-27 11:00:21 -0400644
645#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400646#Height 90
647 SkRRect rrect = SkRRect::MakeEmpty();
648 SkRRect rrect2(rrect);
649 rrect2.inset(-20, -20);
650 SkPaint p;
651 p.setStyle(SkPaint::kStroke_Style);
652 p.setStrokeWidth(10);
653 std::string str("Type ");
654 str += SkRRect::kEmpty_Type == rrect2.type() ? "=" : "!";
655 str += "= SkRRect::kEmpty_Type";
656 canvas->drawString(str.c_str(), 20, 80, SkPaint());
657 canvas->drawRRect(rrect2, p);
Cary Clark224c7002018-06-27 11:00:21 -0400658##
659
Cary Clark82f1f742018-06-28 08:50:35 -0400660#SeeAlso SkRRect() SkRect::MakeEmpty
Cary Clark224c7002018-06-27 11:00:21 -0400661
662#Method ##
663
664# ------------------------------------------------------------------------------
665
666#Method static SkRRect MakeRect(const SkRect& r)
667#In Constructor
Cary Clark82f1f742018-06-28 08:50:35 -0400668#Line # copies bounds and zeroes corner radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400669
Cary Clark82f1f742018-06-28 08:50:35 -0400670Initializes to copy of r bounds and zeroes corner radii.
Cary Clark224c7002018-06-27 11:00:21 -0400671
Cary Clark82f1f742018-06-28 08:50:35 -0400672#Param r bounds to copy ##
673
674#Return copy of r ##
Cary Clark224c7002018-06-27 11:00:21 -0400675
676#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400677#Height 70
678 SkPaint paint;
679 SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
680 canvas->drawRRect(rrect, paint);
681 rrect.setOval(rrect.getBounds());
682 paint.setColor(SK_ColorBLUE);
683 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400684##
685
Cary Clark82f1f742018-06-28 08:50:35 -0400686#SeeAlso setRect MakeOval MakeRectXY
Cary Clark224c7002018-06-27 11:00:21 -0400687
688#Method ##
689
690# ------------------------------------------------------------------------------
691
692#Method static SkRRect MakeOval(const SkRect& oval)
Cary Clark82f1f742018-06-28 08:50:35 -0400693#In Constructor
694#Line # creates Oval to fit bounds ##
Cary Clark224c7002018-06-27 11:00:21 -0400695
Cary Clark82f1f742018-06-28 08:50:35 -0400696Sets bounds to oval, x-axis radii to half oval.width(), and all y-axis radii
697to half oval.height(). If rect is empty, sets to kEmpty_Type.
698Otherwise, sets to kOval_Type.
Cary Clark224c7002018-06-27 11:00:21 -0400699
Cary Clark82f1f742018-06-28 08:50:35 -0400700#Param oval bounds of Oval ##
701
702#Return Oval ##
Cary Clark224c7002018-06-27 11:00:21 -0400703
704#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400705#Height 70
706 SkPaint paint;
707 SkRRect rrect = SkRRect::MakeOval({30, 10, 100, 60});
708 canvas->drawRRect(rrect, paint);
709 rrect.setRect(rrect.getBounds());
710 paint.setColor(SK_ColorBLUE);
711 paint.setBlendMode(SkBlendMode::kDifference);
712 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400713##
714
Cary Clark82f1f742018-06-28 08:50:35 -0400715#SeeAlso setOval MakeRect MakeRectXY
Cary Clark224c7002018-06-27 11:00:21 -0400716
717#Method ##
718
719# ------------------------------------------------------------------------------
720
721#Method static SkRRect MakeRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad)
Cary Clark82f1f742018-06-28 08:50:35 -0400722#In Constructor
723#Line # creates rounded rectangle ##
Cary Clark224c7002018-06-27 11:00:21 -0400724
Cary Clark82f1f742018-06-28 08:50:35 -0400725Sets to rounded rectangle with the same radii for all four corners.
726If rect is empty, sets to kEmpty_Type.
727Otherwise, if xRad and yRad are zero, sets to kRect_Type.
728Otherwise, if xRad is at least half rect.width() and yRad is at least half
729rect.height(), sets to kOval_Type.
730Otherwise, sets to kSimple_Type.
Cary Clark224c7002018-06-27 11:00:21 -0400731
Cary Clark82f1f742018-06-28 08:50:35 -0400732#Param rect bounds of rounded rectangle ##
733#Param xRad x-axis radius of corners ##
734#Param yRad y-axis radius of corners ##
735
736#Return rounded rectangle ##
Cary Clark224c7002018-06-27 11:00:21 -0400737
738#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400739#Height 70
740 SkPaint paint;
741 SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 20, 20);
742 canvas->drawRRect(rrect, paint);
743 rrect.setRect(rrect.getBounds());
744 paint.setColor(SK_ColorBLUE);
745 paint.setBlendMode(SkBlendMode::kModulate);
746 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400747##
748
Cary Clark82f1f742018-06-28 08:50:35 -0400749#SeeAlso setRectXY
Cary Clark224c7002018-06-27 11:00:21 -0400750
751#Method ##
752
753# ------------------------------------------------------------------------------
754
755#Method void setOval(const SkRect& oval)
Cary Clark82f1f742018-06-28 08:50:35 -0400756#In Set
757#Line # replaces with Oval to fit bounds ##
Cary Clark224c7002018-06-27 11:00:21 -0400758
Cary Clark82f1f742018-06-28 08:50:35 -0400759Sets bounds to oval, x-axis radii to half oval.width(), and all y-axis radii
760to half oval.height(). If rect is empty, sets to kEmpty_Type.
761Otherwise, sets to kOval_Type.
Cary Clark224c7002018-06-27 11:00:21 -0400762
Cary Clark82f1f742018-06-28 08:50:35 -0400763#Param oval bounds of Oval ##
Cary Clark224c7002018-06-27 11:00:21 -0400764
765#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400766#Height 70
767 SkPaint paint;
768 SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 20, 20);
769 canvas->drawRRect(rrect, paint);
770 rrect.setOval(rrect.getBounds());
771 paint.setColor(SK_ColorWHITE);
772 paint.setBlendMode(SkBlendMode::kExclusion);
773 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400774##
775
Cary Clark82f1f742018-06-28 08:50:35 -0400776#SeeAlso MakeOval
Cary Clark224c7002018-06-27 11:00:21 -0400777
778#Method ##
779
780# ------------------------------------------------------------------------------
781
782#Method void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad)
Cary Clark82f1f742018-06-28 08:50:35 -0400783#In Set
784#Line # replaces with rounded rectangle ##
Cary Clark224c7002018-06-27 11:00:21 -0400785
Cary Clark82f1f742018-06-28 08:50:35 -0400786Sets to rounded rectangle with the same radii for all four corners.
787If rect is empty, sets to kEmpty_Type.
788Otherwise, if xRad or yRad is zero, sets to kRect_Type.
789Otherwise, if xRad is at least half rect.width() and yRad is at least half
790rect.height(), sets to kOval_Type.
791Otherwise, sets to kSimple_Type.
Cary Clark224c7002018-06-27 11:00:21 -0400792
Cary Clark82f1f742018-06-28 08:50:35 -0400793#Param rect bounds of rounded rectangle ##
794#Param xRad x-axis radius of corners ##
795#Param yRad y-axis radius of corners ##
Cary Clark224c7002018-06-27 11:00:21 -0400796
797#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400798#Height 70
799 SkPaint paint;
800 SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 20, 20);
801 canvas->drawRRect(rrect, paint);
802 rrect.setRectXY(rrect.getBounds(), 5, 5);
803 paint.setColor(SK_ColorWHITE);
804 paint.setBlendMode(SkBlendMode::kExclusion);
805 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400806##
807
Cary Clark82f1f742018-06-28 08:50:35 -0400808#SeeAlso MakeRectXY SkPath::addRoundRect
Cary Clark224c7002018-06-27 11:00:21 -0400809
810#Method ##
811
812# ------------------------------------------------------------------------------
813
814#Method void setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad,
815 SkScalar rightRad, SkScalar bottomRad)
Cary Clark82f1f742018-06-28 08:50:35 -0400816#In Set
817#Line # replaces with rounded rectangle ##
Cary Clark224c7002018-06-27 11:00:21 -0400818
Cary Clark82f1f742018-06-28 08:50:35 -0400819Sets bounds to rect. Sets radii to (leftRad, topRad), (rightRad, topRad),
820(rightRad, bottomRad), (leftRad, bottomRad).
Cary Clark224c7002018-06-27 11:00:21 -0400821
Cary Clark82f1f742018-06-28 08:50:35 -0400822If rect is empty, sets to kEmpty_Type.
823Otherwise, if leftRad and rightRad are zero, sets to kRect_Type.
824Otherwise, if topRad and bottomRad are zero, sets to kRect_Type.
825Otherwise, if leftRad and rightRad are equal and at least half rect.width(), and
826topRad and bottomRad are equal at least half rect.height(), sets to kOval_Type.
827Otherwise, if leftRad and rightRad are equal, and topRad and bottomRad are equal,
828sets to kSimple_Type. Otherwise, sets to kNinePatch_Type.
829
830Nine patch refers to the nine parts defined by the radii: one center rectangle,
831four edge patches, and four corner patches.
832
833#Param rect bounds of rounded rectangle ##
834#Param leftRad left-top and left-bottom x-axis radius ##
835#Param topRad left-top and right-top y-axis radius ##
836#Param rightRad right-top and right-bottom x-axis radius ##
837#Param bottomRad left-bottom and right-bottom y-axis radius ##
Cary Clark224c7002018-06-27 11:00:21 -0400838
839#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400840#Height 70
841 SkPaint paint;
842 paint.setAntiAlias(true);
843 SkRRect rrect;
844 rrect.setNinePatch({30, 10, 100, 60}, 10, 20, 20, 10);
845 canvas->drawRRect(rrect, paint);
846 paint.setColor(SK_ColorWHITE);
847 const SkRect r = rrect.getBounds();
848 canvas->drawLine(r.fLeft, r.fTop + rrect.radii(SkRRect::kUpperLeft_Corner).fY,
849 r.fRight, r.fTop + rrect.radii(SkRRect::kUpperRight_Corner).fY, paint);
850 canvas->drawLine(r.fLeft, r.fBottom - rrect.radii(SkRRect::kLowerLeft_Corner).fY,
851 r.fRight, r.fBottom - rrect.radii(SkRRect::kLowerRight_Corner).fY, paint);
852 canvas->drawLine(r.fLeft + rrect.radii(SkRRect::kUpperLeft_Corner).fX, r.fTop,
853 r.fLeft + rrect.radii(SkRRect::kLowerLeft_Corner).fX, r.fBottom, paint);
854 canvas->drawLine(r.fRight - rrect.radii(SkRRect::kUpperRight_Corner).fX, r.fTop,
855 r.fRight - rrect.radii(SkRRect::kLowerRight_Corner).fX, r.fBottom, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400856##
857
Cary Clark82f1f742018-06-28 08:50:35 -0400858#SeeAlso setRectRadii
Cary Clark224c7002018-06-27 11:00:21 -0400859
860#Method ##
861
862# ------------------------------------------------------------------------------
863
864#Method void setRectRadii(const SkRect& rect, const SkVector radii[4])
Cary Clark82f1f742018-06-28 08:50:35 -0400865#In Set
866#Line # replaces with rounded rectangle ##
Cary Clark224c7002018-06-27 11:00:21 -0400867
Cary Clark82f1f742018-06-28 08:50:35 -0400868Sets bounds to rect. Sets radii array for individual control of all for corners.
Cary Clark224c7002018-06-27 11:00:21 -0400869
Cary Clark82f1f742018-06-28 08:50:35 -0400870If rect is empty, sets to kEmpty_Type.
871Otherwise, if one of each corner radii are zero, sets to kRect_Type.
872Otherwise, if all x-axis radii are equal and at least half rect.width(), and
873all y-axis radii are equal at least half rect.height(), sets to kOval_Type.
874Otherwise, if all x-axis radii are equal, and all y-axis radii are equal,
875sets to kSimple_Type. Otherwise, sets to kNinePatch_Type.
876
877#Param rect bounds of rounded rectangle ##
878#Param radii corner x-axis and y-axis radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400879
880#Example
Cary Clark53498e92018-06-28 19:13:56 -0400881 SkPaint paint;
882 paint.setStrokeWidth(15);
883 paint.setStrokeCap(SkPaint::kSquare_Cap);
884 paint.setAntiAlias(true);
885 float intervals[] = { 5, 21.75f };
886 paint.setStyle(SkPaint::kStroke_Style);
887 paint.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
888 SkPath path;
889 SkRRect rrect;
890 SkVector corners[] = {{15, 17}, {17, 19}, {19, 15}, {15, 15}};
891 rrect.setRectRadii({20, 20, 100, 100}, corners);
892 path.addRRect(rrect, SkPath::kCW_Direction);
893 canvas->drawPath(path, paint);
894 path.rewind();
895 path.addRRect(rrect, SkPath::kCCW_Direction, 1);
896 canvas->translate(120, 0);
897 canvas->drawPath(path, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400898##
899
Cary Clark82f1f742018-06-28 08:50:35 -0400900#SeeAlso setNinePatch SkPath::addRoundRect
Cary Clark224c7002018-06-27 11:00:21 -0400901
902#Method ##
903
904# ------------------------------------------------------------------------------
905
906#Enum Corner
Cary Clark53498e92018-06-28 19:13:56 -0400907#Line # corner radii order ##
Cary Clark224c7002018-06-27 11:00:21 -0400908
909#Code
910 enum Corner {
911 kUpperLeft_Corner,
912 kUpperRight_Corner,
913 kLowerRight_Corner,
914 kLowerLeft_Corner,
915 };
916##
917
918The radii are stored: top-left, top-right, bottom-right, bottom-left.
919
Cary Clark53498e92018-06-28 19:13:56 -0400920#Const kUpperLeft_Corner 0
921#Line # index of top-left corner radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400922##
Cary Clark53498e92018-06-28 19:13:56 -0400923#Const kUpperRight_Corner 1
924#Line # index of top-right corner radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400925##
Cary Clark53498e92018-06-28 19:13:56 -0400926#Const kLowerRight_Corner 2
927#Line # index of bottom-right corner radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400928##
Cary Clark53498e92018-06-28 19:13:56 -0400929#Const kLowerLeft_Corner 3
930#Line # index of bottom-left corner radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400931##
932
933#Example
Cary Clark53498e92018-06-28 19:13:56 -0400934#Height 70
935 SkPaint paint;
936 paint.setAntiAlias(true);
937 SkRRect rrect;
938 SkVector corners[] = {{25, 17}, {17, 19}, {19, 15}, {15, 15}};
939 rrect.setRectRadii({30, 10, 100, 60}, corners);
940 canvas->drawRRect(rrect, paint);
941 paint.setColor(SK_ColorWHITE);
942 const SkRect r = rrect.getBounds();
943 canvas->drawLine(r.fLeft, r.fTop + rrect.radii(SkRRect::kUpperLeft_Corner).fY,
944 r.fRight, r.fTop + rrect.radii(SkRRect::kUpperRight_Corner).fY, paint);
945 canvas->drawLine(r.fLeft, r.fBottom - rrect.radii(SkRRect::kLowerLeft_Corner).fY,
946 r.fRight, r.fBottom - rrect.radii(SkRRect::kLowerRight_Corner).fY, paint);
947 canvas->drawLine(r.fLeft + rrect.radii(SkRRect::kUpperLeft_Corner).fX, r.fTop,
948 r.fLeft + rrect.radii(SkRRect::kLowerLeft_Corner).fX, r.fBottom, paint);
949 canvas->drawLine(r.fRight - rrect.radii(SkRRect::kUpperRight_Corner).fX, r.fTop,
950 r.fRight - rrect.radii(SkRRect::kLowerRight_Corner).fX, r.fBottom, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400951##
952
Cary Clark53498e92018-06-28 19:13:56 -0400953#SeeAlso radii
Cary Clark224c7002018-06-27 11:00:21 -0400954
955#Enum ##
956
957# ------------------------------------------------------------------------------
958
959#Method const SkRect& rect() const
Cary Clark53498e92018-06-28 19:13:56 -0400960#In Property
961#Line # returns bounds ##
962Returns bounds. Bounds may have zero width or zero height. Bounds right is
963greater than or equal to left; bounds bottom is greater than or equal to top.
964Result is identical to getBounds.
Cary Clark224c7002018-06-27 11:00:21 -0400965
Cary Clark53498e92018-06-28 19:13:56 -0400966#Return bounding box ##
Cary Clark224c7002018-06-27 11:00:21 -0400967
968#Example
Cary Clark53498e92018-06-28 19:13:56 -0400969 for (SkScalar left : { SK_ScalarNaN, SK_ScalarInfinity, 100.f, 50.f, 25.f} ) {
970 SkRRect rrect1 = SkRRect::MakeRectXY({left, 20, 60, 220}, 50, 200);
971 SkDebugf("left bounds: (%g) %g\n", left, rrect1.rect().fLeft);
972 }
973#StdOut
974left bounds: (nan) 0
975left bounds: (inf) 0
976left bounds: (100) 60
977left bounds: (50) 50
978left bounds: (25) 25
979##
Cary Clark224c7002018-06-27 11:00:21 -0400980##
981
Cary Clark53498e92018-06-28 19:13:56 -0400982#SeeAlso getBounds
Cary Clark224c7002018-06-27 11:00:21 -0400983
984#Method ##
985
986# ------------------------------------------------------------------------------
987
988#Method SkVector radii(Corner corner) const
Cary Clark53498e92018-06-28 19:13:56 -0400989#In Property
990#Line # returns x-axis and y-axis radii for one corner ##
991Returns Scalar pair for radius of curve on x-axis and y-axis for one corner.
992Both radii may be zero. If not zero, both are positive and finite.
Cary Clark224c7002018-06-27 11:00:21 -0400993
Cary Clark224c7002018-06-27 11:00:21 -0400994
Cary Clark53498e92018-06-28 19:13:56 -0400995#Param corner one of: kUpperLeft_Corner, kUpperRight_Corner,
996 kLowerRight_Corner, kLowerLeft_Corner
Cary Clark224c7002018-06-27 11:00:21 -0400997##
998
Cary Clark53498e92018-06-28 19:13:56 -0400999#Return x-axis and y-axis radii for one corner ##
1000
1001#Example
1002#Description
1003Finite values are scaled proportionately to fit; other values are set to zero.
1004Scaled values cannot be larger than 25, half the bounding rect width.
1005Small scaled values are halved to scale in proportion to the y-axis corner
1006radius, which is twice the bounds height.
1007##
1008 for (SkScalar radiusX : { SK_ScalarNaN, SK_ScalarInfinity, 100.f, 50.f, 25.f} ) {
1009 SkRRect rrect1 = SkRRect::MakeRectXY({10, 20, 60, 220}, radiusX, 200);
1010 SkDebugf("left corner: (%g) %g\n", radiusX, rrect1.radii(SkRRect::kUpperLeft_Corner).fX);
1011 }
1012#StdOut
1013left corner: (nan) 0
1014left corner: (inf) 0
1015left corner: (100) 25
1016left corner: (50) 25
1017left corner: (25) 12.5
1018##
1019##
1020
1021#SeeAlso Corner
Cary Clark224c7002018-06-27 11:00:21 -04001022
1023#Method ##
1024
1025# ------------------------------------------------------------------------------
1026
1027#Method const SkRect& getBounds() const
Cary Clark53498e92018-06-28 19:13:56 -04001028#In Property
1029#Line # returns bounds ##
1030Returns bounds. Bounds may have zero width or zero height. Bounds right is
1031greater than or equal to left; bounds bottom is greater than or equal to top.
1032Result is identical to rect().
Cary Clark224c7002018-06-27 11:00:21 -04001033
Cary Clark53498e92018-06-28 19:13:56 -04001034#Return bounding box ##
Cary Clark224c7002018-06-27 11:00:21 -04001035
1036#Example
Cary Clark53498e92018-06-28 19:13:56 -04001037#Height 120
1038 SkPaint paint;
1039 SkRRect rrect = SkRRect::MakeRectXY({20, 20, 220, 100}, 15, 15);
1040 canvas->drawRRect(rrect, paint);
1041 paint.setColor(SK_ColorWHITE);
1042 rrect = SkRRect::MakeOval(rrect.getBounds());
1043 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -04001044##
1045
Cary Clark53498e92018-06-28 19:13:56 -04001046#SeeAlso rect
Cary Clark224c7002018-06-27 11:00:21 -04001047
1048#Method ##
1049
1050# ------------------------------------------------------------------------------
1051
1052#Method bool operator==(const SkRRect& a, const SkRRect& b)
1053#In Operator
Cary Clark53498e92018-06-28 19:13:56 -04001054#Line # returns true if members are equal ##
1055Returns true if bounds and radii in a are equal to bounds and radii in b.
Cary Clark224c7002018-06-27 11:00:21 -04001056
Cary Clark53498e92018-06-28 19:13:56 -04001057a and b are not equal if either contain NaN. a and b are equal if members
1058contain zeroes width different signs.
Cary Clark224c7002018-06-27 11:00:21 -04001059
Cary Clark53498e92018-06-28 19:13:56 -04001060#Param a Rect bounds and radii to compare ##
1061#Param b Rect bounds and radii to compare ##
1062
1063#Return true if members are equal ##
Cary Clark224c7002018-06-27 11:00:21 -04001064
1065#Example
Cary Clark53498e92018-06-28 19:13:56 -04001066 SkRRect rrect1 = SkRRect::MakeRectXY({10, 20, 60, 220}, 50, 200);
1067 SkRRect rrect2 = SkRRect::MakeRectXY(rrect1.rect(), 25, 100);
1068 SkRRect rrect3 = SkRRect::MakeOval(rrect1.rect());
1069 canvas->drawRRect(rrect1, SkPaint());
1070 std::string str = "rrect1 " + std::string(rrect1 == rrect2 ? "=" : "!") + "= rrect2";
1071 canvas->drawString(str.c_str(), 10, 240, SkPaint());
1072 canvas->translate(70, 0);
1073 canvas->drawRRect(rrect2, SkPaint());
1074 canvas->translate(70, 0);
1075 canvas->drawRRect(rrect3, SkPaint());
1076 str = "rrect2 " + std::string(rrect2 == rrect3 ? "=" : "!") + "= rrect3";
1077 canvas->drawString(str.c_str(), -20, 240, SkPaint());
Cary Clark224c7002018-06-27 11:00:21 -04001078##
1079
Cary Clark53498e92018-06-28 19:13:56 -04001080#SeeAlso operator!=(const SkRRect& a, const SkRRect& b)
Cary Clark224c7002018-06-27 11:00:21 -04001081
1082#Method ##
1083
1084# ------------------------------------------------------------------------------
1085
1086#Method bool operator!=(const SkRRect& a, const SkRRect& b)
1087#In Operator
Cary Clark53498e92018-06-28 19:13:56 -04001088#Line # returns true if members are unequal ##
1089Returns true if bounds and radii in a are not equal to bounds and radii in b.
Cary Clark224c7002018-06-27 11:00:21 -04001090
Cary Clark53498e92018-06-28 19:13:56 -04001091a and b are not equal if either contain NaN. a and b are equal if members
1092contain zeroes width different signs.
Cary Clark224c7002018-06-27 11:00:21 -04001093
Cary Clark53498e92018-06-28 19:13:56 -04001094#Param a Rect bounds and radii to compare ##
1095#Param b Rect bounds and radii to compare ##
1096
1097#Return true if members are not equal ##
Cary Clark224c7002018-06-27 11:00:21 -04001098
1099#Example
Cary Clark53498e92018-06-28 19:13:56 -04001100 SkRRect rrect1 = SkRRect::MakeRectXY({10, 20, 60, 220}, 50, 100);
1101 SkRRect rrect2 = SkRRect::MakeRectXY(rrect1.rect(), 50, 50);
1102 SkRRect rrect3 = SkRRect::MakeOval(rrect1.rect());
1103 canvas->drawRRect(rrect1, SkPaint());
1104 std::string str = "rrect1 " + std::string(rrect1 == rrect2 ? "=" : "!") + "= rrect2";
1105 canvas->drawString(str.c_str(), 10, 240, SkPaint());
1106 canvas->translate(70, 0);
1107 canvas->drawRRect(rrect2, SkPaint());
1108 canvas->translate(70, 0);
1109 canvas->drawRRect(rrect3, SkPaint());
1110 str = "rrect2 " + std::string(rrect2 == rrect3 ? "=" : "!") + "= rrect3";
1111 canvas->drawString(str.c_str(), -20, 240, SkPaint());
Cary Clark224c7002018-06-27 11:00:21 -04001112##
1113
Cary Clark53498e92018-06-28 19:13:56 -04001114#SeeAlso operator==(const SkRRect& a, const SkRRect& b)
Cary Clark224c7002018-06-27 11:00:21 -04001115
1116#Method ##
1117
1118# ------------------------------------------------------------------------------
1119
1120#Method void inset(SkScalar dx, SkScalar dy, SkRRect* dst) const
Cary Clark53498e92018-06-28 19:13:56 -04001121#In Inset_Outset_Offset
1122#Line # insets bounds and radii ##
Cary Clark224c7002018-06-27 11:00:21 -04001123
1124Calls inset on the bounds, and adjust the radii to reflect what happens.
1125If the corner is sharp (no curvature), leave it alone,
1126otherwise we grow/shrink the radii by the amount of the inset. If a
1127given radius becomes negative, it is pinned to 0.
1128If the inset amount is larger than the width/height then the rrect collapses to
1129a degenerate line or point.
1130If the inset is sufficiently negative to cause the bounds to become infinite then
1131the result is a default initialized rrect.
1132It is valid for dst == this.
1133
Cary Clark53498e92018-06-28 19:13:56 -04001134#Param dx added to rect().fLeft, and subtracted from rect().fRight ##
1135#Param dy added to rect().fTop, and subtracted from rect().fBottom ##
1136#Param dst insets bounds and radii ##
Cary Clark224c7002018-06-27 11:00:21 -04001137
1138#Example
Cary Clark53498e92018-06-28 19:13:56 -04001139 SkPaint paint;
1140 paint.setAntiAlias(true);
1141 paint.setStyle(SkPaint::kStroke_Style);
1142 SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
1143 for (int index = 0; index < 25; ++index) {
1144 canvas->drawRRect(rrect, paint);
1145 rrect.inset(-3, 3, &rrect);
1146 }
Cary Clark224c7002018-06-27 11:00:21 -04001147##
1148
Cary Clark53498e92018-06-28 19:13:56 -04001149#SeeAlso outset offset makeOffset
Cary Clark224c7002018-06-27 11:00:21 -04001150
1151#Method ##
1152
1153# ------------------------------------------------------------------------------
1154
1155#Method void inset(SkScalar dx, SkScalar dy)
Cary Clark53498e92018-06-28 19:13:56 -04001156#In Inset_Outset_Offset
1157#Line # insets bounds and radii ##
Cary Clark224c7002018-06-27 11:00:21 -04001158
Cary Clark53498e92018-06-28 19:13:56 -04001159#Param dx added to rect().fLeft, and subtracted from rect().fRight ##
1160#Param dy added to rect().fTop, and subtracted from rect().fBottom ##
Cary Clark224c7002018-06-27 11:00:21 -04001161
1162#Example
Cary Clark53498e92018-06-28 19:13:56 -04001163 SkPaint paint;
1164 paint.setAntiAlias(true);
1165 paint.setStyle(SkPaint::kStroke_Style);
1166 SkRRect rrect = SkRRect::MakeRectXY({10, 20, 180, 220}, 50, 100);
1167 for (int index = 0; index < 25; ++index) {
1168 canvas->drawRRect(rrect, paint);
1169 rrect.inset(3, 3);
1170 }
Cary Clark224c7002018-06-27 11:00:21 -04001171##
1172
Cary Clark53498e92018-06-28 19:13:56 -04001173#SeeAlso outset offset makeOffset
1174
Cary Clark224c7002018-06-27 11:00:21 -04001175
1176#Method ##
1177
1178# ------------------------------------------------------------------------------
1179
1180#Method void outset(SkScalar dx, SkScalar dy, SkRRect* dst) const
Cary Clark53498e92018-06-28 19:13:56 -04001181#In Inset_Outset_Offset
1182#Line # outsets bounds and radii ##
Cary Clark224c7002018-06-27 11:00:21 -04001183
1184Call outset on the bounds, and adjust the radii to reflect what happens
1185in stroking. If the corner is sharp (no curvature), leave it alone,
1186otherwise we grow/shrink the radii by the amount of the inset. If a
1187given radius becomes negative, it is pinned to 0.
1188It is valid for dst == this.
1189
Cary Clark53498e92018-06-28 19:13:56 -04001190#Param dx subtracted from rect().fLeft, and added to rect().fRight ##
1191#Param dy subtracted from rect().fTop, and added to rect().fBottom ##
1192#Param dst outset bounds and radii ##
Cary Clark224c7002018-06-27 11:00:21 -04001193
1194#Example
Cary Clark53498e92018-06-28 19:13:56 -04001195 SkPaint paint;
1196 paint.setAntiAlias(true);
1197 paint.setStyle(SkPaint::kStroke_Style);
1198 SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
1199 for (int index = 0; index < 25; ++index) {
1200 canvas->drawRRect(rrect, paint);
1201 rrect.outset(-3, 3, &rrect);
1202 }
Cary Clark224c7002018-06-27 11:00:21 -04001203##
1204
Cary Clark53498e92018-06-28 19:13:56 -04001205#SeeAlso inset offset makeOffset
1206
Cary Clark224c7002018-06-27 11:00:21 -04001207
1208#Method ##
1209
1210# ------------------------------------------------------------------------------
1211
1212#Method void outset(SkScalar dx, SkScalar dy)
Cary Clark53498e92018-06-28 19:13:56 -04001213#In Inset_Outset_Offset
1214#Line # outsets bounds and radii ##
Cary Clark224c7002018-06-27 11:00:21 -04001215
Cary Clark53498e92018-06-28 19:13:56 -04001216#Param dx subtracted from rect().fLeft, and added to rect().fRight ##
1217#Param dy subtracted from rect().fTop, and added to rect().fBottom ##
Cary Clark224c7002018-06-27 11:00:21 -04001218
1219#Example
Cary Clark53498e92018-06-28 19:13:56 -04001220 SkPaint paint;
1221 paint.setAntiAlias(true);
1222 paint.setStyle(SkPaint::kStroke_Style);
1223 SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
1224 for (int index = 0; index < 25; ++index) {
1225 canvas->drawRRect(rrect, paint);
1226 rrect.outset(3, 3);
1227 }
Cary Clark224c7002018-06-27 11:00:21 -04001228##
1229
Cary Clark53498e92018-06-28 19:13:56 -04001230#SeeAlso inset offset makeOffset
Cary Clark224c7002018-06-27 11:00:21 -04001231
1232#Method ##
1233
1234# ------------------------------------------------------------------------------
1235
1236#Method void offset(SkScalar dx, SkScalar dy)
Cary Clark53498e92018-06-28 19:13:56 -04001237#In Inset_Outset_Offset
1238#Line # offsets bounds and radii ##
Cary Clark224c7002018-06-27 11:00:21 -04001239
Cary Clark53498e92018-06-28 19:13:56 -04001240Translates the rrect by (dx, dy).
Cary Clark224c7002018-06-27 11:00:21 -04001241
Cary Clark53498e92018-06-28 19:13:56 -04001242#Param dx offset added to rect().fLeft and rect().fRight ##
1243#Param dy offset added to rect().fTop and rect().fBottom ##
Cary Clark224c7002018-06-27 11:00:21 -04001244
1245#Example
Cary Clark53498e92018-06-28 19:13:56 -04001246 SkPaint paint;
1247 paint.setAntiAlias(true);
1248 paint.setStyle(SkPaint::kStroke_Style);
1249 SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
1250 for (int index = 0; index < 25; ++index) {
1251 canvas->drawRRect(rrect, paint);
1252 rrect.offset(3, 3);
1253 }
Cary Clark224c7002018-06-27 11:00:21 -04001254##
1255
Cary Clark53498e92018-06-28 19:13:56 -04001256#SeeAlso makeOffset inset outset
Cary Clark224c7002018-06-27 11:00:21 -04001257
1258#Method ##
1259
1260# ------------------------------------------------------------------------------
1261
1262#Method SkRRect SK_WARN_UNUSED_RESULT makeOffset(SkScalar dx, SkScalar dy) const
Cary Clark53498e92018-06-28 19:13:56 -04001263#In Inset_Outset_Offset
1264#Line # offsets bounds and radii ##
Cary Clark224c7002018-06-27 11:00:21 -04001265
Cary Clark53498e92018-06-28 19:13:56 -04001266#Param dx offset added to rect().fLeft and rect().fRight ##
1267#Param dy offset added to rect().fTop and rect().fBottom ##
Cary Clark224c7002018-06-27 11:00:21 -04001268
Cary Clark53498e92018-06-28 19:13:56 -04001269#Return Round_Rect bounds offset by (dx, dy), with unchanged corner radii ##
Cary Clark224c7002018-06-27 11:00:21 -04001270
1271#Example
Cary Clark53498e92018-06-28 19:13:56 -04001272 SkPaint paint;
1273 paint.setAntiAlias(true);
1274 paint.setStyle(SkPaint::kStroke_Style);
1275 SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
1276 for (int index = 0; index < 25; ++index) {
1277 canvas->drawRRect(rrect, paint);
1278 rrect = rrect.makeOffset(-3, 3);
1279 }
Cary Clark224c7002018-06-27 11:00:21 -04001280##
1281
Cary Clark53498e92018-06-28 19:13:56 -04001282#SeeAlso offset inset outset
Cary Clark224c7002018-06-27 11:00:21 -04001283
1284#Method ##
1285
1286# ------------------------------------------------------------------------------
1287
1288#Method bool contains(const SkRect& rect) const
Cary Clark53498e92018-06-28 19:13:56 -04001289#In Intersection
1290#Line # returns true if Rect is inside ##
Cary Clark224c7002018-06-27 11:00:21 -04001291
Cary Clark53498e92018-06-28 19:13:56 -04001292Returns true if rect is inside the bounds and corner radii, and if
1293Round_Rect and rect are not empty.
Cary Clark224c7002018-06-27 11:00:21 -04001294
Cary Clark53498e92018-06-28 19:13:56 -04001295#Param rect area tested for containment ##
Cary Clark224c7002018-06-27 11:00:21 -04001296
Cary Clark53498e92018-06-28 19:13:56 -04001297#Return true if Round_Rect contains rect ##
Cary Clark224c7002018-06-27 11:00:21 -04001298
1299#Example
1300// incomplete
1301##
1302
Cary Clark53498e92018-06-28 19:13:56 -04001303#SeeAlso SkRect::contains
Cary Clark224c7002018-06-27 11:00:21 -04001304
1305#Method ##
1306
1307# ------------------------------------------------------------------------------
1308
1309#Method bool isValid() const
Cary Clark53498e92018-06-28 19:13:56 -04001310#In Utility
Cary Clark224c7002018-06-27 11:00:21 -04001311#Line # incomplete ##
1312
1313#Return incomplete ##
1314
1315#Example
1316// incomplete
1317##
1318
1319#SeeAlso incomplete
1320
1321#Method ##
1322
1323# ------------------------------------------------------------------------------
1324
1325#Const kSizeInMemory 48
1326#Line # incomplete ##
1327
1328#Example
1329// incomplete
1330##
1331
1332#Const ##
1333
1334# ------------------------------------------------------------------------------
1335
1336#Method size_t writeToMemory(void* buffer) const
Cary Clark53498e92018-06-28 19:13:56 -04001337#In Utility
Cary Clark224c7002018-06-27 11:00:21 -04001338#Line # incomplete ##
1339
1340Write the rrect into the specified buffer. This is guaranteed to always
1341write kSizeInMemory bytes, and that value is guaranteed to always be
1342a multiple of 4. Return kSizeInMemory.
1343
1344#Param buffer incomplete ##
1345
1346#Return incomplete ##
1347
1348#Example
1349// incomplete
1350##
1351
1352#SeeAlso incomplete
1353
1354#Method ##
1355
1356# ------------------------------------------------------------------------------
1357
1358#Method size_t readFromMemory(const void* buffer, size_t length)
Cary Clark53498e92018-06-28 19:13:56 -04001359#In Utility
Cary Clark224c7002018-06-27 11:00:21 -04001360#Line # incomplete ##
1361
1362Reads the rrect from the specified buffer.
1363If the specified buffer is large enough, this will read kSizeInMemory bytes,
1364and that value is guaranteed to always be a multiple of 4.
1365
1366#Param buffer memory to read from
1367##
1368#Param length amount of memory available in the buffer
1369##
1370
1371#Return number of bytes read (must be a multiple of 4) or
1372 0 if there was not enough memory available
1373##
1374
1375#Example
1376// incomplete
1377##
1378
1379#SeeAlso incomplete
1380
1381#Method ##
1382
1383# ------------------------------------------------------------------------------
1384
1385#Method bool transform(const SkMatrix& matrix, SkRRect* dst) const
Cary Clark53498e92018-06-28 19:13:56 -04001386#In Inset_Outset_Offset
1387#Line # scales and offsets into copy ##
Cary Clark224c7002018-06-27 11:00:21 -04001388
Cary Clark53498e92018-06-28 19:13:56 -04001389Transforms by Round_Rect by matrix, storing result in dst.
1390Returns true if Round_Rect transformed can be represented by another Round_Rect.
1391Returns false if matrix contains transformations other than scale and translate.
Cary Clark224c7002018-06-27 11:00:21 -04001392
Cary Clark53498e92018-06-28 19:13:56 -04001393Asserts in debug builds if Round_Rect equals dst.
Cary Clark224c7002018-06-27 11:00:21 -04001394
Cary Clark53498e92018-06-28 19:13:56 -04001395#Param matrix SkMatrix specifying the transform ##
1396#Param dst SkRRect to store the result ##
1397
1398#Return true if transformation succeeded.
Cary Clark224c7002018-06-27 11:00:21 -04001399##
1400
1401#Example
1402// incomplete
1403##
1404
1405#SeeAlso incomplete
1406
1407#Method ##
1408
1409# ------------------------------------------------------------------------------
1410
1411#Method void dump(bool asHex) const
Cary Clark53498e92018-06-28 19:13:56 -04001412#In Utility
1413#Line # sends text representation to standard output ##
1414Writes text representation of Round_Rect to standard output.
1415Set asHex true to generate exact binary representations
1416of floating point numbers.
Cary Clark224c7002018-06-27 11:00:21 -04001417
Cary Clark53498e92018-06-28 19:13:56 -04001418#Param asHex true if SkScalar values are written as hexadecimal ##
Cary Clark224c7002018-06-27 11:00:21 -04001419
1420#Example
Cary Clark53498e92018-06-28 19:13:56 -04001421SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
1422for (bool dumpAsHex : { false, true } ) {
1423 rrect.dump(dumpAsHex);
1424}
1425#StdOut
1426SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f);
1427const SkPoint corners[] = {
1428 { 0, 0 },
1429 { 0, 0 },
1430 { 0, 0 },
1431 { 0, 0 },
1432};
1433SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
1434 SkBits2Float(0x3f2aaaab), /* 0.666667 */
1435 SkBits2Float(0x3f5b6db7), /* 0.857143 */
1436 SkBits2Float(0x3f2aaaab) /* 0.666667 */);
1437const SkPoint corners[] = {
1438 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1439 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1440 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1441 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1442};
1443##
Cary Clark224c7002018-06-27 11:00:21 -04001444##
1445
Cary Clark53498e92018-06-28 19:13:56 -04001446#SeeAlso dumpHex SkRect::dump SkPath::dump SkPathMeasure::dump
Cary Clark224c7002018-06-27 11:00:21 -04001447
1448#Method ##
1449
1450# ------------------------------------------------------------------------------
1451
1452#Method void dump() const
Cary Clark53498e92018-06-28 19:13:56 -04001453#In Utility
1454#Line # sends text representation using floats to standard output ##
1455Writes text representation of Round_Rect to standard output. The representation
1456may be directly compiled as C++ code. Floating point values are written
1457with limited precision; it may not be possible to reconstruct original
1458Round_Rect from output.
Cary Clark224c7002018-06-27 11:00:21 -04001459
1460#Example
Cary Clark53498e92018-06-28 19:13:56 -04001461SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
1462rrect.dump();
1463SkRect bounds = SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f);
1464const SkPoint corners[] = {
1465 { 0, 0 },
1466 { 0, 0 },
1467 { 0, 0 },
1468 { 0, 0 },
1469};
1470SkRRect copy;
1471copy.setRectRadii(bounds, corners);
1472SkDebugf("rrect is " "%s" "equal to copy\n", rrect == copy ? "" : "not ");
1473#StdOut
1474SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f);
1475const SkPoint corners[] = {
1476 { 0, 0 },
1477 { 0, 0 },
1478 { 0, 0 },
1479 { 0, 0 },
1480};
1481rrect is not equal to copy
1482##
Cary Clark224c7002018-06-27 11:00:21 -04001483##
1484
Cary Clark53498e92018-06-28 19:13:56 -04001485#SeeAlso dumpHex SkRect::dump SkPath::dump SkPathMeasure::dump
Cary Clark224c7002018-06-27 11:00:21 -04001486
1487#Method ##
1488
1489# ------------------------------------------------------------------------------
1490
1491#Method void dumpHex() const
Cary Clark53498e92018-06-28 19:13:56 -04001492#In Utility
1493#Line # sends text representation using hexadecimal to standard output ##
1494Writes text representation of Round_Rect to standard output. The representation
1495may be directly compiled as C++ code. Floating point values are written
1496in hexadecimal to preserve their exact bit pattern. The output reconstructs the
1497original Round_Rect.
Cary Clark224c7002018-06-27 11:00:21 -04001498
1499#Example
Cary Clark53498e92018-06-28 19:13:56 -04001500SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
1501rrect.dumpHex();
1502SkRect bounds = SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
1503 SkBits2Float(0x3f2aaaab), /* 0.666667 */
1504 SkBits2Float(0x3f5b6db7), /* 0.857143 */
1505 SkBits2Float(0x3f2aaaab) /* 0.666667 */);
1506const SkPoint corners[] = {
1507 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1508 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1509 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1510 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1511};
1512SkRRect copy;
1513copy.setRectRadii(bounds, corners);
1514SkDebugf("rrect is " "%s" "equal to copy\n", rrect == copy ? "" : "not ");
1515#StdOut
1516SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
1517 SkBits2Float(0x3f2aaaab), /* 0.666667 */
1518 SkBits2Float(0x3f5b6db7), /* 0.857143 */
1519 SkBits2Float(0x3f2aaaab) /* 0.666667 */);
1520const SkPoint corners[] = {
1521 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1522 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1523 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1524 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1525};
1526rrect is equal to copy
1527##
Cary Clark224c7002018-06-27 11:00:21 -04001528##
1529
Cary Clark53498e92018-06-28 19:13:56 -04001530#SeeAlso dump SkRect::dumpHex SkPath::dumpHex
Cary Clark224c7002018-06-27 11:00:21 -04001531
1532#Method ##
1533
1534#Class SkRRect ##
1535
1536#Topic RRect ##