• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 Google LLC.
2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3 #include "tools/fiddle/examples.h"
4 // HASH=9205393f30b156e1507e88aa27f1dd91
5 REG_FIDDLE(RRect_Corner, 256, 70, false, 0) {
draw(SkCanvas * canvas)6 void draw(SkCanvas* canvas) {
7     SkPaint paint;
8     paint.setAntiAlias(true);
9     SkRRect rrect;
10     SkVector corners[] = {{25, 17}, {17, 19}, {19, 15}, {15, 15}};
11     rrect.setRectRadii({30, 10, 100, 60}, corners);
12     canvas->drawRRect(rrect, paint);
13     paint.setColor(SK_ColorWHITE);
14     const SkRect r = rrect.getBounds();
15     canvas->drawLine(r.fLeft, r.fTop + rrect.radii(SkRRect::kUpperLeft_Corner).fY,
16                      r.fRight, r.fTop + rrect.radii(SkRRect::kUpperRight_Corner).fY, paint);
17     canvas->drawLine(r.fLeft, r.fBottom - rrect.radii(SkRRect::kLowerLeft_Corner).fY,
18                      r.fRight, r.fBottom - rrect.radii(SkRRect::kLowerRight_Corner).fY, paint);
19     canvas->drawLine(r.fLeft + rrect.radii(SkRRect::kUpperLeft_Corner).fX, r.fTop,
20                      r.fLeft + rrect.radii(SkRRect::kLowerLeft_Corner).fX, r.fBottom, paint);
21     canvas->drawLine(r.fRight - rrect.radii(SkRRect::kUpperRight_Corner).fX, r.fTop,
22                      r.fRight - rrect.radii(SkRRect::kLowerRight_Corner).fX, r.fBottom, paint);
23 }
24 }  // END FIDDLE
25