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=9202430b3f4f5275af8eec5cc9d7baa8 |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 5 | REG_FIDDLE(Path_addRect_2, 256, 128, false, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 6 | void draw(SkCanvas* canvas) { |
| 7 | const SkPoint arrow[] = { {5, -5}, {15, -5}, {20, 0}, {15, 5}, {5, 5}, {10, 0} }; |
| 8 | const SkRect rect = {10, 10, 54, 54}; |
| 9 | SkPaint rectPaint; |
| 10 | rectPaint.setAntiAlias(true); |
| 11 | rectPaint.setStyle(SkPaint::kStroke_Style); |
| 12 | SkPaint arrowPaint(rectPaint); |
| 13 | SkPath arrowPath; |
| 14 | arrowPath.addPoly(arrow, SK_ARRAY_COUNT(arrow), true); |
| 15 | arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 176, 0, |
| 16 | SkPath1DPathEffect::kRotate_Style)); |
Mike Reed | 30bc527 | 2019-11-22 18:34:02 +0000 | [diff] [blame] | 17 | for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 18 | for (unsigned start : { 0, 1, 2, 3 } ) { |
| 19 | SkPath path; |
| 20 | path.addRect(rect, direction, start); |
| 21 | canvas->drawPath(path, rectPaint); |
| 22 | canvas->drawPath(path, arrowPaint); |
| 23 | canvas->translate(64, 0); |
| 24 | } |
| 25 | canvas->translate(-256, 64); |
| 26 | } |
| 27 | } |
| 28 | } // END FIDDLE |