Debian Codegraph @

docs/examples/Canvas_drawPath.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(Canvas_drawPath, 256, 256, false, 0) {
5 void draw(SkCanvas* canvas) {
6 SkPath path = SkPathBuilder()
7 .moveTo(20, 20)
8 .quadTo(60, 20, 60, 60)
9 .close()
10 .moveTo(60, 20)
11 .quadTo(60, 60, 20, 60)
12 .detach();
13 SkPaint paint;
14 paint.setStrokeWidth(10);
15 paint.setAntiAlias(true);
16 paint.setStyle(SkPaint::kStroke_Style);
17 for (auto join: { SkPaint::kBevel_Join, SkPaint::kRound_Join, SkPaint::kMiter_Join } ) {
18 paint.setStrokeJoin(join);
19 for (auto cap: { SkPaint::kButt_Cap, SkPaint::kSquare_Cap, SkPaint::kRound_Cap } ) {
20 paint.setStrokeCap(cap);
21 canvas->drawPath(path, paint);
22 canvas->translate(80, 0);
23 }
24 canvas->translate(-240, 60);
25 }
26 paint.setStyle(SkPaint::kFill_Style);
27 for (auto fill : { SkPathFillType::kWinding,
28 SkPathFillType::kEvenOdd,
29 SkPathFillType::kInverseWinding } ) {
30 path.setFillType(fill);
31 canvas->save();
32 canvas->clipRect({0, 10, 80, 70});
33 canvas->drawPath(path, paint);
34 canvas->restore();
35 canvas->translate(80, 0);
36 }
37 }
38 } // END FIDDLE