Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1 | #Topic RRect |
| 2 | #Alias Round_Rect ## |
| 3 | #Alias RRect_Reference ## |
| 4 | |
| 5 | #Class SkRRect |
| 6 | |
| 7 | #Private |
| 8 | Path 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 | |
| 25 | The SkRRect class represents a rounded rect with a potentially different |
| 26 | radii for each corner. It does not have a constructor so must be |
| 27 | initialized with one of the initialization functions (e.g., setEmpty, |
| 28 | setRectRadii, etc.) |
| 29 | |
| 30 | This class allows implementing CSS properties that describe rounded corners. |
| 31 | A rectangle may have up to eight radii, one for each axis on each of its four |
| 32 | corners. |
| 33 | |
| 34 | If either corner's radii are zero, the corner is square. |
| 35 | Negative radii are treated as zero. |
| 36 | If 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 Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 56 | #Method SkRRect() |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 57 | #In Constructor |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 58 | #Line # creates with zeroed bounds and corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 59 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 60 | Initializes bounds at (0, 0), the origin, with zero width and height. |
| 61 | Initializes corner radii to (0, 0), and sets type of kEmpty_Type. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 62 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 63 | #Return empty Round_Rect ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 64 | |
| 65 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 66 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 74 | ## |
| 75 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 76 | #SeeAlso setEmpty isEmpty |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 77 | |
| 78 | #Method ## |
| 79 | |
| 80 | # ------------------------------------------------------------------------------ |
| 81 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 82 | #Method SkRRect(const SkRRect& rrect) |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 83 | #In Constructor |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 84 | #Line # copies bounds and corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 85 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 86 | Initializes to copy of rrect bounds and corner radii. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 87 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 88 | #Param rrect bounds and corner to copy ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 89 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 90 | #Return copy of rrect ## |
| 91 | |
| 92 | #Bug 8115 |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 93 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 94 | 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 102 | ## |
| 103 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 104 | #SeeAlso operator=(const SkRRect& rrect) MakeRect |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 105 | |
| 106 | #Method ## |
| 107 | |
| 108 | # ------------------------------------------------------------------------------ |
| 109 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 110 | #Method SkRRect& operator=(const SkRRect& rrect) |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 111 | #In Operator |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 112 | #Line # copies bounds and corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 113 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 114 | Copies rrect bounds and corner radii. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 115 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 116 | #Param rrect bounds and corner to copy ## |
| 117 | |
| 118 | #Return copy of rrect ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 119 | |
| 120 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 121 | 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 129 | ## |
| 130 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 131 | #SeeAlso SkRRect(const SkRRect& rrect) MakeRect |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 132 | |
| 133 | #Method ## |
| 134 | |
| 135 | # ------------------------------------------------------------------------------ |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 136 | #Subtopic Type |
| 137 | #Line # specialization of Round_Rect geometry ## |
| 138 | |
| 139 | #PhraseDef list_of_rrect_types |
| 140 | kEmpty_Type, kRect_Type, kOval_Type, kSimple_Type, kNinePatch_Type, |
| 141 | kComplex_Type |
| 142 | ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 143 | |
| 144 | #Enum Type |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 145 | #Line # specialization of Round_Rect geometry ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 146 | |
| 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 Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 159 | Type describes possible specializations of Round_Rect. Each Type is |
| 160 | exclusive; a Round_Rect may only have one type. |
| 161 | |
| 162 | The enum members become progressively less restrictive; larger values of |
| 163 | Type have more degrees of freedom than smaller values. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 164 | |
| 165 | #Const kEmpty_Type |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 166 | #Line # zero width or height ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 167 | Round_Rect has zero width or height. All radii are zero. |
| 168 | ## |
| 169 | #Const kRect_Type |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 170 | #Line # non-zero width and height, and zeroed radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 171 | Round_Rect has width and height. All radii are zero. |
| 172 | ## |
| 173 | #Const kOval_Type |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 174 | #Line # non-zero width and height filled with radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 175 | Round_Rect has width and height. All four x-radii are equal, |
| 176 | and at least half the width. All four y-radii are equal, |
| 177 | and at least half the height. |
| 178 | ## |
| 179 | #Const kSimple_Type |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 180 | #Line # non-zero width and height with equal radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 181 | Round_Rect has width and height. All four x-radii are equal and |
| 182 | greater than zero, and all four y-radii are equal and greater than |
| 183 | zero. Either x-radii are less than half the width, or y-radii is |
| 184 | less than half the height, or both. |
| 185 | ## |
| 186 | #Const kNinePatch_Type |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 187 | #Line # non-zero width and height with axis-aligned radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 188 | Round_Rect has width and height. Left x-radii are equal, top |
| 189 | y-radii are equal, right x-radii are equal, and bottom y-radii |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 190 | are equal. The radii do not describe a rect, oval, or simple type. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 191 | |
| 192 | The centers of the corner ellipses form an axis-aligned rectangle |
| 193 | that divides the Round_Rect into nine rectangular patches; an |
| 194 | interior rectangle, four edges, and four corners. |
| 195 | ## |
| 196 | #Const kComplex_Type |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 197 | #Line # non-zero width and height with arbitrary radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 198 | both radii are non-zero. |
| 199 | ## |
| 200 | #Const kLastType = kComplex_Type |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 201 | #Line # largest Type value ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 202 | ## |
| 203 | |
| 204 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 205 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 224 | ## |
| 225 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 226 | #SeeAlso Rect Path |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 227 | |
| 228 | #Enum ## |
| 229 | |
| 230 | # ------------------------------------------------------------------------------ |
| 231 | |
| 232 | #Method Type getType() const |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 233 | #In Property |
| 234 | #Line # returns Type ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 235 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 236 | Returns Type, one of: #list_of_rrect_types#. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 237 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 238 | #Return Type ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 239 | |
| 240 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 241 | #Description |
| 242 | rrect2 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 255 | ## |
| 256 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 257 | #SeeAlso Type type |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 258 | |
| 259 | #Method ## |
| 260 | |
| 261 | # ------------------------------------------------------------------------------ |
| 262 | |
| 263 | #Method Type type() const |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 264 | #In Property |
| 265 | #Line # returns Type ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 266 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 267 | Returns Type, one of: #list_of_rrect_types#. |
| 268 | |
| 269 | #Return Type ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 270 | |
| 271 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 272 | #Description |
| 273 | inset() 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 286 | ## |
| 287 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 288 | #SeeAlso Type getType |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 289 | |
| 290 | #Method ## |
| 291 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 292 | #Subtopic Type ## |
| 293 | |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 294 | # ------------------------------------------------------------------------------ |
| 295 | |
| 296 | #Method inline bool isEmpty() const |
| 297 | #In Property |
| 298 | #Line # returns true if width or height are zero ## |
| 299 | Returns true if rect().fLeft is equal to rect().fRight, or if rect().fTop is equal |
| 300 | to 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 ## |
| 328 | Returns 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 ## |
| 357 | Returns true if not empty, if all x-axis radii are equal, if all y-axis radii |
| 358 | are equal, x-axis radii are at least half the width, and y-axis radii are at |
| 359 | least half the height. |
| 360 | |
| 361 | #Return true if has identical geometry to Oval ## |
| 362 | |
| 363 | #Example |
| 364 | #Height 100 |
| 365 | #Description |
| 366 | The first radii are scaled down proportionately until both x-axis and y-axis fit |
| 367 | within the bounds. After scaling, x-axis radius is smaller than half the width; |
| 368 | left round rect is not an oval. The second radii are equal to half the |
| 369 | dimensions; 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 ## |
| 393 | Returns true if not empty, if all x-axis radii are equal but not zero, |
| 394 | if all y-axis radii are equal but not zero; and x-axis radius is less than half |
| 395 | width(), 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 ## |
| 427 | Returns true if isEmpty, isRect, isOval, and isSimple return false; and if |
| 428 | left x-axis radii are equal, right x-axis radii are equal, top y-axis radii are |
| 429 | equal, 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 | |
| 462 | Returns true if isEmpty, isRect, isOval, isSimple, and isNinePatch return false. |
| 463 | If true: width and height are greater than zero, at least one corner radii are |
| 464 | both greater than zero; left x-axis radii are not equal, or right x-axis radii |
| 465 | are not equal, or top y-axis radii are not equal, or bottom y-axis radii are not |
| 466 | equal. |
| 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 ## |
| 496 | Returns span on the x-axis. This does not check if result fits in 32-bit float; |
| 497 | result may be infinity. |
| 498 | |
| 499 | #Return bounds().fRight minus bounds().fLeft ## |
| 500 | |
| 501 | #Example |
| 502 | #Description |
| 503 | SkRRect::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 |
| 510 | unsorted width: 5
|
| 511 | large 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 ## |
| 524 | Returns span on the y-axis. This does not check if result fits in 32-bit float; |
| 525 | result may be infinity. |
| 526 | |
| 527 | #Return bounds().fBottom minus bounds().fTop ## |
| 528 | |
| 529 | #Example |
| 530 | #Description |
| 531 | SkRRect::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 |
| 538 | unsorted height: 5
|
| 539 | large 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 | |
| 553 | Returns top-left corner x-radii. If type() returns kEmpty_Type, kRect_Type, |
| 554 | kOval_Type, or kSimple_Type, returns a value representative of all corner radii. |
| 555 | If type() returns kNinePatch_Type or kComplex_Type, at least one of the |
| 556 | remaining 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 | |
| 589 | Sets bounds to zero width and height at (0, 0), the origin. Sets |
| 590 | corner radii to zero and sets type to kEmpty_Type. |
| 591 | |
| 592 | #Example |
| 593 | #Description |
| 594 | Nothing 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 | |
| 614 | Sets bounds to sorted rect, and sets corner radii to zero. |
| 615 | If set bounds has width and height, and sets type to kRect_Type; |
| 616 | otherwise, sets type to kEmpty_Type. |
| 617 | |
| 618 | #Param rect bounds to set ## |
| 619 | |
| 620 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 621 | #Height 90 |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 622 | 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 Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 638 | #Line # creates with zeroed bounds and corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 639 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 640 | Initializes bounds at (0, 0), the origin, with zero width and height. |
| 641 | Initializes corner radii to (0, 0), and sets type of kEmpty_Type. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 642 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 643 | #Return empty Round_Rect ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 644 | |
| 645 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 646 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 658 | ## |
| 659 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 660 | #SeeAlso SkRRect() SkRect::MakeEmpty |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 661 | |
| 662 | #Method ## |
| 663 | |
| 664 | # ------------------------------------------------------------------------------ |
| 665 | |
| 666 | #Method static SkRRect MakeRect(const SkRect& r) |
| 667 | #In Constructor |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 668 | #Line # copies bounds and zeroes corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 669 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 670 | Initializes to copy of r bounds and zeroes corner radii. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 671 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 672 | #Param r bounds to copy ## |
| 673 | |
| 674 | #Return copy of r ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 675 | |
| 676 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 677 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 684 | ## |
| 685 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 686 | #SeeAlso setRect MakeOval MakeRectXY |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 687 | |
| 688 | #Method ## |
| 689 | |
| 690 | # ------------------------------------------------------------------------------ |
| 691 | |
| 692 | #Method static SkRRect MakeOval(const SkRect& oval) |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 693 | #In Constructor |
| 694 | #Line # creates Oval to fit bounds ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 695 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 696 | Sets bounds to oval, x-axis radii to half oval.width(), and all y-axis radii |
| 697 | to half oval.height(). If rect is empty, sets to kEmpty_Type. |
| 698 | Otherwise, sets to kOval_Type. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 699 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 700 | #Param oval bounds of Oval ## |
| 701 | |
| 702 | #Return Oval ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 703 | |
| 704 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 705 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 713 | ## |
| 714 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 715 | #SeeAlso setOval MakeRect MakeRectXY |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 716 | |
| 717 | #Method ## |
| 718 | |
| 719 | # ------------------------------------------------------------------------------ |
| 720 | |
| 721 | #Method static SkRRect MakeRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad) |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 722 | #In Constructor |
| 723 | #Line # creates rounded rectangle ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 724 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 725 | Sets to rounded rectangle with the same radii for all four corners. |
| 726 | If rect is empty, sets to kEmpty_Type. |
| 727 | Otherwise, if xRad and yRad are zero, sets to kRect_Type. |
| 728 | Otherwise, if xRad is at least half rect.width() and yRad is at least half |
| 729 | rect.height(), sets to kOval_Type. |
| 730 | Otherwise, sets to kSimple_Type. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 731 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 732 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 737 | |
| 738 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 739 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 747 | ## |
| 748 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 749 | #SeeAlso setRectXY |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 750 | |
| 751 | #Method ## |
| 752 | |
| 753 | # ------------------------------------------------------------------------------ |
| 754 | |
| 755 | #Method void setOval(const SkRect& oval) |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 756 | #In Set |
| 757 | #Line # replaces with Oval to fit bounds ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 758 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 759 | Sets bounds to oval, x-axis radii to half oval.width(), and all y-axis radii |
| 760 | to half oval.height(). If rect is empty, sets to kEmpty_Type. |
| 761 | Otherwise, sets to kOval_Type. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 762 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 763 | #Param oval bounds of Oval ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 764 | |
| 765 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 766 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 774 | ## |
| 775 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 776 | #SeeAlso MakeOval |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 777 | |
| 778 | #Method ## |
| 779 | |
| 780 | # ------------------------------------------------------------------------------ |
| 781 | |
| 782 | #Method void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad) |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 783 | #In Set |
| 784 | #Line # replaces with rounded rectangle ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 785 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 786 | Sets to rounded rectangle with the same radii for all four corners. |
| 787 | If rect is empty, sets to kEmpty_Type. |
| 788 | Otherwise, if xRad or yRad is zero, sets to kRect_Type. |
| 789 | Otherwise, if xRad is at least half rect.width() and yRad is at least half |
| 790 | rect.height(), sets to kOval_Type. |
| 791 | Otherwise, sets to kSimple_Type. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 792 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 793 | #Param rect bounds of rounded rectangle ## |
| 794 | #Param xRad x-axis radius of corners ## |
| 795 | #Param yRad y-axis radius of corners ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 796 | |
| 797 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 798 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 806 | ## |
| 807 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 808 | #SeeAlso MakeRectXY SkPath::addRoundRect |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 809 | |
| 810 | #Method ## |
| 811 | |
| 812 | # ------------------------------------------------------------------------------ |
| 813 | |
| 814 | #Method void setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad, |
| 815 | SkScalar rightRad, SkScalar bottomRad) |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 816 | #In Set |
| 817 | #Line # replaces with rounded rectangle ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 818 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 819 | Sets bounds to rect. Sets radii to (leftRad, topRad), (rightRad, topRad), |
| 820 | (rightRad, bottomRad), (leftRad, bottomRad). |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 821 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 822 | If rect is empty, sets to kEmpty_Type. |
| 823 | Otherwise, if leftRad and rightRad are zero, sets to kRect_Type. |
| 824 | Otherwise, if topRad and bottomRad are zero, sets to kRect_Type. |
| 825 | Otherwise, if leftRad and rightRad are equal and at least half rect.width(), and |
| 826 | topRad and bottomRad are equal at least half rect.height(), sets to kOval_Type. |
| 827 | Otherwise, if leftRad and rightRad are equal, and topRad and bottomRad are equal, |
| 828 | sets to kSimple_Type. Otherwise, sets to kNinePatch_Type. |
| 829 | |
| 830 | Nine patch refers to the nine parts defined by the radii: one center rectangle, |
| 831 | four 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 838 | |
| 839 | #Example |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 840 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 856 | ## |
| 857 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 858 | #SeeAlso setRectRadii |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 859 | |
| 860 | #Method ## |
| 861 | |
| 862 | # ------------------------------------------------------------------------------ |
| 863 | |
| 864 | #Method void setRectRadii(const SkRect& rect, const SkVector radii[4]) |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 865 | #In Set |
| 866 | #Line # replaces with rounded rectangle ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 867 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 868 | Sets bounds to rect. Sets radii array for individual control of all for corners. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 869 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 870 | If rect is empty, sets to kEmpty_Type. |
| 871 | Otherwise, if one of each corner radii are zero, sets to kRect_Type. |
| 872 | Otherwise, if all x-axis radii are equal and at least half rect.width(), and |
| 873 | all y-axis radii are equal at least half rect.height(), sets to kOval_Type. |
| 874 | Otherwise, if all x-axis radii are equal, and all y-axis radii are equal, |
| 875 | sets 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 879 | |
| 880 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 881 | 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 898 | ## |
| 899 | |
Cary Clark | 82f1f74 | 2018-06-28 08:50:35 -0400 | [diff] [blame] | 900 | #SeeAlso setNinePatch SkPath::addRoundRect |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 901 | |
| 902 | #Method ## |
| 903 | |
| 904 | # ------------------------------------------------------------------------------ |
| 905 | |
| 906 | #Enum Corner |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 907 | #Line # corner radii order ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 908 | |
| 909 | #Code |
| 910 | enum Corner { |
| 911 | kUpperLeft_Corner, |
| 912 | kUpperRight_Corner, |
| 913 | kLowerRight_Corner, |
| 914 | kLowerLeft_Corner, |
| 915 | }; |
| 916 | ## |
| 917 | |
| 918 | The radii are stored: top-left, top-right, bottom-right, bottom-left. |
| 919 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 920 | #Const kUpperLeft_Corner 0 |
| 921 | #Line # index of top-left corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 922 | ## |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 923 | #Const kUpperRight_Corner 1 |
| 924 | #Line # index of top-right corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 925 | ## |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 926 | #Const kLowerRight_Corner 2 |
| 927 | #Line # index of bottom-right corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 928 | ## |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 929 | #Const kLowerLeft_Corner 3 |
| 930 | #Line # index of bottom-left corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 931 | ## |
| 932 | |
| 933 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 934 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 951 | ## |
| 952 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 953 | #SeeAlso radii |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 954 | |
| 955 | #Enum ## |
| 956 | |
| 957 | # ------------------------------------------------------------------------------ |
| 958 | |
| 959 | #Method const SkRect& rect() const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 960 | #In Property |
| 961 | #Line # returns bounds ## |
| 962 | Returns bounds. Bounds may have zero width or zero height. Bounds right is |
| 963 | greater than or equal to left; bounds bottom is greater than or equal to top. |
| 964 | Result is identical to getBounds. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 965 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 966 | #Return bounding box ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 967 | |
| 968 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 969 | 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 |
| 974 | left bounds: (nan) 0
|
| 975 | left bounds: (inf) 0
|
| 976 | left bounds: (100) 60
|
| 977 | left bounds: (50) 50
|
| 978 | left bounds: (25) 25 |
| 979 | ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 980 | ## |
| 981 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 982 | #SeeAlso getBounds |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 983 | |
| 984 | #Method ## |
| 985 | |
| 986 | # ------------------------------------------------------------------------------ |
| 987 | |
| 988 | #Method SkVector radii(Corner corner) const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 989 | #In Property |
| 990 | #Line # returns x-axis and y-axis radii for one corner ## |
| 991 | Returns Scalar pair for radius of curve on x-axis and y-axis for one corner. |
| 992 | Both radii may be zero. If not zero, both are positive and finite. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 993 | |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 994 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 995 | #Param corner one of: kUpperLeft_Corner, kUpperRight_Corner, |
| 996 | kLowerRight_Corner, kLowerLeft_Corner |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 997 | ## |
| 998 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 999 | #Return x-axis and y-axis radii for one corner ## |
| 1000 | |
| 1001 | #Example |
| 1002 | #Description |
| 1003 | Finite values are scaled proportionately to fit; other values are set to zero. |
| 1004 | Scaled values cannot be larger than 25, half the bounding rect width. |
| 1005 | Small scaled values are halved to scale in proportion to the y-axis corner |
| 1006 | radius, 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 |
| 1013 | left corner: (nan) 0
|
| 1014 | left corner: (inf) 0
|
| 1015 | left corner: (100) 25
|
| 1016 | left corner: (50) 25
|
| 1017 | left corner: (25) 12.5 |
| 1018 | ## |
| 1019 | ## |
| 1020 | |
| 1021 | #SeeAlso Corner |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1022 | |
| 1023 | #Method ## |
| 1024 | |
| 1025 | # ------------------------------------------------------------------------------ |
| 1026 | |
| 1027 | #Method const SkRect& getBounds() const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1028 | #In Property |
| 1029 | #Line # returns bounds ## |
| 1030 | Returns bounds. Bounds may have zero width or zero height. Bounds right is |
| 1031 | greater than or equal to left; bounds bottom is greater than or equal to top. |
| 1032 | Result is identical to rect(). |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1033 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1034 | #Return bounding box ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1035 | |
| 1036 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1037 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1044 | ## |
| 1045 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1046 | #SeeAlso rect |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1047 | |
| 1048 | #Method ## |
| 1049 | |
| 1050 | # ------------------------------------------------------------------------------ |
| 1051 | |
| 1052 | #Method bool operator==(const SkRRect& a, const SkRRect& b) |
| 1053 | #In Operator |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1054 | #Line # returns true if members are equal ## |
| 1055 | Returns true if bounds and radii in a are equal to bounds and radii in b. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1056 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1057 | a and b are not equal if either contain NaN. a and b are equal if members |
| 1058 | contain zeroes width different signs. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1059 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1060 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1064 | |
| 1065 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1066 | 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1078 | ## |
| 1079 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1080 | #SeeAlso operator!=(const SkRRect& a, const SkRRect& b) |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1081 | |
| 1082 | #Method ## |
| 1083 | |
| 1084 | # ------------------------------------------------------------------------------ |
| 1085 | |
| 1086 | #Method bool operator!=(const SkRRect& a, const SkRRect& b) |
| 1087 | #In Operator |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1088 | #Line # returns true if members are unequal ## |
| 1089 | Returns true if bounds and radii in a are not equal to bounds and radii in b. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1090 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1091 | a and b are not equal if either contain NaN. a and b are equal if members |
| 1092 | contain zeroes width different signs. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1093 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1094 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1098 | |
| 1099 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1100 | 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1112 | ## |
| 1113 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1114 | #SeeAlso operator==(const SkRRect& a, const SkRRect& b) |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1115 | |
| 1116 | #Method ## |
| 1117 | |
| 1118 | # ------------------------------------------------------------------------------ |
| 1119 | |
| 1120 | #Method void inset(SkScalar dx, SkScalar dy, SkRRect* dst) const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1121 | #In Inset_Outset_Offset |
| 1122 | #Line # insets bounds and radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1123 | |
| 1124 | Calls inset on the bounds, and adjust the radii to reflect what happens. |
| 1125 | If the corner is sharp (no curvature), leave it alone, |
| 1126 | otherwise we grow/shrink the radii by the amount of the inset. If a |
| 1127 | given radius becomes negative, it is pinned to 0. |
| 1128 | If the inset amount is larger than the width/height then the rrect collapses to |
| 1129 | a degenerate line or point. |
| 1130 | If the inset is sufficiently negative to cause the bounds to become infinite then |
| 1131 | the result is a default initialized rrect. |
| 1132 | It is valid for dst == this. |
| 1133 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1134 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1137 | |
| 1138 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1139 | 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1147 | ## |
| 1148 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1149 | #SeeAlso outset offset makeOffset |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1150 | |
| 1151 | #Method ## |
| 1152 | |
| 1153 | # ------------------------------------------------------------------------------ |
| 1154 | |
| 1155 | #Method void inset(SkScalar dx, SkScalar dy) |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1156 | #In Inset_Outset_Offset |
| 1157 | #Line # insets bounds and radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1158 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1159 | #Param dx added to rect().fLeft, and subtracted from rect().fRight ## |
| 1160 | #Param dy added to rect().fTop, and subtracted from rect().fBottom ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1161 | |
| 1162 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1163 | 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1171 | ## |
| 1172 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1173 | #SeeAlso outset offset makeOffset |
| 1174 | |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1175 | |
| 1176 | #Method ## |
| 1177 | |
| 1178 | # ------------------------------------------------------------------------------ |
| 1179 | |
| 1180 | #Method void outset(SkScalar dx, SkScalar dy, SkRRect* dst) const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1181 | #In Inset_Outset_Offset |
| 1182 | #Line # outsets bounds and radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1183 | |
| 1184 | Call outset on the bounds, and adjust the radii to reflect what happens |
| 1185 | in stroking. If the corner is sharp (no curvature), leave it alone, |
| 1186 | otherwise we grow/shrink the radii by the amount of the inset. If a |
| 1187 | given radius becomes negative, it is pinned to 0. |
| 1188 | It is valid for dst == this. |
| 1189 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1190 | #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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1193 | |
| 1194 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1195 | 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1203 | ## |
| 1204 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1205 | #SeeAlso inset offset makeOffset |
| 1206 | |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1207 | |
| 1208 | #Method ## |
| 1209 | |
| 1210 | # ------------------------------------------------------------------------------ |
| 1211 | |
| 1212 | #Method void outset(SkScalar dx, SkScalar dy) |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1213 | #In Inset_Outset_Offset |
| 1214 | #Line # outsets bounds and radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1215 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1216 | #Param dx subtracted from rect().fLeft, and added to rect().fRight ## |
| 1217 | #Param dy subtracted from rect().fTop, and added to rect().fBottom ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1218 | |
| 1219 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1220 | 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1228 | ## |
| 1229 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1230 | #SeeAlso inset offset makeOffset |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1231 | |
| 1232 | #Method ## |
| 1233 | |
| 1234 | # ------------------------------------------------------------------------------ |
| 1235 | |
| 1236 | #Method void offset(SkScalar dx, SkScalar dy) |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1237 | #In Inset_Outset_Offset |
| 1238 | #Line # offsets bounds and radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1239 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1240 | Translates the rrect by (dx, dy). |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1241 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1242 | #Param dx offset added to rect().fLeft and rect().fRight ## |
| 1243 | #Param dy offset added to rect().fTop and rect().fBottom ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1244 | |
| 1245 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1246 | 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1254 | ## |
| 1255 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1256 | #SeeAlso makeOffset inset outset |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1257 | |
| 1258 | #Method ## |
| 1259 | |
| 1260 | # ------------------------------------------------------------------------------ |
| 1261 | |
| 1262 | #Method SkRRect SK_WARN_UNUSED_RESULT makeOffset(SkScalar dx, SkScalar dy) const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1263 | #In Inset_Outset_Offset |
| 1264 | #Line # offsets bounds and radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1265 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1266 | #Param dx offset added to rect().fLeft and rect().fRight ## |
| 1267 | #Param dy offset added to rect().fTop and rect().fBottom ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1268 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1269 | #Return Round_Rect bounds offset by (dx, dy), with unchanged corner radii ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1270 | |
| 1271 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1272 | 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1280 | ## |
| 1281 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1282 | #SeeAlso offset inset outset |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1283 | |
| 1284 | #Method ## |
| 1285 | |
| 1286 | # ------------------------------------------------------------------------------ |
| 1287 | |
| 1288 | #Method bool contains(const SkRect& rect) const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1289 | #In Intersection |
| 1290 | #Line # returns true if Rect is inside ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1291 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1292 | Returns true if rect is inside the bounds and corner radii, and if |
| 1293 | Round_Rect and rect are not empty. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1294 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1295 | #Param rect area tested for containment ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1296 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1297 | #Return true if Round_Rect contains rect ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1298 | |
| 1299 | #Example |
| 1300 | // incomplete |
| 1301 | ## |
| 1302 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1303 | #SeeAlso SkRect::contains |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1304 | |
| 1305 | #Method ## |
| 1306 | |
| 1307 | # ------------------------------------------------------------------------------ |
| 1308 | |
| 1309 | #Method bool isValid() const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1310 | #In Utility |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1311 | #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 Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1337 | #In Utility |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1338 | #Line # incomplete ## |
| 1339 | |
| 1340 | Write the rrect into the specified buffer. This is guaranteed to always |
| 1341 | write kSizeInMemory bytes, and that value is guaranteed to always be |
| 1342 | a 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 Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1359 | #In Utility |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1360 | #Line # incomplete ## |
| 1361 | |
| 1362 | Reads the rrect from the specified buffer. |
| 1363 | If the specified buffer is large enough, this will read kSizeInMemory bytes, |
| 1364 | and 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 Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1386 | #In Inset_Outset_Offset |
| 1387 | #Line # scales and offsets into copy ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1388 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1389 | Transforms by Round_Rect by matrix, storing result in dst. |
| 1390 | Returns true if Round_Rect transformed can be represented by another Round_Rect. |
| 1391 | Returns false if matrix contains transformations other than scale and translate. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1392 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1393 | Asserts in debug builds if Round_Rect equals dst. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1394 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1395 | #Param matrix SkMatrix specifying the transform ## |
| 1396 | #Param dst SkRRect to store the result ## |
| 1397 | |
| 1398 | #Return true if transformation succeeded. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1399 | ## |
| 1400 | |
| 1401 | #Example |
| 1402 | // incomplete |
| 1403 | ## |
| 1404 | |
| 1405 | #SeeAlso incomplete |
| 1406 | |
| 1407 | #Method ## |
| 1408 | |
| 1409 | # ------------------------------------------------------------------------------ |
| 1410 | |
| 1411 | #Method void dump(bool asHex) const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1412 | #In Utility |
| 1413 | #Line # sends text representation to standard output ## |
| 1414 | Writes text representation of Round_Rect to standard output. |
| 1415 | Set asHex true to generate exact binary representations |
| 1416 | of floating point numbers. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1417 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1418 | #Param asHex true if SkScalar values are written as hexadecimal ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1419 | |
| 1420 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1421 | SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
|
| 1422 | for (bool dumpAsHex : { false, true } ) {
|
| 1423 | rrect.dump(dumpAsHex);
|
| 1424 | } |
| 1425 | #StdOut |
| 1426 | SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f);
|
| 1427 | const SkPoint corners[] = {
|
| 1428 | { 0, 0 },
|
| 1429 | { 0, 0 },
|
| 1430 | { 0, 0 },
|
| 1431 | { 0, 0 },
|
| 1432 | };
|
| 1433 | SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
| 1434 | SkBits2Float(0x3f2aaaab), /* 0.666667 */
|
| 1435 | SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
| 1436 | SkBits2Float(0x3f2aaaab) /* 0.666667 */);
|
| 1437 | const 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 Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1444 | ## |
| 1445 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1446 | #SeeAlso dumpHex SkRect::dump SkPath::dump SkPathMeasure::dump |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1447 | |
| 1448 | #Method ## |
| 1449 | |
| 1450 | # ------------------------------------------------------------------------------ |
| 1451 | |
| 1452 | #Method void dump() const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1453 | #In Utility |
| 1454 | #Line # sends text representation using floats to standard output ## |
| 1455 | Writes text representation of Round_Rect to standard output. The representation |
| 1456 | may be directly compiled as C++ code. Floating point values are written |
| 1457 | with limited precision; it may not be possible to reconstruct original |
| 1458 | Round_Rect from output. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1459 | |
| 1460 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1461 | SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
|
| 1462 | rrect.dump();
|
| 1463 | SkRect bounds = SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f);
|
| 1464 | const SkPoint corners[] = {
|
| 1465 | { 0, 0 },
|
| 1466 | { 0, 0 },
|
| 1467 | { 0, 0 },
|
| 1468 | { 0, 0 },
|
| 1469 | };
|
| 1470 | SkRRect copy;
|
| 1471 | copy.setRectRadii(bounds, corners);
|
| 1472 | SkDebugf("rrect is " "%s" "equal to copy\n", rrect == copy ? "" : "not ");
|
| 1473 | #StdOut |
| 1474 | SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f);
|
| 1475 | const SkPoint corners[] = {
|
| 1476 | { 0, 0 },
|
| 1477 | { 0, 0 },
|
| 1478 | { 0, 0 },
|
| 1479 | { 0, 0 },
|
| 1480 | };
|
| 1481 | rrect is not equal to copy |
| 1482 | ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1483 | ## |
| 1484 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1485 | #SeeAlso dumpHex SkRect::dump SkPath::dump SkPathMeasure::dump |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1486 | |
| 1487 | #Method ## |
| 1488 | |
| 1489 | # ------------------------------------------------------------------------------ |
| 1490 | |
| 1491 | #Method void dumpHex() const |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1492 | #In Utility |
| 1493 | #Line # sends text representation using hexadecimal to standard output ## |
| 1494 | Writes text representation of Round_Rect to standard output. The representation |
| 1495 | may be directly compiled as C++ code. Floating point values are written |
| 1496 | in hexadecimal to preserve their exact bit pattern. The output reconstructs the |
| 1497 | original Round_Rect. |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1498 | |
| 1499 | #Example |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1500 | SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
|
| 1501 | rrect.dumpHex();
|
| 1502 | SkRect bounds = SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
| 1503 | SkBits2Float(0x3f2aaaab), /* 0.666667 */
|
| 1504 | SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
| 1505 | SkBits2Float(0x3f2aaaab) /* 0.666667 */);
|
| 1506 | const 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 | };
|
| 1512 | SkRRect copy;
|
| 1513 | copy.setRectRadii(bounds, corners);
|
| 1514 | SkDebugf("rrect is " "%s" "equal to copy\n", rrect == copy ? "" : "not "); |
| 1515 | #StdOut |
| 1516 | SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
| 1517 | SkBits2Float(0x3f2aaaab), /* 0.666667 */
|
| 1518 | SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
| 1519 | SkBits2Float(0x3f2aaaab) /* 0.666667 */);
|
| 1520 | const 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 | };
|
| 1526 | rrect is equal to copy |
| 1527 | ## |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1528 | ## |
| 1529 | |
Cary Clark | 53498e9 | 2018-06-28 19:13:56 -0400 | [diff] [blame] | 1530 | #SeeAlso dump SkRect::dumpHex SkPath::dumpHex |
Cary Clark | 224c700 | 2018-06-27 11:00:21 -0400 | [diff] [blame] | 1531 | |
| 1532 | #Method ## |
| 1533 | |
| 1534 | #Class SkRRect ## |
| 1535 | |
| 1536 | #Topic RRect ## |