Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 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. |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 3 | #include "tools/fiddle/examples.h" |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 4 | // HASH=199fe818c09026c114e165bff166a39f |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 5 | REG_FIDDLE(Canvas_drawRoundRect, 256, 256, false, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 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 < SK_ARRAY_COUNT(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 |