blob: 2136984f74000c15e990202472ad94599375ed1f [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
Cary Clark61313f32018-10-08 14:57:48 -04007#Code
8class SkRRect {
9public:
10 SkRRect() = default;
11 SkRRect(const SkRRect& rrect) = default;
12 SkRRect& operator=(const SkRRect& rrect) = default;
13
14 enum Type {
15 kEmpty_Type,
16 kRect_Type,
17 kOval_Type,
18 kSimple_Type,
19 kNinePatch_Type,
20 kComplex_Type,
21 kLastType = kComplex_Type,
22 };
23
24 Type getType() const;
25 Type type() const;
26 bool isEmpty() const;
27 bool isRect() const;
28 bool isOval() const;
29 bool isSimple() const;
30 bool isNinePatch() const;
31 bool isComplex() const;
32 SkScalar width() const;
33 SkScalar height() const;
34 SkVector getSimpleRadii() const;
35 void setEmpty();
36 void setRect(const SkRect& rect);
37 static SkRRect MakeEmpty();
38 static SkRRect MakeRect(const SkRect& r);
39 static SkRRect MakeOval(const SkRect& oval);
40 static SkRRect MakeRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad);
41 void setOval(const SkRect& oval);
42 void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad);
43 void setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad,
44 SkScalar rightRad, SkScalar bottomRad);
45 void setRectRadii(const SkRect& rect, const SkVector radii[4]);
46
47 enum Corner {
48 kUpperLeft_Corner,
49 kUpperRight_Corner,
50 kLowerRight_Corner,
51 kLowerLeft_Corner,
52 };
53
54 const SkRect& rect() const;
55 SkVector radii(Corner corner) const;
56 const SkRect& getBounds() const;
57 friend bool operator==(const SkRRect& a, const SkRRect& b);
58 friend bool operator!=(const SkRRect& a, const SkRRect& b);
59 void inset(SkScalar dx, SkScalar dy, SkRRect* dst) const;
60 void inset(SkScalar dx, SkScalar dy);
61 void outset(SkScalar dx, SkScalar dy, SkRRect* dst) const;
62 void outset(SkScalar dx, SkScalar dy);
63 void offset(SkScalar dx, SkScalar dy);
64 SkRRect makeOffset(SkScalar dx, SkScalar dy) const;
65 bool contains(const SkRect& rect) const;
66 bool isValid() const;
67
68 static constexpr size_t kSizeInMemory = 12 * sizeof(SkScalar);
69
70 size_t writeToMemory(void* buffer) const;
71 size_t readFromMemory(const void* buffer, size_t length);
72 bool transform(const SkMatrix& matrix, SkRRect* dst) const;
73 void dump(bool asHex) const;
74 void dump() const;
75 void dumpHex() const;
76};
77##
78
Cary Clark80247e52018-07-11 16:18:41 -040079SkRRect describes a rounded rectangle with a bounds and a pair of radii for each corner.
Cary Clarkf9603982018-07-17 08:20:27 -040080The bounds and radii can be set so that SkRRect describes: a rectangle with sharp corners;
81a Circle; an Oval; or a rectangle with one or more rounded corners.
Cary Clark224c7002018-06-27 11:00:21 -040082
Cary Clark80247e52018-07-11 16:18:41 -040083SkRRect allows implementing CSS properties that describe rounded corners.
84SkRRect may have up to eight different radii, one for each axis on each of its four
Cary Clark224c7002018-06-27 11:00:21 -040085corners.
86
Cary Clark80247e52018-07-11 16:18:41 -040087SkRRect may modify the provided parameters when initializing bounds and radii.
Cary Clarkf9603982018-07-17 08:20:27 -040088If either axis radii is zero or less: radii are stored as zero; corner is square.
Cary Clark80247e52018-07-11 16:18:41 -040089If corner curves overlap, radii are proportionally reduced to fit within bounds.
Cary Clark224c7002018-06-27 11:00:21 -040090
Cary Clark224c7002018-06-27 11:00:21 -040091# ------------------------------------------------------------------------------
92
Cary Clark82f1f742018-06-28 08:50:35 -040093#Method SkRRect()
Cary Clark61313f32018-10-08 14:57:48 -040094#In Constructors
Cary Clark82f1f742018-06-28 08:50:35 -040095#Line # creates with zeroed bounds and corner radii ##
Cary Clark09d80c02018-10-31 12:14:03 -040096#Populate
Cary Clark224c7002018-06-27 11:00:21 -040097
98#Example
Cary Clark82f1f742018-06-28 08:50:35 -040099#Height 60
Cary Clark09d80c02018-10-31 12:14:03 -0400100 SkRRect rrect;
101 SkPaint p;
102 p.setStyle(SkPaint::kStroke_Style);
103 p.setStrokeWidth(10);
104 canvas->drawRRect(rrect, p);
105 rrect.setRect({10, 10, 100, 50});
106 canvas->drawRRect(rrect, p);
Cary Clark224c7002018-06-27 11:00:21 -0400107##
108
Cary Clark82f1f742018-06-28 08:50:35 -0400109#SeeAlso setEmpty isEmpty
Cary Clark224c7002018-06-27 11:00:21 -0400110
111#Method ##
112
113# ------------------------------------------------------------------------------
114
Cary Clark82f1f742018-06-28 08:50:35 -0400115#Method SkRRect(const SkRRect& rrect)
Cary Clark61313f32018-10-08 14:57:48 -0400116#In Constructors
Cary Clark82f1f742018-06-28 08:50:35 -0400117#Line # copies bounds and corner radii ##
Cary Clark09d80c02018-10-31 12:14:03 -0400118#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400119
Cary Clark224c7002018-06-27 11:00:21 -0400120#Example
Cary Clark80247e52018-07-11 16:18:41 -0400121#Height 60
Cary Clark09d80c02018-10-31 12:14:03 -0400122 SkRRect rrect = SkRRect::MakeRect({10, 10, 100, 50});
123 SkRRect rrect2(rrect);
124 rrect2.inset(20, 20);
125 SkPaint p;
126 p.setStyle(SkPaint::kStroke_Style);
127 p.setStrokeWidth(10);
128 canvas->drawRRect(rrect, p);
129 canvas->drawRRect(rrect2, p);
Cary Clark224c7002018-06-27 11:00:21 -0400130##
131
Cary Clark82f1f742018-06-28 08:50:35 -0400132#SeeAlso operator=(const SkRRect& rrect) MakeRect
Cary Clark224c7002018-06-27 11:00:21 -0400133
134#Method ##
135
136# ------------------------------------------------------------------------------
137
Cary Clark82f1f742018-06-28 08:50:35 -0400138#Method SkRRect& operator=(const SkRRect& rrect)
Cary Clark61313f32018-10-08 14:57:48 -0400139#In Operators
Cary Clark82f1f742018-06-28 08:50:35 -0400140#Line # copies bounds and corner radii ##
Cary Clark09d80c02018-10-31 12:14:03 -0400141#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400142
143#Example
Cary Clark80247e52018-07-11 16:18:41 -0400144#Height 110
Cary Clark09d80c02018-10-31 12:14:03 -0400145 SkRRect rrect = SkRRect::MakeRect({40, 40, 100, 70});
146 SkRRect rrect2 = rrect;
147 rrect2.inset(-20, -20);
148 SkPaint p;
149 p.setStyle(SkPaint::kStroke_Style);
150 p.setStrokeWidth(10);
151 canvas->drawRRect(rrect, p);
Cary Clark82f1f742018-06-28 08:50:35 -0400152 canvas->drawRRect(rrect2, p);
Cary Clark224c7002018-06-27 11:00:21 -0400153##
154
Cary Clark82f1f742018-06-28 08:50:35 -0400155#SeeAlso SkRRect(const SkRRect& rrect) MakeRect
Cary Clark224c7002018-06-27 11:00:21 -0400156
157#Method ##
158
159# ------------------------------------------------------------------------------
Cary Clark82f1f742018-06-28 08:50:35 -0400160#Subtopic Type
161#Line # specialization of Round_Rect geometry ##
162
163#PhraseDef list_of_rrect_types
164kEmpty_Type, kRect_Type, kOval_Type, kSimple_Type, kNinePatch_Type,
165kComplex_Type
166##
Cary Clark224c7002018-06-27 11:00:21 -0400167
168#Enum Type
Cary Clark82f1f742018-06-28 08:50:35 -0400169#Line # specialization of Round_Rect geometry ##
Cary Clark224c7002018-06-27 11:00:21 -0400170
171#Code
172 enum Type {
173 kEmpty_Type,
174 kRect_Type,
175 kOval_Type,
176 kSimple_Type,
177 kNinePatch_Type,
178 kComplex_Type,
179 kLastType = kComplex_Type,
180 };
181##
182
Cary Clark82f1f742018-06-28 08:50:35 -0400183Type describes possible specializations of Round_Rect. Each Type is
184exclusive; a Round_Rect may only have one type.
185
Cary Clark80247e52018-07-11 16:18:41 -0400186Type members become progressively less restrictive; larger values of
Cary Clark82f1f742018-06-28 08:50:35 -0400187Type have more degrees of freedom than smaller values.
Cary Clark224c7002018-06-27 11:00:21 -0400188
Cary Clark80247e52018-07-11 16:18:41 -0400189#Const kEmpty_Type 0
Cary Clark82f1f742018-06-28 08:50:35 -0400190#Line # zero width or height ##
Cary Clark224c7002018-06-27 11:00:21 -0400191Round_Rect has zero width or height. All radii are zero.
192##
Cary Clark80247e52018-07-11 16:18:41 -0400193#Const kRect_Type 1
Cary Clark82f1f742018-06-28 08:50:35 -0400194#Line # non-zero width and height, and zeroed radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400195Round_Rect has width and height. All radii are zero.
196##
Cary Clark80247e52018-07-11 16:18:41 -0400197#Const kOval_Type 2
Cary Clark82f1f742018-06-28 08:50:35 -0400198#Line # non-zero width and height filled with radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400199Round_Rect has width and height. All four x-radii are equal,
200and at least half the width. All four y-radii are equal,
201and at least half the height.
202##
Cary Clark80247e52018-07-11 16:18:41 -0400203#Const kSimple_Type 3
Cary Clark82f1f742018-06-28 08:50:35 -0400204#Line # non-zero width and height with equal radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400205Round_Rect has width and height. All four x-radii are equal and
206greater than zero, and all four y-radii are equal and greater than
207zero. Either x-radii are less than half the width, or y-radii is
208less than half the height, or both.
209##
Cary Clark80247e52018-07-11 16:18:41 -0400210#Const kNinePatch_Type 4
Cary Clark82f1f742018-06-28 08:50:35 -0400211#Line # non-zero width and height with axis-aligned radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400212Round_Rect has width and height. Left x-radii are equal, top
213y-radii are equal, right x-radii are equal, and bottom y-radii
Cary Clarkf9603982018-07-17 08:20:27 -0400214are equal. The radii do not describe Rect, Oval, or simple type.
Cary Clark224c7002018-06-27 11:00:21 -0400215
216The centers of the corner ellipses form an axis-aligned rectangle
217that divides the Round_Rect into nine rectangular patches; an
218interior rectangle, four edges, and four corners.
219##
Cary Clark80247e52018-07-11 16:18:41 -0400220#Const kComplex_Type 5
Cary Clark82f1f742018-06-28 08:50:35 -0400221#Line # non-zero width and height with arbitrary radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400222both radii are non-zero.
223##
Cary Clark80247e52018-07-11 16:18:41 -0400224#Const kLastType 5
Cary Clark82f1f742018-06-28 08:50:35 -0400225#Line # largest Type value ##
Cary Clark224c7002018-06-27 11:00:21 -0400226##
227
228#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400229#Height 128
Cary Clark09d80c02018-10-31 12:14:03 -0400230 struct Radii { SkVector data[4]; };
231 auto drawRRectType = [=](const SkRect& rect, const Radii& radii) {
232 SkRRect rrect;
233 rrect.setRectRadii(rect, radii.data);
234 SkPaint paint;
235 paint.setAntiAlias(true);
236 const char* typeStr[] = { "empty", "rect", "oval", "simple", "nine patch", "complex" };
237 canvas->drawString(typeStr[(int) rrect.type()], rect.centerX(), rect.bottom() + 20, paint);
238 paint.setStyle(SkPaint::kStroke_Style);
239 canvas->drawRRect(rrect, paint);
240 };
241 drawRRectType({ 45, 30, 45, 30}, {{{ 5, 5}, { 5, 5}, { 5, 5}, { 5, 5}}});
242 drawRRectType({ 90, 10, 140, 30}, {{{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}}});
243 drawRRectType({160, 10, 210, 30}, {{{25, 10}, {25, 10}, {25, 10}, {25, 10}}});
244 drawRRectType({ 20, 80, 70, 100}, {{{ 5, 5}, { 5, 5}, { 5, 5}, { 5, 5}}});
245 drawRRectType({ 90, 80, 140, 100}, {{{ 5, 5}, {10, 5}, {10, 5}, { 5, 5}}});
Cary Clark82f1f742018-06-28 08:50:35 -0400246 drawRRectType({160, 80, 210, 100}, {{{ 5, 5}, {10, 5}, { 5, 5}, { 5, 5}}});
Cary Clark224c7002018-06-27 11:00:21 -0400247##
248
Cary Clark82f1f742018-06-28 08:50:35 -0400249#SeeAlso Rect Path
Cary Clark224c7002018-06-27 11:00:21 -0400250
251#Enum ##
252
253# ------------------------------------------------------------------------------
254
255#Method Type getType() const
Cary Clark82f1f742018-06-28 08:50:35 -0400256#In Property
257#Line # returns Type ##
Cary Clark224c7002018-06-27 11:00:21 -0400258
Cary Clark82f1f742018-06-28 08:50:35 -0400259Returns Type, one of: #list_of_rrect_types#.
Cary Clark224c7002018-06-27 11:00:21 -0400260
Cary Clark82f1f742018-06-28 08:50:35 -0400261#Return Type ##
Cary Clark224c7002018-06-27 11:00:21 -0400262
263#Example
Cary Clark80247e52018-07-11 16:18:41 -0400264#Height 100
Cary Clark82f1f742018-06-28 08:50:35 -0400265#Description
266rrect2 is not a Rect; inset() has made it empty.
267##
Cary Clark09d80c02018-10-31 12:14:03 -0400268 SkRRect rrect = SkRRect::MakeRect({10, 10, 100, 50});
269 SkRRect rrect2(rrect);
270 rrect2.inset(20, 20);
271 SkPaint p;
272 p.setStyle(SkPaint::kStroke_Style);
273 p.setStrokeWidth(10);
274 std::string str("Type ");
275 str += SkRRect::kRect_Type == rrect2.getType() ? "=" : "!";
276 str += "= SkRRect::kRect_Type";
277 canvas->drawString(str.c_str(), 20, 80, SkPaint());
Cary Clark82f1f742018-06-28 08:50:35 -0400278 canvas->drawRRect(rrect2, p);
Cary Clark224c7002018-06-27 11:00:21 -0400279##
280
Cary Clark82f1f742018-06-28 08:50:35 -0400281#SeeAlso Type type
Cary Clark224c7002018-06-27 11:00:21 -0400282
283#Method ##
284
285# ------------------------------------------------------------------------------
286
287#Method Type type() const
Cary Clark82f1f742018-06-28 08:50:35 -0400288#In Property
289#Line # returns Type ##
Cary Clark224c7002018-06-27 11:00:21 -0400290
Cary Clark82f1f742018-06-28 08:50:35 -0400291Returns Type, one of: #list_of_rrect_types#.
292
293#Return Type ##
Cary Clark224c7002018-06-27 11:00:21 -0400294
295#Example
Cary Clark80247e52018-07-11 16:18:41 -0400296#Height 100
Cary Clark82f1f742018-06-28 08:50:35 -0400297#Description
298inset() has made rrect2 empty.
299##
Cary Clark09d80c02018-10-31 12:14:03 -0400300 SkRRect rrect = SkRRect::MakeRect({10, 10, 100, 50});
301 SkRRect rrect2(rrect);
302 rrect2.inset(20, 20);
303 SkPaint p;
304 p.setStyle(SkPaint::kStroke_Style);
305 p.setStrokeWidth(10);
306 std::string str("Type ");
307 str += SkRRect::kEmpty_Type == rrect2.type() ? "=" : "!";
308 str += "= SkRRect::kEmpty_Type";
309 canvas->drawString(str.c_str(), 20, 80, SkPaint());
Cary Clark82f1f742018-06-28 08:50:35 -0400310 canvas->drawRRect(rrect2, p);
Cary Clark224c7002018-06-27 11:00:21 -0400311##
312
Cary Clark82f1f742018-06-28 08:50:35 -0400313#SeeAlso Type getType
Cary Clark224c7002018-06-27 11:00:21 -0400314
315#Method ##
316
Cary Clark82f1f742018-06-28 08:50:35 -0400317#Subtopic Type ##
318
Cary Clark224c7002018-06-27 11:00:21 -0400319# ------------------------------------------------------------------------------
320
Cary Clark61313f32018-10-08 14:57:48 -0400321#Method bool isEmpty() const
Cary Clark224c7002018-06-27 11:00:21 -0400322#In Property
323#Line # returns true if width or height are zero ##
Cary Clark09d80c02018-10-31 12:14:03 -0400324#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400325
326#Example
327#Height 100
Cary Clark09d80c02018-10-31 12:14:03 -0400328 SkPaint paint;
329 paint.setAntiAlias(true);
330 paint.setTextSize(16);
331 SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 10, 5);
332 canvas->drawRRect(rrect, paint);
333 canvas->drawString(rrect.isEmpty() ? "empty" : "not empty", 64, 90, paint);
334 rrect.inset(40, 0);
335 canvas->translate(128, 0);
336 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400337 canvas->drawString(rrect.isEmpty() ? "empty" : "not empty", 64, 90, paint);
338##
339
340#SeeAlso SkRect::isEmpty height width
341
342#Method ##
343
344# ------------------------------------------------------------------------------
345
Cary Clark61313f32018-10-08 14:57:48 -0400346#Method bool isRect() const
Cary Clark224c7002018-06-27 11:00:21 -0400347#In Property
348#Line # returns true if not empty, and one radius at each corner is zero ##
Cary Clark09d80c02018-10-31 12:14:03 -0400349#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400350
351#Example
352#Height 100
Cary Clark09d80c02018-10-31 12:14:03 -0400353 SkPaint paint;
354 paint.setAntiAlias(true);
355 paint.setTextSize(16);
356 SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
357 canvas->drawRRect(rrect, paint);
358 canvas->drawString(rrect.isRect() ? "rect" : "not rect", 64, 90, paint);
359 SkVector radii[] = {{10, 10}, {0, 0}, {0, 0}, {0, 0}};
360 rrect.setRectRadii(rrect.getBounds(), radii);
361 canvas->translate(128, 0);
362 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400363 canvas->drawString(rrect.isRect() ? "rect" : "not rect", 64, 90, paint);
364##
365
366#SeeAlso isEmpty radii
367
368#Method ##
369
370# ------------------------------------------------------------------------------
371
Cary Clark61313f32018-10-08 14:57:48 -0400372#Method bool isOval() const
Cary Clark224c7002018-06-27 11:00:21 -0400373#In Property
374#Line # returns true if not empty, axes radii are equal, radii fill bounds ##
Cary Clark09d80c02018-10-31 12:14:03 -0400375#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400376
377#Example
378#Height 100
379#Description
380The first radii are scaled down proportionately until both x-axis and y-axis fit
381within the bounds. After scaling, x-axis radius is smaller than half the width;
Cary Clark80247e52018-07-11 16:18:41 -0400382left Round_Rect is not an oval. The second radii are equal to half the
383dimensions; right Round_Rect is an oval.
Cary Clark224c7002018-06-27 11:00:21 -0400384##
Cary Clark09d80c02018-10-31 12:14:03 -0400385 SkPaint paint;
386 paint.setAntiAlias(true);
387 paint.setTextSize(16);
388 SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 40, 30);
389 canvas->drawRRect(rrect, paint);
390 canvas->drawString(rrect.isOval() ? "oval" : "not oval", 64, 90, paint);
391 rrect.setRectXY(rrect.getBounds(), 35, 25);
392 canvas->translate(128, 0);
393 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400394 canvas->drawString(rrect.isOval() ? "oval" : "not oval", 64, 90, paint);
395##
396
397#SeeAlso isEmpty isSimple SkCanvas::drawOval
398
399#Method ##
400
401# ------------------------------------------------------------------------------
402
Cary Clark61313f32018-10-08 14:57:48 -0400403#Method bool isSimple() const
Cary Clark224c7002018-06-27 11:00:21 -0400404#In Property
Cary Clark80247e52018-07-11 16:18:41 -0400405#Line # returns true if not empty, Rect or Oval; and axes radii are equal ##
Cary Clark09d80c02018-10-31 12:14:03 -0400406#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400407
Cary Clark224c7002018-06-27 11:00:21 -0400408#Example
409#Height 100
Cary Clark09d80c02018-10-31 12:14:03 -0400410 SkPaint paint;
411 paint.setAntiAlias(true);
412 paint.setTextSize(16);
413 SkVector radii[] = {{40, 30}, {40, 30}, {40, 30}, {40, 30}};
414 SkRRect rrect;
415 rrect.setRectRadii({30, 10, 100, 60}, radii);
416 canvas->drawRRect(rrect, paint);
417 canvas->drawString(rrect.isSimple() ? "simple" : "not simple", 64, 90, paint);
418 radii[0].fX = 35;
419 rrect.setRectRadii(rrect.getBounds(), radii);
420 canvas->translate(128, 0);
421 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400422 canvas->drawString(rrect.isSimple() ? "simple" : "not simple", 64, 90, paint);
423##
424
425#SeeAlso isEmpty isRect isOval isNinePatch
426
427#Method ##
428
429# ------------------------------------------------------------------------------
430
Cary Clark61313f32018-10-08 14:57:48 -0400431#Method bool isNinePatch() const
Cary Clark224c7002018-06-27 11:00:21 -0400432#In Property
Cary Clark80247e52018-07-11 16:18:41 -0400433#Line # returns true if not empty, Rect, Oval or simple; and radii are axis-aligned ##
Cary Clark09d80c02018-10-31 12:14:03 -0400434#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400435
Cary Clark224c7002018-06-27 11:00:21 -0400436#Example
437#Height 100
Cary Clark09d80c02018-10-31 12:14:03 -0400438 SkPaint paint;
439 paint.setAntiAlias(true);
440 paint.setTextSize(16);
441 SkVector radii[] = {{20, 30}, {40, 30}, {40, 30}, {20, 30}};
442 SkRRect rrect;
443 rrect.setRectRadii({30, 10, 100, 60}, radii);
444 canvas->drawRRect(rrect, paint);
445 canvas->drawString(rrect.isNinePatch() ? "9 patch" : "not 9 patch", 64, 90, paint);
446 radii[0].fX = 35;
447 rrect.setRectRadii(rrect.getBounds(), radii);
448 canvas->translate(128, 0);
449 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400450 canvas->drawString(rrect.isNinePatch() ? "9 patch" : "not 9 patch", 64, 90, paint);
451##
452
453#SeeAlso isEmpty isRect isOval isSimple isComplex
454
455#Method ##
456
457# ------------------------------------------------------------------------------
458
Cary Clark61313f32018-10-08 14:57:48 -0400459#Method bool isComplex() const
Cary Clark224c7002018-06-27 11:00:21 -0400460#In Property
Cary Clark80247e52018-07-11 16:18:41 -0400461#Line # returns true if not empty, Rect, Oval, simple, or nine-patch ##
Cary Clark09d80c02018-10-31 12:14:03 -0400462#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400463
464#Example
Cary Clark80247e52018-07-11 16:18:41 -0400465#Height 100
Cary Clark09d80c02018-10-31 12:14:03 -0400466 SkPaint paint;
467 paint.setAntiAlias(true);
468 paint.setTextSize(16);
469 SkVector radii[] = {{25, 30}, {40, 30}, {40, 30}, {20, 30}};
470 SkRRect rrect;
471 rrect.setRectRadii({30, 10, 100, 60}, radii);
472 canvas->drawRRect(rrect, paint);
473 canvas->drawString(rrect.isComplex() ? "complex" : "not complex", 64, 90, paint);
474 radii[0].fX = 20;
475 rrect.setRectRadii(rrect.getBounds(), radii);
476 canvas->translate(128, 0);
477 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400478 canvas->drawString(rrect.isComplex() ? "complex" : "not complex", 64, 90, paint);
479##
480
481#SeeAlso isEmpty isRect isOval isSimple isNinePatch
482
483#Method ##
484
485# ------------------------------------------------------------------------------
486
487#Method SkScalar width() const
488#In Property
Cary Clark80247e52018-07-11 16:18:41 -0400489#Line # returns span in x-axis ##
Cary Clark09d80c02018-10-31 12:14:03 -0400490#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400491
492#Example
493#Description
494SkRRect::MakeRect sorts its input, so width() is always zero or larger.
495##
Cary Clark09d80c02018-10-31 12:14:03 -0400496 SkRRect unsorted = SkRRect::MakeRect({ 15, 25, 10, 5 });
497 SkDebugf("unsorted width: %g\n", unsorted.width());
498 SkRRect large = SkRRect::MakeRect({ -FLT_MAX, 1, FLT_MAX, 2 });
Cary Clark224c7002018-06-27 11:00:21 -0400499 SkDebugf("large width: %.0f\n", large.width());
500#StdOut
Cary Clark09d80c02018-10-31 12:14:03 -0400501unsorted width: 5
Cary Clark224c7002018-06-27 11:00:21 -0400502large width: inf
503##
504##
505
506#SeeAlso SkRect::width height getBounds
507
508#Method ##
509
510# ------------------------------------------------------------------------------
511
512#Method SkScalar height() const
513#In Property
Cary Clark80247e52018-07-11 16:18:41 -0400514#Line # returns span in y-axis ##
Cary Clark09d80c02018-10-31 12:14:03 -0400515#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400516
517#Example
518#Description
519SkRRect::MakeRect sorts its input, so height() is always zero or larger.
520##
521 SkRRect unsorted = SkRRect::MakeRect({ 15, 25, 10, 20 });
522 SkDebugf("unsorted height: %g\n", unsorted.height());
523 SkRRect large = SkRRect::MakeRect({ 1, -FLT_MAX, 2, FLT_MAX });
524 SkDebugf("large height: %.0f\n", large.height());
525#StdOut
Cary Clark09d80c02018-10-31 12:14:03 -0400526unsorted height: 5
Cary Clark224c7002018-06-27 11:00:21 -0400527large height: inf
528##
529##
530
Cary Clark77b3f3a2018-11-07 14:59:03 -0500531#SeeAlso SkRect::height width getBounds
Cary Clark224c7002018-06-27 11:00:21 -0400532
533#Method ##
534
535# ------------------------------------------------------------------------------
536
537#Method SkVector getSimpleRadii() const
538#In Property
539#Line # returns corner radii for simple types ##
Cary Clark09d80c02018-10-31 12:14:03 -0400540#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400541
542#Example
Cary Clark80247e52018-07-11 16:18:41 -0400543#Height 100
Cary Clark09d80c02018-10-31 12:14:03 -0400544 auto drawDetails = [=](const SkRRect& rrect) {
545 SkPaint paint;
546 paint.setAntiAlias(true);
547 paint.setTextSize(12);
548 canvas->drawRRect(rrect, paint);
549 SkVector corner = rrect.getSimpleRadii();
550 std::string label = "corner: " + std::to_string(corner.fX).substr(0, 3) + ", " +
551 std::to_string(corner.fY).substr(0, 3);
552 canvas->drawString(label.c_str(), 64, 90, paint);
553 canvas->translate(128, 0);
554 };
555 SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
556 drawDetails(rrect);
557 rrect.setRectXY(rrect.getBounds(), 5, 8);
558 drawDetails(rrect);
Cary Clark224c7002018-06-27 11:00:21 -0400559##
560
561#SeeAlso radii getBounds getType isSimple
562
563#Method ##
564
565# ------------------------------------------------------------------------------
566
567#Method void setEmpty()
568#In Set
569#Line # zeroes width, height, and corner radii ##
Cary Clark09d80c02018-10-31 12:14:03 -0400570#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400571
572#Example
Cary Clark80247e52018-07-11 16:18:41 -0400573#Height 80
Cary Clark224c7002018-06-27 11:00:21 -0400574#Description
Cary Clark80247e52018-07-11 16:18:41 -0400575Nothing blue is drawn because Round_Rect is set to empty.
Cary Clark224c7002018-06-27 11:00:21 -0400576##
Cary Clark09d80c02018-10-31 12:14:03 -0400577 SkPaint paint;
578 SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
579 canvas->drawRRect(rrect, paint);
580 rrect.setEmpty();
581 paint.setColor(SK_ColorBLUE);
Cary Clark224c7002018-06-27 11:00:21 -0400582 canvas->drawRRect(rrect, paint);
583##
584
585#SeeAlso MakeEmpty setRect
586
587#Method ##
588
589# ------------------------------------------------------------------------------
590
591#Method void setRect(const SkRect& rect)
592#In Set
Cary Clark80247e52018-07-11 16:18:41 -0400593#Line # sets Round_Rect bounds with zeroed corners ##
Cary Clark09d80c02018-10-31 12:14:03 -0400594#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400595
596#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400597#Height 90
Cary Clark09d80c02018-10-31 12:14:03 -0400598 SkPaint paint;
599 SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
600 canvas->drawRRect(rrect, paint);
601 rrect.setRect({60, 30, 120, 80});
602 paint.setColor(SK_ColorBLUE);
Cary Clark224c7002018-06-27 11:00:21 -0400603 canvas->drawRRect(rrect, paint);
604##
605
606#SeeAlso MakeRect setRectXY
607
608#Method ##
609
610# ------------------------------------------------------------------------------
611
612#Method static SkRRect MakeEmpty()
Cary Clark61313f32018-10-08 14:57:48 -0400613#In Constructors
Cary Clark82f1f742018-06-28 08:50:35 -0400614#Line # creates with zeroed bounds and corner radii ##
Cary Clark09d80c02018-10-31 12:14:03 -0400615#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400616
617#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400618#Height 90
Cary Clark09d80c02018-10-31 12:14:03 -0400619 SkRRect rrect = SkRRect::MakeEmpty();
620 SkRRect rrect2(rrect);
621 rrect2.inset(-20, -20);
622 SkPaint p;
623 p.setStyle(SkPaint::kStroke_Style);
624 p.setStrokeWidth(10);
625 std::string str("Type ");
626 str += SkRRect::kEmpty_Type == rrect2.type() ? "=" : "!";
627 str += "= SkRRect::kEmpty_Type";
628 canvas->drawString(str.c_str(), 20, 80, SkPaint());
Cary Clark82f1f742018-06-28 08:50:35 -0400629 canvas->drawRRect(rrect2, p);
Cary Clark224c7002018-06-27 11:00:21 -0400630##
631
Cary Clark82f1f742018-06-28 08:50:35 -0400632#SeeAlso SkRRect() SkRect::MakeEmpty
Cary Clark224c7002018-06-27 11:00:21 -0400633
634#Method ##
635
636# ------------------------------------------------------------------------------
637
638#Method static SkRRect MakeRect(const SkRect& r)
Cary Clark61313f32018-10-08 14:57:48 -0400639#In Constructors
Cary Clark82f1f742018-06-28 08:50:35 -0400640#Line # copies bounds and zeroes corner radii ##
Cary Clark09d80c02018-10-31 12:14:03 -0400641#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400642
643#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400644#Height 70
Cary Clark09d80c02018-10-31 12:14:03 -0400645 SkPaint paint;
646 SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
647 canvas->drawRRect(rrect, paint);
648 rrect.setOval(rrect.getBounds());
649 paint.setColor(SK_ColorBLUE);
Cary Clark82f1f742018-06-28 08:50:35 -0400650 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400651##
652
Cary Clark82f1f742018-06-28 08:50:35 -0400653#SeeAlso setRect MakeOval MakeRectXY
Cary Clark224c7002018-06-27 11:00:21 -0400654
655#Method ##
656
657# ------------------------------------------------------------------------------
658
659#Method static SkRRect MakeOval(const SkRect& oval)
Cary Clark61313f32018-10-08 14:57:48 -0400660#In Constructors
Cary Clark82f1f742018-06-28 08:50:35 -0400661#Line # creates Oval to fit bounds ##
Cary Clark09d80c02018-10-31 12:14:03 -0400662#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400663
664#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400665#Height 70
Cary Clark09d80c02018-10-31 12:14:03 -0400666 SkPaint paint;
667 SkRRect rrect = SkRRect::MakeOval({30, 10, 100, 60});
668 canvas->drawRRect(rrect, paint);
669 rrect.setRect(rrect.getBounds());
670 paint.setColor(SK_ColorBLUE);
671 paint.setBlendMode(SkBlendMode::kDifference);
Cary Clark82f1f742018-06-28 08:50:35 -0400672 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400673##
674
Cary Clark82f1f742018-06-28 08:50:35 -0400675#SeeAlso setOval MakeRect MakeRectXY
Cary Clark224c7002018-06-27 11:00:21 -0400676
677#Method ##
678
679# ------------------------------------------------------------------------------
680
681#Method static SkRRect MakeRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad)
Cary Clark61313f32018-10-08 14:57:48 -0400682#In Constructors
Cary Clark82f1f742018-06-28 08:50:35 -0400683#Line # creates rounded rectangle ##
Cary Clark09d80c02018-10-31 12:14:03 -0400684#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400685
686#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400687#Height 70
Cary Clark09d80c02018-10-31 12:14:03 -0400688 SkPaint paint;
689 SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 20, 20);
690 canvas->drawRRect(rrect, paint);
691 rrect.setRect(rrect.getBounds());
692 paint.setColor(SK_ColorBLUE);
693 paint.setBlendMode(SkBlendMode::kModulate);
Cary Clark82f1f742018-06-28 08:50:35 -0400694 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400695##
696
Cary Clark82f1f742018-06-28 08:50:35 -0400697#SeeAlso setRectXY
Cary Clark224c7002018-06-27 11:00:21 -0400698
699#Method ##
700
701# ------------------------------------------------------------------------------
702
703#Method void setOval(const SkRect& oval)
Cary Clark82f1f742018-06-28 08:50:35 -0400704#In Set
705#Line # replaces with Oval to fit bounds ##
Cary Clark09d80c02018-10-31 12:14:03 -0400706#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400707
708#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400709#Height 70
Cary Clark09d80c02018-10-31 12:14:03 -0400710 SkPaint paint;
711 SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 20, 20);
712 canvas->drawRRect(rrect, paint);
713 rrect.setOval(rrect.getBounds());
714 paint.setColor(SK_ColorWHITE);
715 paint.setBlendMode(SkBlendMode::kExclusion);
Cary Clark82f1f742018-06-28 08:50:35 -0400716 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400717##
718
Cary Clark82f1f742018-06-28 08:50:35 -0400719#SeeAlso MakeOval
Cary Clark224c7002018-06-27 11:00:21 -0400720
721#Method ##
722
723# ------------------------------------------------------------------------------
724
725#Method void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad)
Cary Clark82f1f742018-06-28 08:50:35 -0400726#In Set
727#Line # replaces with rounded rectangle ##
Cary Clark09d80c02018-10-31 12:14:03 -0400728#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400729
730#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400731#Height 70
Cary Clark09d80c02018-10-31 12:14:03 -0400732 SkPaint paint;
733 SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 20, 20);
734 canvas->drawRRect(rrect, paint);
735 rrect.setRectXY(rrect.getBounds(), 5, 5);
736 paint.setColor(SK_ColorWHITE);
737 paint.setBlendMode(SkBlendMode::kExclusion);
Cary Clark82f1f742018-06-28 08:50:35 -0400738 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400739##
740
Cary Clark82f1f742018-06-28 08:50:35 -0400741#SeeAlso MakeRectXY SkPath::addRoundRect
Cary Clark224c7002018-06-27 11:00:21 -0400742
743#Method ##
744
745# ------------------------------------------------------------------------------
746
747#Method void setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad,
748 SkScalar rightRad, SkScalar bottomRad)
Cary Clark82f1f742018-06-28 08:50:35 -0400749#In Set
750#Line # replaces with rounded rectangle ##
Cary Clark09d80c02018-10-31 12:14:03 -0400751#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400752
753#Example
Cary Clark82f1f742018-06-28 08:50:35 -0400754#Height 70
Cary Clark09d80c02018-10-31 12:14:03 -0400755 SkPaint paint;
756 paint.setAntiAlias(true);
757 SkRRect rrect;
758 rrect.setNinePatch({30, 10, 100, 60}, 10, 20, 20, 10);
759 canvas->drawRRect(rrect, paint);
760 paint.setColor(SK_ColorWHITE);
761 const SkRect r = rrect.getBounds();
762 canvas->drawLine(r.fLeft, r.fTop + rrect.radii(SkRRect::kUpperLeft_Corner).fY,
763 r.fRight, r.fTop + rrect.radii(SkRRect::kUpperRight_Corner).fY, paint);
764 canvas->drawLine(r.fLeft, r.fBottom - rrect.radii(SkRRect::kLowerLeft_Corner).fY,
765 r.fRight, r.fBottom - rrect.radii(SkRRect::kLowerRight_Corner).fY, paint);
766 canvas->drawLine(r.fLeft + rrect.radii(SkRRect::kUpperLeft_Corner).fX, r.fTop,
767 r.fLeft + rrect.radii(SkRRect::kLowerLeft_Corner).fX, r.fBottom, paint);
768 canvas->drawLine(r.fRight - rrect.radii(SkRRect::kUpperRight_Corner).fX, r.fTop,
Cary Clark82f1f742018-06-28 08:50:35 -0400769 r.fRight - rrect.radii(SkRRect::kLowerRight_Corner).fX, r.fBottom, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400770##
771
Cary Clark82f1f742018-06-28 08:50:35 -0400772#SeeAlso setRectRadii
Cary Clark224c7002018-06-27 11:00:21 -0400773
774#Method ##
775
776# ------------------------------------------------------------------------------
777
778#Method void setRectRadii(const SkRect& rect, const SkVector radii[4])
Cary Clark82f1f742018-06-28 08:50:35 -0400779#In Set
780#Line # replaces with rounded rectangle ##
Cary Clark09d80c02018-10-31 12:14:03 -0400781#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400782
783#Example
Cary Clark80247e52018-07-11 16:18:41 -0400784#Height 128
Cary Clark09d80c02018-10-31 12:14:03 -0400785 SkPaint paint;
786 paint.setStrokeWidth(15);
787 paint.setStrokeCap(SkPaint::kSquare_Cap);
788 paint.setAntiAlias(true);
789 float intervals[] = { 5, 21.75f };
790 paint.setStyle(SkPaint::kStroke_Style);
791 paint.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
792 SkPath path;
793 SkRRect rrect;
794 SkVector corners[] = {{15, 17}, {17, 19}, {19, 15}, {15, 15}};
795 rrect.setRectRadii({20, 20, 100, 100}, corners);
796 path.addRRect(rrect, SkPath::kCW_Direction);
797 canvas->drawPath(path, paint);
798 path.rewind();
799 path.addRRect(rrect, SkPath::kCCW_Direction, 1);
800 canvas->translate(120, 0);
Cary Clark53498e92018-06-28 19:13:56 -0400801 canvas->drawPath(path, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400802##
803
Cary Clark82f1f742018-06-28 08:50:35 -0400804#SeeAlso setNinePatch SkPath::addRoundRect
Cary Clark224c7002018-06-27 11:00:21 -0400805
806#Method ##
807
808# ------------------------------------------------------------------------------
809
810#Enum Corner
Cary Clark53498e92018-06-28 19:13:56 -0400811#Line # corner radii order ##
Cary Clark224c7002018-06-27 11:00:21 -0400812
813#Code
814 enum Corner {
815 kUpperLeft_Corner,
816 kUpperRight_Corner,
817 kLowerRight_Corner,
818 kLowerLeft_Corner,
819 };
820##
821
822The radii are stored: top-left, top-right, bottom-right, bottom-left.
823
Cary Clark53498e92018-06-28 19:13:56 -0400824#Const kUpperLeft_Corner 0
825#Line # index of top-left corner radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400826##
Cary Clark53498e92018-06-28 19:13:56 -0400827#Const kUpperRight_Corner 1
828#Line # index of top-right corner radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400829##
Cary Clark53498e92018-06-28 19:13:56 -0400830#Const kLowerRight_Corner 2
831#Line # index of bottom-right corner radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400832##
Cary Clark53498e92018-06-28 19:13:56 -0400833#Const kLowerLeft_Corner 3
834#Line # index of bottom-left corner radii ##
Cary Clark224c7002018-06-27 11:00:21 -0400835##
836
837#Example
Cary Clark53498e92018-06-28 19:13:56 -0400838#Height 70
Cary Clark09d80c02018-10-31 12:14:03 -0400839 SkPaint paint;
840 paint.setAntiAlias(true);
841 SkRRect rrect;
842 SkVector corners[] = {{25, 17}, {17, 19}, {19, 15}, {15, 15}};
843 rrect.setRectRadii({30, 10, 100, 60}, corners);
844 canvas->drawRRect(rrect, paint);
845 paint.setColor(SK_ColorWHITE);
846 const SkRect r = rrect.getBounds();
847 canvas->drawLine(r.fLeft, r.fTop + rrect.radii(SkRRect::kUpperLeft_Corner).fY,
848 r.fRight, r.fTop + rrect.radii(SkRRect::kUpperRight_Corner).fY, paint);
849 canvas->drawLine(r.fLeft, r.fBottom - rrect.radii(SkRRect::kLowerLeft_Corner).fY,
850 r.fRight, r.fBottom - rrect.radii(SkRRect::kLowerRight_Corner).fY, paint);
851 canvas->drawLine(r.fLeft + rrect.radii(SkRRect::kUpperLeft_Corner).fX, r.fTop,
852 r.fLeft + rrect.radii(SkRRect::kLowerLeft_Corner).fX, r.fBottom, paint);
853 canvas->drawLine(r.fRight - rrect.radii(SkRRect::kUpperRight_Corner).fX, r.fTop,
Cary Clark53498e92018-06-28 19:13:56 -0400854 r.fRight - rrect.radii(SkRRect::kLowerRight_Corner).fX, r.fBottom, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400855##
856
Cary Clark53498e92018-06-28 19:13:56 -0400857#SeeAlso radii
Cary Clark224c7002018-06-27 11:00:21 -0400858
859#Enum ##
860
861# ------------------------------------------------------------------------------
862
863#Method const SkRect& rect() const
Cary Clark53498e92018-06-28 19:13:56 -0400864#In Property
865#Line # returns bounds ##
Cary Clark09d80c02018-10-31 12:14:03 -0400866#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400867
868#Example
Cary Clark09d80c02018-10-31 12:14:03 -0400869 for (SkScalar left : { SK_ScalarNaN, SK_ScalarInfinity, 100.f, 50.f, 25.f} ) {
870 SkRRect rrect1 = SkRRect::MakeRectXY({left, 20, 60, 220}, 50, 200);
871 SkDebugf("left bounds: (%g) %g\n", left, rrect1.rect().fLeft);
Cary Clark53498e92018-06-28 19:13:56 -0400872 }
873#StdOut
Cary Clark09d80c02018-10-31 12:14:03 -0400874left bounds: (nan) 0
875left bounds: (inf) 0
876left bounds: (100) 60
877left bounds: (50) 50
Cary Clark53498e92018-06-28 19:13:56 -0400878left bounds: (25) 25
879##
Cary Clark224c7002018-06-27 11:00:21 -0400880##
881
Cary Clark53498e92018-06-28 19:13:56 -0400882#SeeAlso getBounds
Cary Clark224c7002018-06-27 11:00:21 -0400883
884#Method ##
885
886# ------------------------------------------------------------------------------
887
888#Method SkVector radii(Corner corner) const
Cary Clark53498e92018-06-28 19:13:56 -0400889#In Property
890#Line # returns x-axis and y-axis radii for one corner ##
Cary Clark09d80c02018-10-31 12:14:03 -0400891#Populate
Cary Clark53498e92018-06-28 19:13:56 -0400892
893#Example
894#Description
895Finite values are scaled proportionately to fit; other values are set to zero.
Cary Clark80247e52018-07-11 16:18:41 -0400896Scaled values cannot be larger than 25, half the bounding Round_Rect width.
Cary Clark53498e92018-06-28 19:13:56 -0400897Small scaled values are halved to scale in proportion to the y-axis corner
898radius, which is twice the bounds height.
899##
Cary Clark09d80c02018-10-31 12:14:03 -0400900 for (SkScalar radiusX : { SK_ScalarNaN, SK_ScalarInfinity, 100.f, 50.f, 25.f} ) {
901 SkRRect rrect1 = SkRRect::MakeRectXY({10, 20, 60, 220}, radiusX, 200);
902 SkDebugf("left corner: (%g) %g\n", radiusX, rrect1.radii(SkRRect::kUpperLeft_Corner).fX);
903 }
Cary Clark53498e92018-06-28 19:13:56 -0400904#StdOut
Cary Clark09d80c02018-10-31 12:14:03 -0400905left corner: (nan) 0
906left corner: (inf) 0
907left corner: (100) 25
908left corner: (50) 25
Cary Clark53498e92018-06-28 19:13:56 -0400909left corner: (25) 12.5
910##
911##
912
913#SeeAlso Corner
Cary Clark224c7002018-06-27 11:00:21 -0400914
915#Method ##
916
917# ------------------------------------------------------------------------------
918
919#Method const SkRect& getBounds() const
Cary Clark53498e92018-06-28 19:13:56 -0400920#In Property
921#Line # returns bounds ##
Cary Clark09d80c02018-10-31 12:14:03 -0400922#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400923
924#Example
Cary Clark53498e92018-06-28 19:13:56 -0400925#Height 120
Cary Clark09d80c02018-10-31 12:14:03 -0400926 SkPaint paint;
927 SkRRect rrect = SkRRect::MakeRectXY({20, 20, 220, 100}, 15, 15);
928 canvas->drawRRect(rrect, paint);
929 paint.setColor(SK_ColorWHITE);
930 rrect = SkRRect::MakeOval(rrect.getBounds());
Cary Clark53498e92018-06-28 19:13:56 -0400931 canvas->drawRRect(rrect, paint);
Cary Clark224c7002018-06-27 11:00:21 -0400932##
933
Cary Clark53498e92018-06-28 19:13:56 -0400934#SeeAlso rect
Cary Clark224c7002018-06-27 11:00:21 -0400935
936#Method ##
937
938# ------------------------------------------------------------------------------
939
940#Method bool operator==(const SkRRect& a, const SkRRect& b)
Cary Clark61313f32018-10-08 14:57:48 -0400941#In Operators
Cary Clark53498e92018-06-28 19:13:56 -0400942#Line # returns true if members are equal ##
Cary Clark09d80c02018-10-31 12:14:03 -0400943#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400944
945#Example
Cary Clark09d80c02018-10-31 12:14:03 -0400946 SkRRect rrect1 = SkRRect::MakeRectXY({10, 20, 60, 220}, 50, 200);
947 SkRRect rrect2 = SkRRect::MakeRectXY(rrect1.rect(), 25, 100);
948 SkRRect rrect3 = SkRRect::MakeOval(rrect1.rect());
949 canvas->drawRRect(rrect1, SkPaint());
950 std::string str = "rrect1 " + std::string(rrect1 == rrect2 ? "=" : "!") + "= rrect2";
951 canvas->drawString(str.c_str(), 10, 240, SkPaint());
952 canvas->translate(70, 0);
953 canvas->drawRRect(rrect2, SkPaint());
954 canvas->translate(70, 0);
955 canvas->drawRRect(rrect3, SkPaint());
956 str = "rrect2 " + std::string(rrect2 == rrect3 ? "=" : "!") + "= rrect3";
Cary Clark53498e92018-06-28 19:13:56 -0400957 canvas->drawString(str.c_str(), -20, 240, SkPaint());
Cary Clark224c7002018-06-27 11:00:21 -0400958##
959
Cary Clark53498e92018-06-28 19:13:56 -0400960#SeeAlso operator!=(const SkRRect& a, const SkRRect& b)
Cary Clark224c7002018-06-27 11:00:21 -0400961
962#Method ##
963
964# ------------------------------------------------------------------------------
965
966#Method bool operator!=(const SkRRect& a, const SkRRect& b)
Cary Clark61313f32018-10-08 14:57:48 -0400967#In Operators
Cary Clark53498e92018-06-28 19:13:56 -0400968#Line # returns true if members are unequal ##
Cary Clark09d80c02018-10-31 12:14:03 -0400969#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400970
971#Example
Cary Clark09d80c02018-10-31 12:14:03 -0400972 SkRRect rrect1 = SkRRect::MakeRectXY({10, 20, 60, 220}, 50, 100);
973 SkRRect rrect2 = SkRRect::MakeRectXY(rrect1.rect(), 50, 50);
974 SkRRect rrect3 = SkRRect::MakeOval(rrect1.rect());
975 canvas->drawRRect(rrect1, SkPaint());
976 std::string str = "rrect1 " + std::string(rrect1 == rrect2 ? "=" : "!") + "= rrect2";
977 canvas->drawString(str.c_str(), 10, 240, SkPaint());
978 canvas->translate(70, 0);
979 canvas->drawRRect(rrect2, SkPaint());
980 canvas->translate(70, 0);
981 canvas->drawRRect(rrect3, SkPaint());
982 str = "rrect2 " + std::string(rrect2 == rrect3 ? "=" : "!") + "= rrect3";
Cary Clark53498e92018-06-28 19:13:56 -0400983 canvas->drawString(str.c_str(), -20, 240, SkPaint());
Cary Clark224c7002018-06-27 11:00:21 -0400984##
985
Cary Clark53498e92018-06-28 19:13:56 -0400986#SeeAlso operator==(const SkRRect& a, const SkRRect& b)
Cary Clark224c7002018-06-27 11:00:21 -0400987
988#Method ##
989
990# ------------------------------------------------------------------------------
991
992#Method void inset(SkScalar dx, SkScalar dy, SkRRect* dst) const
Cary Clark53498e92018-06-28 19:13:56 -0400993#In Inset_Outset_Offset
994#Line # insets bounds and radii ##
Cary Clark09d80c02018-10-31 12:14:03 -0400995#Populate
Cary Clark224c7002018-06-27 11:00:21 -0400996
997#Example
Cary Clark09d80c02018-10-31 12:14:03 -0400998 SkPaint paint;
999 paint.setAntiAlias(true);
1000 paint.setStyle(SkPaint::kStroke_Style);
1001 SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
1002 for (int index = 0; index < 25; ++index) {
1003 canvas->drawRRect(rrect, paint);
1004 rrect.inset(-3, 3, &rrect);
1005 }
Cary Clark224c7002018-06-27 11:00:21 -04001006##
1007
Cary Clark53498e92018-06-28 19:13:56 -04001008#SeeAlso outset offset makeOffset
Cary Clark224c7002018-06-27 11:00:21 -04001009
1010#Method ##
1011
1012# ------------------------------------------------------------------------------
1013
1014#Method void inset(SkScalar dx, SkScalar dy)
Cary Clark53498e92018-06-28 19:13:56 -04001015#In Inset_Outset_Offset
1016#Line # insets bounds and radii ##
Cary Clark09d80c02018-10-31 12:14:03 -04001017#Populate
Cary Clark224c7002018-06-27 11:00:21 -04001018
1019#Example
Cary Clark09d80c02018-10-31 12:14:03 -04001020 SkPaint paint;
1021 paint.setAntiAlias(true);
1022 paint.setStyle(SkPaint::kStroke_Style);
1023 SkRRect rrect = SkRRect::MakeRectXY({10, 20, 180, 220}, 50, 100);
1024 for (int index = 0; index < 25; ++index) {
1025 canvas->drawRRect(rrect, paint);
1026 rrect.inset(3, 3);
Cary Clark53498e92018-06-28 19:13:56 -04001027 }
Cary Clark224c7002018-06-27 11:00:21 -04001028##
1029
Cary Clark53498e92018-06-28 19:13:56 -04001030#SeeAlso outset offset makeOffset
1031
Cary Clark224c7002018-06-27 11:00:21 -04001032
1033#Method ##
1034
1035# ------------------------------------------------------------------------------
1036
1037#Method void outset(SkScalar dx, SkScalar dy, SkRRect* dst) const
Cary Clark53498e92018-06-28 19:13:56 -04001038#In Inset_Outset_Offset
1039#Line # outsets bounds and radii ##
Cary Clark09d80c02018-10-31 12:14:03 -04001040#Populate
Cary Clark224c7002018-06-27 11:00:21 -04001041
1042#Example
Cary Clark09d80c02018-10-31 12:14:03 -04001043 SkPaint paint;
1044 paint.setAntiAlias(true);
1045 paint.setStyle(SkPaint::kStroke_Style);
1046 SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
1047 for (int index = 0; index < 25; ++index) {
1048 canvas->drawRRect(rrect, paint);
1049 rrect.outset(-3, 3, &rrect);
1050 }
Cary Clark224c7002018-06-27 11:00:21 -04001051##
1052
Cary Clark53498e92018-06-28 19:13:56 -04001053#SeeAlso inset offset makeOffset
1054
Cary Clark224c7002018-06-27 11:00:21 -04001055
1056#Method ##
1057
1058# ------------------------------------------------------------------------------
1059
1060#Method void outset(SkScalar dx, SkScalar dy)
Cary Clark53498e92018-06-28 19:13:56 -04001061#In Inset_Outset_Offset
1062#Line # outsets bounds and radii ##
Cary Clark09d80c02018-10-31 12:14:03 -04001063#Populate
Cary Clark224c7002018-06-27 11:00:21 -04001064
1065#Example
Cary Clark09d80c02018-10-31 12:14:03 -04001066 SkPaint paint;
1067 paint.setAntiAlias(true);
1068 paint.setStyle(SkPaint::kStroke_Style);
1069 SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
1070 for (int index = 0; index < 25; ++index) {
1071 canvas->drawRRect(rrect, paint);
1072 rrect.outset(3, 3);
1073 }
Cary Clark224c7002018-06-27 11:00:21 -04001074##
1075
Cary Clark53498e92018-06-28 19:13:56 -04001076#SeeAlso inset offset makeOffset
Cary Clark224c7002018-06-27 11:00:21 -04001077
1078#Method ##
1079
1080# ------------------------------------------------------------------------------
1081
1082#Method void offset(SkScalar dx, SkScalar dy)
Cary Clark53498e92018-06-28 19:13:56 -04001083#In Inset_Outset_Offset
1084#Line # offsets bounds and radii ##
Cary Clark09d80c02018-10-31 12:14:03 -04001085#Populate
Cary Clark224c7002018-06-27 11:00:21 -04001086
1087#Example
Cary Clark09d80c02018-10-31 12:14:03 -04001088 SkPaint paint;
1089 paint.setAntiAlias(true);
1090 paint.setStyle(SkPaint::kStroke_Style);
1091 SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
1092 for (int index = 0; index < 25; ++index) {
1093 canvas->drawRRect(rrect, paint);
1094 rrect.offset(3, 3);
1095 }
Cary Clark224c7002018-06-27 11:00:21 -04001096##
1097
Cary Clark53498e92018-06-28 19:13:56 -04001098#SeeAlso makeOffset inset outset
Cary Clark224c7002018-06-27 11:00:21 -04001099
1100#Method ##
1101
1102# ------------------------------------------------------------------------------
1103
Cary Clark61313f32018-10-08 14:57:48 -04001104#Method SkRRect makeOffset(SkScalar dx, SkScalar dy) const
Cary Clark53498e92018-06-28 19:13:56 -04001105#In Inset_Outset_Offset
1106#Line # offsets bounds and radii ##
Cary Clark09d80c02018-10-31 12:14:03 -04001107#Populate
Cary Clark224c7002018-06-27 11:00:21 -04001108
1109#Example
Cary Clark09d80c02018-10-31 12:14:03 -04001110 SkPaint paint;
1111 paint.setAntiAlias(true);
1112 paint.setStyle(SkPaint::kStroke_Style);
1113 SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
1114 for (int index = 0; index < 25; ++index) {
1115 canvas->drawRRect(rrect, paint);
1116 rrect = rrect.makeOffset(-3, 3);
Cary Clark53498e92018-06-28 19:13:56 -04001117 }
Cary Clark224c7002018-06-27 11:00:21 -04001118##
1119
Cary Clark53498e92018-06-28 19:13:56 -04001120#SeeAlso offset inset outset
Cary Clark224c7002018-06-27 11:00:21 -04001121
1122#Method ##
1123
1124# ------------------------------------------------------------------------------
1125
1126#Method bool contains(const SkRect& rect) const
Cary Clark53498e92018-06-28 19:13:56 -04001127#In Intersection
1128#Line # returns true if Rect is inside ##
Cary Clark09d80c02018-10-31 12:14:03 -04001129#Populate
Cary Clark224c7002018-06-27 11:00:21 -04001130
1131#Example
Cary Clark80247e52018-07-11 16:18:41 -04001132#Height 110
Cary Clark09d80c02018-10-31 12:14:03 -04001133 SkRect test = {10, 10, 110, 80};
1134 SkRRect rrect = SkRRect::MakeRect(test);
1135 SkRRect oval = SkRRect::MakeOval(test);
1136 test.inset(10, 10);
1137 SkPaint paint;
1138 paint.setAntiAlias(true);
1139 canvas->drawString(rrect.contains(test) ? "contains" : "does not contain", 55, 100, paint);
1140 canvas->drawString(oval.contains(test) ? "contains" : "does not contain", 185, 100, paint);
1141 paint.setStyle(SkPaint::kStroke_Style);
1142 canvas->drawRRect(rrect, paint);
1143 canvas->drawRect(test, paint);
1144 canvas->translate(120, 0);
1145 canvas->drawRRect(oval, paint);
Cary Clark80247e52018-07-11 16:18:41 -04001146 canvas->drawRect(test, paint);
Cary Clark224c7002018-06-27 11:00:21 -04001147##
1148
Cary Clark53498e92018-06-28 19:13:56 -04001149#SeeAlso SkRect::contains
Cary Clark224c7002018-06-27 11:00:21 -04001150
1151#Method ##
1152
1153# ------------------------------------------------------------------------------
1154
1155#Method bool isValid() const
Cary Clark53498e92018-06-28 19:13:56 -04001156#In Utility
Cary Clark80247e52018-07-11 16:18:41 -04001157#Line # returns if type() matches bounds and radii ##
Cary Clark09d80c02018-10-31 12:14:03 -04001158#Populate
Cary Clark224c7002018-06-27 11:00:21 -04001159
1160#Example
Cary Clark80247e52018-07-11 16:18:41 -04001161#Height 110
Cary Clark09d80c02018-10-31 12:14:03 -04001162 SkRRect rrect = SkRRect::MakeRect({10, 10, 110, 80});
1163 SkRRect corrupt = rrect;
1164 *((float*) &corrupt) = 120;
1165 SkPaint paint;
1166 paint.setAntiAlias(true);
1167 canvas->drawString(rrect.isValid() ? "is valid" : "is corrupted", 55, 100, paint);
1168 canvas->drawString(corrupt.isValid() ? "is valid" : "is corrupted", 185, 100, paint);
1169 paint.setStyle(SkPaint::kStroke_Style);
1170 canvas->drawRRect(rrect, paint);
1171 canvas->translate(120, 0);
Cary Clark80247e52018-07-11 16:18:41 -04001172 canvas->drawRRect(corrupt, paint);
Cary Clark224c7002018-06-27 11:00:21 -04001173##
1174
Cary Clark80247e52018-07-11 16:18:41 -04001175#SeeAlso Type getType
Cary Clark224c7002018-06-27 11:00:21 -04001176
1177#Method ##
1178
1179# ------------------------------------------------------------------------------
1180
1181#Const kSizeInMemory 48
Cary Clark80247e52018-07-11 16:18:41 -04001182#Line # storage space for Round_Rect ##
Cary Clark224c7002018-06-27 11:00:21 -04001183
Cary Clark77b3f3a2018-11-07 14:59:03 -05001184Space required to write the contents of SkRRect into a buffer; always a multiple of four.
Cary Clark224c7002018-06-27 11:00:21 -04001185
1186#Const ##
1187
1188# ------------------------------------------------------------------------------
1189
1190#Method size_t writeToMemory(void* buffer) const
Cary Clark53498e92018-06-28 19:13:56 -04001191#In Utility
Cary Clark80247e52018-07-11 16:18:41 -04001192#Line # writes Round_Rect to buffer ##
Cary Clark09d80c02018-10-31 12:14:03 -04001193#Populate
Cary Clark224c7002018-06-27 11:00:21 -04001194
1195#Example
Cary Clark80247e52018-07-11 16:18:41 -04001196#Height 110
Cary Clark09d80c02018-10-31 12:14:03 -04001197 SkRRect rrect = SkRRect::MakeRect({10, 10, 110, 80});
1198 char storage[SkRRect::kSizeInMemory];
1199 rrect.writeToMemory(storage);
1200 SkRRect copy;
1201 copy.readFromMemory(storage, sizeof(storage));
1202 SkPaint paint;
1203 paint.setAntiAlias(true);
1204 canvas->drawString("rrect", 55, 100, paint);
1205 canvas->drawString("copy", 185, 100, paint);
1206 paint.setStyle(SkPaint::kStroke_Style);
1207 canvas->drawRRect(rrect, paint);
1208 canvas->translate(120, 0);
Cary Clark80247e52018-07-11 16:18:41 -04001209 canvas->drawRRect(copy, paint);
Cary Clark224c7002018-06-27 11:00:21 -04001210##
1211
Cary Clark80247e52018-07-11 16:18:41 -04001212#SeeAlso readFromMemory
Cary Clark224c7002018-06-27 11:00:21 -04001213
1214#Method ##
1215
1216# ------------------------------------------------------------------------------
1217
1218#Method size_t readFromMemory(const void* buffer, size_t length)
Cary Clark53498e92018-06-28 19:13:56 -04001219#In Utility
Cary Clark80247e52018-07-11 16:18:41 -04001220#Line # reads Round_Rect from buffer ##
Cary Clark09d80c02018-10-31 12:14:03 -04001221#Populate
Cary Clark224c7002018-06-27 11:00:21 -04001222
1223#Example
Cary Clark80247e52018-07-11 16:18:41 -04001224#Height 110
Cary Clark09d80c02018-10-31 12:14:03 -04001225 SkVector radii[] = {{5, 5}, {10, 10}, {15, 15}, {5, 5}};
1226 SkRRect rrect;
1227 rrect.setRectRadii({10, 10, 110, 80}, radii);
1228 char storage[SkRRect::kSizeInMemory];
1229 rrect.writeToMemory(storage);
1230 SkRRect copy;
1231 copy.readFromMemory(storage, sizeof(storage));
1232 SkPaint paint;
1233 paint.setAntiAlias(true);
1234 canvas->drawString("rrect", 55, 100, paint);
1235 canvas->drawString("copy", 185, 100, paint);
1236 paint.setStyle(SkPaint::kStroke_Style);
1237 canvas->drawRRect(rrect, paint);
1238 canvas->translate(120, 0);
Cary Clark80247e52018-07-11 16:18:41 -04001239 canvas->drawRRect(copy, paint);
Cary Clark224c7002018-06-27 11:00:21 -04001240##
1241
Cary Clark80247e52018-07-11 16:18:41 -04001242#SeeAlso writeToMemory
Cary Clark224c7002018-06-27 11:00:21 -04001243
1244#Method ##
1245
1246# ------------------------------------------------------------------------------
1247
1248#Method bool transform(const SkMatrix& matrix, SkRRect* dst) const
Cary Clark53498e92018-06-28 19:13:56 -04001249#In Inset_Outset_Offset
1250#Line # scales and offsets into copy ##
Cary Clark09d80c02018-10-31 12:14:03 -04001251#Populate
Cary Clark224c7002018-06-27 11:00:21 -04001252
1253#Example
Cary Clark80247e52018-07-11 16:18:41 -04001254#Height 110
Cary Clark09d80c02018-10-31 12:14:03 -04001255 SkVector radii[] = {{5, 5}, {10, 10}, {15, 15}, {5, 5}};
1256 SkRRect rrect;
1257 rrect.setRectRadii({10, 10, 110, 80}, radii);
1258 SkRRect transformed;
1259 SkMatrix matrix = SkMatrix::MakeRectToRect(rrect.rect(), {140, 30, 220, 80},
1260 SkMatrix::kCenter_ScaleToFit);
1261 bool success = rrect.transform(matrix, &transformed);
1262 SkPaint paint;
1263 paint.setAntiAlias(true);
1264 canvas->drawString("rrect", 55, 100, paint);
1265 canvas->drawString(success ? "transformed" : "transform failed", 185, 100, paint);
1266 paint.setStyle(SkPaint::kStroke_Style);
1267 canvas->drawRRect(rrect, paint);
Cary Clark80247e52018-07-11 16:18:41 -04001268 canvas->drawRRect(transformed, paint);
Cary Clark224c7002018-06-27 11:00:21 -04001269##
1270
Cary Clark80247e52018-07-11 16:18:41 -04001271#SeeAlso SkPath::transform
Cary Clark224c7002018-06-27 11:00:21 -04001272
1273#Method ##
1274
1275# ------------------------------------------------------------------------------
1276
1277#Method void dump(bool asHex) const
Cary Clark53498e92018-06-28 19:13:56 -04001278#In Utility
1279#Line # sends text representation to standard output ##
Cary Clark09d80c02018-10-31 12:14:03 -04001280#Populate
Cary Clark224c7002018-06-27 11:00:21 -04001281
1282#Example
Cary Clark09d80c02018-10-31 12:14:03 -04001283SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
1284for (bool dumpAsHex : { false, true } ) {
1285 rrect.dump(dumpAsHex);
Cary Clark53498e92018-06-28 19:13:56 -04001286}
1287#StdOut
Cary Clark09d80c02018-10-31 12:14:03 -04001288SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f);
1289const SkPoint corners[] = {
1290 { 0, 0 },
1291 { 0, 0 },
1292 { 0, 0 },
1293 { 0, 0 },
1294};
1295SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
1296 SkBits2Float(0x3f2aaaab), /* 0.666667 */
1297 SkBits2Float(0x3f5b6db7), /* 0.857143 */
1298 SkBits2Float(0x3f2aaaab) /* 0.666667 */);
1299const SkPoint corners[] = {
1300 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1301 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1302 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1303 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
Cary Clark53498e92018-06-28 19:13:56 -04001304};
1305##
Cary Clark224c7002018-06-27 11:00:21 -04001306##
1307
Cary Clark53498e92018-06-28 19:13:56 -04001308#SeeAlso dumpHex SkRect::dump SkPath::dump SkPathMeasure::dump
Cary Clark224c7002018-06-27 11:00:21 -04001309
1310#Method ##
1311
1312# ------------------------------------------------------------------------------
1313
1314#Method void dump() const
Cary Clark53498e92018-06-28 19:13:56 -04001315#In Utility
1316#Line # sends text representation using floats to standard output ##
Cary Clark09d80c02018-10-31 12:14:03 -04001317#Populate
Cary Clark224c7002018-06-27 11:00:21 -04001318
1319#Example
Cary Clark09d80c02018-10-31 12:14:03 -04001320SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
1321rrect.dump();
1322SkRect bounds = SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f);
1323const SkPoint corners[] = {
1324 { 0, 0 },
1325 { 0, 0 },
1326 { 0, 0 },
1327 { 0, 0 },
1328};
1329SkRRect copy;
1330copy.setRectRadii(bounds, corners);
1331SkDebugf("rrect is " "%s" "equal to copy\n", rrect == copy ? "" : "not ");
Cary Clark53498e92018-06-28 19:13:56 -04001332#StdOut
Cary Clark09d80c02018-10-31 12:14:03 -04001333SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f);
1334const SkPoint corners[] = {
1335 { 0, 0 },
1336 { 0, 0 },
1337 { 0, 0 },
1338 { 0, 0 },
1339};
Cary Clark53498e92018-06-28 19:13:56 -04001340rrect is not equal to copy
1341##
Cary Clark224c7002018-06-27 11:00:21 -04001342##
1343
Cary Clark53498e92018-06-28 19:13:56 -04001344#SeeAlso dumpHex SkRect::dump SkPath::dump SkPathMeasure::dump
Cary Clark224c7002018-06-27 11:00:21 -04001345
1346#Method ##
1347
1348# ------------------------------------------------------------------------------
1349
1350#Method void dumpHex() const
Cary Clark53498e92018-06-28 19:13:56 -04001351#In Utility
1352#Line # sends text representation using hexadecimal to standard output ##
Cary Clark09d80c02018-10-31 12:14:03 -04001353#Populate
Cary Clark224c7002018-06-27 11:00:21 -04001354
1355#Example
Cary Clark09d80c02018-10-31 12:14:03 -04001356SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
1357rrect.dumpHex();
1358SkRect bounds = SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
1359 SkBits2Float(0x3f2aaaab), /* 0.666667 */
1360 SkBits2Float(0x3f5b6db7), /* 0.857143 */
1361 SkBits2Float(0x3f2aaaab) /* 0.666667 */);
1362const SkPoint corners[] = {
1363 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1364 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1365 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1366 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1367};
1368SkRRect copy;
1369copy.setRectRadii(bounds, corners);
Cary Clark53498e92018-06-28 19:13:56 -04001370SkDebugf("rrect is " "%s" "equal to copy\n", rrect == copy ? "" : "not ");
1371#StdOut
Cary Clark09d80c02018-10-31 12:14:03 -04001372SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
1373 SkBits2Float(0x3f2aaaab), /* 0.666667 */
1374 SkBits2Float(0x3f5b6db7), /* 0.857143 */
1375 SkBits2Float(0x3f2aaaab) /* 0.666667 */);
1376const SkPoint corners[] = {
1377 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1378 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1379 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1380 { SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
1381};
Cary Clark53498e92018-06-28 19:13:56 -04001382rrect is equal to copy
1383##
Cary Clark224c7002018-06-27 11:00:21 -04001384##
1385
Cary Clark53498e92018-06-28 19:13:56 -04001386#SeeAlso dump SkRect::dumpHex SkPath::dumpHex
Cary Clark224c7002018-06-27 11:00:21 -04001387
1388#Method ##
1389
1390#Class SkRRect ##
1391
1392#Topic RRect ##