Debian Codegraph @

docs/examples/Path_addRect_2.cpp

raw
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) {
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 = SkPath::Polygon(arrow, true);
13 arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 176, 0,
14 SkPath1DPathEffect::kRotate_Style));
15 for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) {
16 for (unsigned start : { 0, 1, 2, 3 } ) {
17 SkPath path = SkPath::Rect(rect, direction, start);
18 canvas->drawPath(path, rectPaint);
19 canvas->drawPath(path, arrowPaint);
20 canvas->translate(64, 0);
21 }
22 canvas->translate(-256, 64);
23 }
24 }
25 } // END FIDDLE