1 #Topic RRect 2 #Alias Round_Rect ## 3 #Alias RRect_Reference ## 4 5 #Class SkRRect 6 7 #Code 8 class SkRRect { 9 public: 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 79 SkRRect describes a rounded rectangle with a bounds and a pair of radii for each corner. 80 The bounds and radii can be set so that SkRRect describes: a rectangle with sharp corners; 81 a Circle; an Oval; or a rectangle with one or more rounded corners. 82 83 SkRRect allows implementing CSS properties that describe rounded corners. 84 SkRRect may have up to eight different radii, one for each axis on each of its four 85 corners. 86 87 SkRRect may modify the provided parameters when initializing bounds and radii. 88 If either axis radii is zero or less: radii are stored as zero; corner is square. 89 If corner curves overlap, radii are proportionally reduced to fit within bounds. 90 91 # ------------------------------------------------------------------------------ 92 93 #Method SkRRect() 94 #In Constructors 95 #Line # creates with zeroed bounds and corner radii ## 96 #Populate 97 98 #Example 99 #Height 60 100 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); 107 ## 108 109 #SeeAlso setEmpty isEmpty 110 111 #Method ## 112 113 # ------------------------------------------------------------------------------ 114 115 #Method SkRRect(const SkRRect& rrect) 116 #In Constructors 117 #Line # copies bounds and corner radii ## 118 #Populate 119 120 #Example 121 #Height 60 122 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); 130 ## 131 132 #SeeAlso operator=(const SkRRect& rrect) MakeRect 133 134 #Method ## 135 136 # ------------------------------------------------------------------------------ 137 138 #Method SkRRect& operator=(const SkRRect& rrect) 139 #In Operators 140 #Line # copies bounds and corner radii ## 141 #Populate 142 143 #Example 144 #Height 110 145 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); 152 canvas->drawRRect(rrect2, p); 153 ## 154 155 #SeeAlso SkRRect(const SkRRect& rrect) MakeRect 156 157 #Method ## 158 159 # ------------------------------------------------------------------------------ 160 #Subtopic Type 161 #Line # specialization of Round_Rect geometry ## 162 163 #PhraseDef list_of_rrect_types 164 kEmpty_Type, kRect_Type, kOval_Type, kSimple_Type, kNinePatch_Type, 165 kComplex_Type 166 ## 167 168 #Enum Type 169 #Line # specialization of Round_Rect geometry ## 170 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 183 Type describes possible specializations of Round_Rect. Each Type is 184 exclusive; a Round_Rect may only have one type. 185 186 Type members become progressively less restrictive; larger values of 187 Type have more degrees of freedom than smaller values. 188 189 #Const kEmpty_Type 0 190 #Line # zero width or height ## 191 Round_Rect has zero width or height. All radii are zero. 192 ## 193 #Const kRect_Type 1 194 #Line # non-zero width and height, and zeroed radii ## 195 Round_Rect has width and height. All radii are zero. 196 ## 197 #Const kOval_Type 2 198 #Line # non-zero width and height filled with radii ## 199 Round_Rect has width and height. All four x-radii are equal, 200 and at least half the width. All four y-radii are equal, 201 and at least half the height. 202 ## 203 #Const kSimple_Type 3 204 #Line # non-zero width and height with equal radii ## 205 Round_Rect has width and height. All four x-radii are equal and 206 greater than zero, and all four y-radii are equal and greater than 207 zero. Either x-radii are less than half the width, or y-radii is 208 less than half the height, or both. 209 ## 210 #Const kNinePatch_Type 4 211 #Line # non-zero width and height with axis-aligned radii ## 212 Round_Rect has width and height. Left x-radii are equal, top 213 y-radii are equal, right x-radii are equal, and bottom y-radii 214 are equal. The radii do not describe Rect, Oval, or simple type. 215 216 The centers of the corner ellipses form an axis-aligned rectangle 217 that divides the Round_Rect into nine rectangular patches; an 218 interior rectangle, four edges, and four corners. 219 ## 220 #Const kComplex_Type 5 221 #Line # non-zero width and height with arbitrary radii ## 222 both radii are non-zero. 223 ## 224 #Const kLastType 5 225 #Line # largest Type value ## 226 ## 227 228 #Example 229 #Height 128 230 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}}}); 246 drawRRectType({160, 80, 210, 100}, {{{ 5, 5}, {10, 5}, { 5, 5}, { 5, 5}}}); 247 ## 248 249 #SeeAlso Rect Path 250 251 #Enum ## 252 253 # ------------------------------------------------------------------------------ 254 255 #Method Type getType() const 256 #In Property 257 #Line # returns Type ## 258 259 Returns Type, one of: #list_of_rrect_types#. 260 261 #Return Type ## 262 263 #Example 264 #Height 100 265 #Description 266 rrect2 is not a Rect; inset() has made it empty. 267 ## 268 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()); 278 canvas->drawRRect(rrect2, p); 279 ## 280 281 #SeeAlso Type type 282 283 #Method ## 284 285 # ------------------------------------------------------------------------------ 286 287 #Method Type type() const 288 #In Property 289 #Line # returns Type ## 290 291 Returns Type, one of: #list_of_rrect_types#. 292 293 #Return Type ## 294 295 #Example 296 #Height 100 297 #Description 298 inset() has made rrect2 empty. 299 ## 300 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()); 310 canvas->drawRRect(rrect2, p); 311 ## 312 313 #SeeAlso Type getType 314 315 #Method ## 316 317 #Subtopic Type ## 318 319 # ------------------------------------------------------------------------------ 320 321 #Method bool isEmpty() const 322 #In Property 323 #Line # returns true if width or height are zero ## 324 #Populate 325 326 #Example 327 #Height 100 328 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); 337 canvas->drawString(rrect.isEmpty() ? "empty" : "not empty", 64, 90, paint); 338 ## 339 340 #SeeAlso SkRect::isEmpty height width 341 342 #Method ## 343 344 # ------------------------------------------------------------------------------ 345 346 #Method bool isRect() const 347 #In Property 348 #Line # returns true if not empty, and one radius at each corner is zero ## 349 #Populate 350 351 #Example 352 #Height 100 353 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); 363 canvas->drawString(rrect.isRect() ? "rect" : "not rect", 64, 90, paint); 364 ## 365 366 #SeeAlso isEmpty radii 367 368 #Method ## 369 370 # ------------------------------------------------------------------------------ 371 372 #Method bool isOval() const 373 #In Property 374 #Line # returns true if not empty, axes radii are equal, radii fill bounds ## 375 #Populate 376 377 #Example 378 #Height 100 379 #Description 380 The first radii are scaled down proportionately until both x-axis and y-axis fit 381 within the bounds. After scaling, x-axis radius is smaller than half the width; 382 left Round_Rect is not an oval. The second radii are equal to half the 383 dimensions; right Round_Rect is an oval. 384 ## 385 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); 394 canvas->drawString(rrect.isOval() ? "oval" : "not oval", 64, 90, paint); 395 ## 396 397 #SeeAlso isEmpty isSimple SkCanvas::drawOval 398 399 #Method ## 400 401 # ------------------------------------------------------------------------------ 402 403 #Method bool isSimple() const 404 #In Property 405 #Line # returns true if not empty, Rect or Oval; and axes radii are equal ## 406 #Populate 407 408 #Example 409 #Height 100 410 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); 422 canvas->drawString(rrect.isSimple() ? "simple" : "not simple", 64, 90, paint); 423 ## 424 425 #SeeAlso isEmpty isRect isOval isNinePatch 426 427 #Method ## 428 429 # ------------------------------------------------------------------------------ 430 431 #Method bool isNinePatch() const 432 #In Property 433 #Line # returns true if not empty, Rect, Oval or simple; and radii are axis-aligned ## 434 #Populate 435 436 #Example 437 #Height 100 438 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); 450 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 459 #Method bool isComplex() const 460 #In Property 461 #Line # returns true if not empty, Rect, Oval, simple, or nine-patch ## 462 #Populate 463 464 #Example 465 #Height 100 466 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); 478 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 489 #Line # returns span in x-axis ## 490 #Populate 491 492 #Example 493 #Description 494 SkRRect::MakeRect sorts its input, so width() is always zero or larger. 495 ## 496 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 }); 499 SkDebugf("large width: %.0f\n", large.width()); 500 #StdOut 501 unsorted width: 5 502 large 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 514 #Line # returns span in y-axis ## 515 #Populate 516 517 #Example 518 #Description 519 SkRRect::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 526 unsorted height: 5 527 large height: inf 528 ## 529 ## 530 531 #SeeAlso SkRect::height width getBounds 532 533 #Method ## 534 535 # ------------------------------------------------------------------------------ 536 537 #Method SkVector getSimpleRadii() const 538 #In Property 539 #Line # returns corner radii for simple types ## 540 #Populate 541 542 #Example 543 #Height 100 544 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); 559 ## 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 ## 570 #Populate 571 572 #Example 573 #Height 80 574 #Description 575 Nothing blue is drawn because Round_Rect is set to empty. 576 ## 577 SkPaint paint; 578 SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60}); 579 canvas->drawRRect(rrect, paint); 580 rrect.setEmpty(); 581 paint.setColor(SK_ColorBLUE); 582 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 593 #Line # sets Round_Rect bounds with zeroed corners ## 594 #Populate 595 596 #Example 597 #Height 90 598 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); 603 canvas->drawRRect(rrect, paint); 604 ## 605 606 #SeeAlso MakeRect setRectXY 607 608 #Method ## 609 610 # ------------------------------------------------------------------------------ 611 612 #Method static SkRRect MakeEmpty() 613 #In Constructors 614 #Line # creates with zeroed bounds and corner radii ## 615 #Populate 616 617 #Example 618 #Height 90 619 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()); 629 canvas->drawRRect(rrect2, p); 630 ## 631 632 #SeeAlso SkRRect() SkRect::MakeEmpty 633 634 #Method ## 635 636 # ------------------------------------------------------------------------------ 637 638 #Method static SkRRect MakeRect(const SkRect& r) 639 #In Constructors 640 #Line # copies bounds and zeroes corner radii ## 641 #Populate 642 643 #Example 644 #Height 70 645 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); 650 canvas->drawRRect(rrect, paint); 651 ## 652 653 #SeeAlso setRect MakeOval MakeRectXY 654 655 #Method ## 656 657 # ------------------------------------------------------------------------------ 658 659 #Method static SkRRect MakeOval(const SkRect& oval) 660 #In Constructors 661 #Line # creates Oval to fit bounds ## 662 #Populate 663 664 #Example 665 #Height 70 666 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); 672 canvas->drawRRect(rrect, paint); 673 ## 674 675 #SeeAlso setOval MakeRect MakeRectXY 676 677 #Method ## 678 679 # ------------------------------------------------------------------------------ 680 681 #Method static SkRRect MakeRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad) 682 #In Constructors 683 #Line # creates rounded rectangle ## 684 #Populate 685 686 #Example 687 #Height 70 688 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); 694 canvas->drawRRect(rrect, paint); 695 ## 696 697 #SeeAlso setRectXY 698 699 #Method ## 700 701 # ------------------------------------------------------------------------------ 702 703 #Method void setOval(const SkRect& oval) 704 #In Set 705 #Line # replaces with Oval to fit bounds ## 706 #Populate 707 708 #Example 709 #Height 70 710 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); 716 canvas->drawRRect(rrect, paint); 717 ## 718 719 #SeeAlso MakeOval 720 721 #Method ## 722 723 # ------------------------------------------------------------------------------ 724 725 #Method void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad) 726 #In Set 727 #Line # replaces with rounded rectangle ## 728 #Populate 729 730 #Example 731 #Height 70 732 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); 738 canvas->drawRRect(rrect, paint); 739 ## 740 741 #SeeAlso MakeRectXY SkPath::addRoundRect 742 743 #Method ## 744 745 # ------------------------------------------------------------------------------ 746 747 #Method void setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad, 748 SkScalar rightRad, SkScalar bottomRad) 749 #In Set 750 #Line # replaces with rounded rectangle ## 751 #Populate 752 753 #Example 754 #Height 70 755 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, 769 r.fRight - rrect.radii(SkRRect::kLowerRight_Corner).fX, r.fBottom, paint); 770 ## 771 772 #SeeAlso setRectRadii 773 774 #Method ## 775 776 # ------------------------------------------------------------------------------ 777 778 #Method void setRectRadii(const SkRect& rect, const SkVector radii[4]) 779 #In Set 780 #Line # replaces with rounded rectangle ## 781 #Populate 782 783 #Example 784 #Height 128 785 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); 801 canvas->drawPath(path, paint); 802 ## 803 804 #SeeAlso setNinePatch SkPath::addRoundRect 805 806 #Method ## 807 808 # ------------------------------------------------------------------------------ 809 810 #Enum Corner 811 #Line # corner radii order ## 812 813 #Code 814 enum Corner { 815 kUpperLeft_Corner, 816 kUpperRight_Corner, 817 kLowerRight_Corner, 818 kLowerLeft_Corner, 819 }; 820 ## 821 822 The radii are stored: top-left, top-right, bottom-right, bottom-left. 823 824 #Const kUpperLeft_Corner 0 825 #Line # index of top-left corner radii ## 826 ## 827 #Const kUpperRight_Corner 1 828 #Line # index of top-right corner radii ## 829 ## 830 #Const kLowerRight_Corner 2 831 #Line # index of bottom-right corner radii ## 832 ## 833 #Const kLowerLeft_Corner 3 834 #Line # index of bottom-left corner radii ## 835 ## 836 837 #Example 838 #Height 70 839 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, 854 r.fRight - rrect.radii(SkRRect::kLowerRight_Corner).fX, r.fBottom, paint); 855 ## 856 857 #SeeAlso radii 858 859 #Enum ## 860 861 # ------------------------------------------------------------------------------ 862 863 #Method const SkRect& rect() const 864 #In Property 865 #Line # returns bounds ## 866 #Populate 867 868 #Example 869 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); 872 } 873 #StdOut 874 left bounds: (nan) 0 875 left bounds: (inf) 0 876 left bounds: (100) 60 877 left bounds: (50) 50 878 left bounds: (25) 25 879 ## 880 ## 881 882 #SeeAlso getBounds 883 884 #Method ## 885 886 # ------------------------------------------------------------------------------ 887 888 #Method SkVector radii(Corner corner) const 889 #In Property 890 #Line # returns x-axis and y-axis radii for one corner ## 891 #Populate 892 893 #Example 894 #Description 895 Finite values are scaled proportionately to fit; other values are set to zero. 896 Scaled values cannot be larger than 25, half the bounding Round_Rect width. 897 Small scaled values are halved to scale in proportion to the y-axis corner 898 radius, which is twice the bounds height. 899 ## 900 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 } 904 #StdOut 905 left corner: (nan) 0 906 left corner: (inf) 0 907 left corner: (100) 25 908 left corner: (50) 25 909 left corner: (25) 12.5 910 ## 911 ## 912 913 #SeeAlso Corner 914 915 #Method ## 916 917 # ------------------------------------------------------------------------------ 918 919 #Method const SkRect& getBounds() const 920 #In Property 921 #Line # returns bounds ## 922 #Populate 923 924 #Example 925 #Height 120 926 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()); 931 canvas->drawRRect(rrect, paint); 932 ## 933 934 #SeeAlso rect 935 936 #Method ## 937 938 # ------------------------------------------------------------------------------ 939 940 #Method bool operator==(const SkRRect& a, const SkRRect& b) 941 #In Operators 942 #Line # returns true if members are equal ## 943 #Populate 944 945 #Example 946 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"; 957 canvas->drawString(str.c_str(), -20, 240, SkPaint()); 958 ## 959 960 #SeeAlso operator!=(const SkRRect& a, const SkRRect& b) 961 962 #Method ## 963 964 # ------------------------------------------------------------------------------ 965 966 #Method bool operator!=(const SkRRect& a, const SkRRect& b) 967 #In Operators 968 #Line # returns true if members are unequal ## 969 #Populate 970 971 #Example 972 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"; 983 canvas->drawString(str.c_str(), -20, 240, SkPaint()); 984 ## 985 986 #SeeAlso operator==(const SkRRect& a, const SkRRect& b) 987 988 #Method ## 989 990 # ------------------------------------------------------------------------------ 991 992 #Method void inset(SkScalar dx, SkScalar dy, SkRRect* dst) const 993 #In Inset_Outset_Offset 994 #Line # insets bounds and radii ## 995 #Populate 996 997 #Example 998 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 } 1006 ## 1007 1008 #SeeAlso outset offset makeOffset 1009 1010 #Method ## 1011 1012 # ------------------------------------------------------------------------------ 1013 1014 #Method void inset(SkScalar dx, SkScalar dy) 1015 #In Inset_Outset_Offset 1016 #Line # insets bounds and radii ## 1017 #Populate 1018 1019 #Example 1020 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); 1027 } 1028 ## 1029 1030 #SeeAlso outset offset makeOffset 1031 1032 1033 #Method ## 1034 1035 # ------------------------------------------------------------------------------ 1036 1037 #Method void outset(SkScalar dx, SkScalar dy, SkRRect* dst) const 1038 #In Inset_Outset_Offset 1039 #Line # outsets bounds and radii ## 1040 #Populate 1041 1042 #Example 1043 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 } 1051 ## 1052 1053 #SeeAlso inset offset makeOffset 1054 1055 1056 #Method ## 1057 1058 # ------------------------------------------------------------------------------ 1059 1060 #Method void outset(SkScalar dx, SkScalar dy) 1061 #In Inset_Outset_Offset 1062 #Line # outsets bounds and radii ## 1063 #Populate 1064 1065 #Example 1066 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 } 1074 ## 1075 1076 #SeeAlso inset offset makeOffset 1077 1078 #Method ## 1079 1080 # ------------------------------------------------------------------------------ 1081 1082 #Method void offset(SkScalar dx, SkScalar dy) 1083 #In Inset_Outset_Offset 1084 #Line # offsets bounds and radii ## 1085 #Populate 1086 1087 #Example 1088 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 } 1096 ## 1097 1098 #SeeAlso makeOffset inset outset 1099 1100 #Method ## 1101 1102 # ------------------------------------------------------------------------------ 1103 1104 #Method SkRRect makeOffset(SkScalar dx, SkScalar dy) const 1105 #In Inset_Outset_Offset 1106 #Line # offsets bounds and radii ## 1107 #Populate 1108 1109 #Example 1110 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); 1117 } 1118 ## 1119 1120 #SeeAlso offset inset outset 1121 1122 #Method ## 1123 1124 # ------------------------------------------------------------------------------ 1125 1126 #Method bool contains(const SkRect& rect) const 1127 #In Intersection 1128 #Line # returns true if Rect is inside ## 1129 #Populate 1130 1131 #Example 1132 #Height 110 1133 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); 1146 canvas->drawRect(test, paint); 1147 ## 1148 1149 #SeeAlso SkRect::contains 1150 1151 #Method ## 1152 1153 # ------------------------------------------------------------------------------ 1154 1155 #Method bool isValid() const 1156 #In Utility 1157 #Line # returns if type() matches bounds and radii ## 1158 #Populate 1159 1160 #Example 1161 #Height 110 1162 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); 1172 canvas->drawRRect(corrupt, paint); 1173 ## 1174 1175 #SeeAlso Type getType 1176 1177 #Method ## 1178 1179 # ------------------------------------------------------------------------------ 1180 1181 #Const kSizeInMemory 48 1182 #Line # storage space for Round_Rect ## 1183 1184 Space required to write the contents of SkRRect into a buffer; always a multiple of four. 1185 1186 #Const ## 1187 1188 # ------------------------------------------------------------------------------ 1189 1190 #Method size_t writeToMemory(void* buffer) const 1191 #In Utility 1192 #Line # writes Round_Rect to buffer ## 1193 #Populate 1194 1195 #Example 1196 #Height 110 1197 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); 1209 canvas->drawRRect(copy, paint); 1210 ## 1211 1212 #SeeAlso readFromMemory 1213 1214 #Method ## 1215 1216 # ------------------------------------------------------------------------------ 1217 1218 #Method size_t readFromMemory(const void* buffer, size_t length) 1219 #In Utility 1220 #Line # reads Round_Rect from buffer ## 1221 #Populate 1222 1223 #Example 1224 #Height 110 1225 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); 1239 canvas->drawRRect(copy, paint); 1240 ## 1241 1242 #SeeAlso writeToMemory 1243 1244 #Method ## 1245 1246 # ------------------------------------------------------------------------------ 1247 1248 #Method bool transform(const SkMatrix& matrix, SkRRect* dst) const 1249 #In Inset_Outset_Offset 1250 #Line # scales and offsets into copy ## 1251 #Populate 1252 1253 #Example 1254 #Height 110 1255 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); 1268 canvas->drawRRect(transformed, paint); 1269 ## 1270 1271 #SeeAlso SkPath::transform 1272 1273 #Method ## 1274 1275 # ------------------------------------------------------------------------------ 1276 1277 #Method void dump(bool asHex) const 1278 #In Utility 1279 #Line # sends text representation to standard output ## 1280 #Populate 1281 1282 #Example 1283 SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3}); 1284 for (bool dumpAsHex : { false, true } ) { 1285 rrect.dump(dumpAsHex); 1286 } 1287 #StdOut 1288 SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f); 1289 const SkPoint corners[] = { 1290 { 0, 0 }, 1291 { 0, 0 }, 1292 { 0, 0 }, 1293 { 0, 0 }, 1294 }; 1295 SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */ 1296 SkBits2Float(0x3f2aaaab), /* 0.666667 */ 1297 SkBits2Float(0x3f5b6db7), /* 0.857143 */ 1298 SkBits2Float(0x3f2aaaab) /* 0.666667 */); 1299 const 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 */ 1304 }; 1305 ## 1306 ## 1307 1308 #SeeAlso dumpHex SkRect::dump SkPath::dump SkPathMeasure::dump 1309 1310 #Method ## 1311 1312 # ------------------------------------------------------------------------------ 1313 1314 #Method void dump() const 1315 #In Utility 1316 #Line # sends text representation using floats to standard output ## 1317 #Populate 1318 1319 #Example 1320 SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3}); 1321 rrect.dump(); 1322 SkRect bounds = SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f); 1323 const SkPoint corners[] = { 1324 { 0, 0 }, 1325 { 0, 0 }, 1326 { 0, 0 }, 1327 { 0, 0 }, 1328 }; 1329 SkRRect copy; 1330 copy.setRectRadii(bounds, corners); 1331 SkDebugf("rrect is " "%s" "equal to copy\n", rrect == copy ? "" : "not "); 1332 #StdOut 1333 SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f); 1334 const SkPoint corners[] = { 1335 { 0, 0 }, 1336 { 0, 0 }, 1337 { 0, 0 }, 1338 { 0, 0 }, 1339 }; 1340 rrect is not equal to copy 1341 ## 1342 ## 1343 1344 #SeeAlso dumpHex SkRect::dump SkPath::dump SkPathMeasure::dump 1345 1346 #Method ## 1347 1348 # ------------------------------------------------------------------------------ 1349 1350 #Method void dumpHex() const 1351 #In Utility 1352 #Line # sends text representation using hexadecimal to standard output ## 1353 #Populate 1354 1355 #Example 1356 SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3}); 1357 rrect.dumpHex(); 1358 SkRect bounds = SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */ 1359 SkBits2Float(0x3f2aaaab), /* 0.666667 */ 1360 SkBits2Float(0x3f5b6db7), /* 0.857143 */ 1361 SkBits2Float(0x3f2aaaab) /* 0.666667 */); 1362 const 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 }; 1368 SkRRect copy; 1369 copy.setRectRadii(bounds, corners); 1370 SkDebugf("rrect is " "%s" "equal to copy\n", rrect == copy ? "" : "not "); 1371 #StdOut 1372 SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */ 1373 SkBits2Float(0x3f2aaaab), /* 0.666667 */ 1374 SkBits2Float(0x3f5b6db7), /* 0.857143 */ 1375 SkBits2Float(0x3f2aaaab) /* 0.666667 */); 1376 const 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 }; 1382 rrect is equal to copy 1383 ## 1384 ## 1385 1386 #SeeAlso dump SkRect::dumpHex SkPath::dumpHex 1387 1388 #Method ## 1389 1390 #Class SkRRect ## 1391 1392 #Topic RRect ## 1393