• 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=199fe818c09026c114e165bff166a39f
5 REG_FIDDLE(Canvas_drawRoundRect, 256, 256, false, 0) {
draw(SkCanvas * canvas)6 void draw(SkCanvas* canvas) {
7     SkVector radii[] = { {0, 20}, {10, 10}, {10, 20}, {10, 40} };
8     SkPaint paint;
9     paint.setStrokeWidth(15);
10     paint.setStrokeJoin(SkPaint::kRound_Join);
11     paint.setAntiAlias(true);
12     for (auto style : { SkPaint::kStroke_Style, SkPaint::kFill_Style  } ) {
13         paint.setStyle(style );
14         for (size_t i = 0; i < std::size(radii); ++i) {
15            canvas->drawRoundRect({10, 10, 60, 40}, radii[i].fX, radii[i].fY, paint);
16            canvas->translate(0, 60);
17         }
18         canvas->translate(80, -240);
19     }
20 }
21 }  // END FIDDLE
22