blob: 2a5460bcd16daa7cd765a4601774649fbfb6f9ec [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001// 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 Kleinc0bd9f92019-04-23 12:05:21 -05003#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04004// HASH=fe2294131f422b8d6752f6a880f98ad9
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(Canvas_drawPath, 256, 256, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04006void draw(SkCanvas* canvas) {
7 SkPath path;
8 path.moveTo(20, 20);
9 path.quadTo(60, 20, 60, 60);
10 path.close();
11 path.moveTo(60, 20);
12 path.quadTo(60, 60, 20, 60);
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);
Mike Reed7d34dc72019-11-26 12:17:17 -050027 for (auto fill : { SkPathFillType::kWinding,
28 SkPathFillType::kEvenOdd,
29 SkPathFillType::kInverseWinding } ) {
Hal Canary87515122019-03-15 14:22:51 -040030 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