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 REG_FIDDLE(Path_addRect_2, 256, 128, false, 0) {
draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) {
6 const SkPoint arrow[] = { {5, -5}, {15, -5}, {20, 0}, {15, 5}, {5, 5}, {10, 0} };
7 const SkRect rect = {10, 10, 54, 54};
8 SkPaint rectPaint;
9 rectPaint.setAntiAlias(true);
10 rectPaint.setStyle(SkPaint::kStroke_Style);
11 SkPaint arrowPaint(rectPaint);
12 SkPath arrowPath;
13 arrowPath.addPoly(arrow, std::size(arrow), true);
14 arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 176, 0,
15 SkPath1DPathEffect::kRotate_Style));
16 for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) {
17 for (unsigned start : { 0, 1, 2, 3 } ) {
18 SkPath path;
19 path.addRect(rect, direction, start);
20 canvas->drawPath(path, rectPaint);
21 canvas->drawPath(path, arrowPaint);
22 canvas->translate(64, 0);
23 }
24 canvas->translate(-256, 64);
25 }
26 }
27 } // END FIDDLE
28