1*c8dee2aaSAndroid Build Coastguard Worker // Copyright 2019 Google LLC.
2*c8dee2aaSAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3*c8dee2aaSAndroid Build Coastguard Worker #include "tools/fiddle/examples.h"
4*c8dee2aaSAndroid Build Coastguard Worker REG_FIDDLE(Path_addRect_2, 256, 128, false, 0) {
draw(SkCanvas * canvas)5*c8dee2aaSAndroid Build Coastguard Worker void draw(SkCanvas* canvas) {
6*c8dee2aaSAndroid Build Coastguard Worker const SkPoint arrow[] = { {5, -5}, {15, -5}, {20, 0}, {15, 5}, {5, 5}, {10, 0} };
7*c8dee2aaSAndroid Build Coastguard Worker const SkRect rect = {10, 10, 54, 54};
8*c8dee2aaSAndroid Build Coastguard Worker SkPaint rectPaint;
9*c8dee2aaSAndroid Build Coastguard Worker rectPaint.setAntiAlias(true);
10*c8dee2aaSAndroid Build Coastguard Worker rectPaint.setStyle(SkPaint::kStroke_Style);
11*c8dee2aaSAndroid Build Coastguard Worker SkPaint arrowPaint(rectPaint);
12*c8dee2aaSAndroid Build Coastguard Worker SkPath arrowPath;
13*c8dee2aaSAndroid Build Coastguard Worker arrowPath.addPoly(arrow, std::size(arrow), true);
14*c8dee2aaSAndroid Build Coastguard Worker arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 176, 0,
15*c8dee2aaSAndroid Build Coastguard Worker SkPath1DPathEffect::kRotate_Style));
16*c8dee2aaSAndroid Build Coastguard Worker for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) {
17*c8dee2aaSAndroid Build Coastguard Worker for (unsigned start : { 0, 1, 2, 3 } ) {
18*c8dee2aaSAndroid Build Coastguard Worker SkPath path;
19*c8dee2aaSAndroid Build Coastguard Worker path.addRect(rect, direction, start);
20*c8dee2aaSAndroid Build Coastguard Worker canvas->drawPath(path, rectPaint);
21*c8dee2aaSAndroid Build Coastguard Worker canvas->drawPath(path, arrowPaint);
22*c8dee2aaSAndroid Build Coastguard Worker canvas->translate(64, 0);
23*c8dee2aaSAndroid Build Coastguard Worker }
24*c8dee2aaSAndroid Build Coastguard Worker canvas->translate(-256, 64);
25*c8dee2aaSAndroid Build Coastguard Worker }
26*c8dee2aaSAndroid Build Coastguard Worker }
27*c8dee2aaSAndroid Build Coastguard Worker } // END FIDDLE
28