blob: c0856b88f300e1e887f862fc712360a8a66b8ade [file] [log] [blame]
Hal Canary6c8422c2020-01-10 15:22:09 -05001// Copyright 2020 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"
4REG_FIDDLE(zero_off_dashing, 256, 256, false, 0) {
5static constexpr float kPi = 3.14159265358979323846f;
6void draw(SkCanvas* canvas) {
7 SkPaint p;
8 canvas->drawCircle(128, 128, 60, p);
9
10 p.setColor(0x88FF0000);
11 p.setAntiAlias(true);
12 p.setStyle(SkPaint::kStroke_Style);
13 p.setStrokeCap(SkPaint::kSquare_Cap);
14 p.setStrokeWidth(80);
15 SkScalar interv[2] = {120 * kPi / 6 - 0.05f, 0.0000f};
16 p.setPathEffect(SkDashPathEffect::Make(interv, 2, 0.5));
17
18 SkPath path, path2;
19 path.addCircle(128, 128, 60);
20 canvas->drawPath(path, p);
21
22 p.setColor(0x8800FF00);
23 SkScalar interv2[2] = {120 * kPi / 6 - 0.05f, 10000.0000f};
24 p.setPathEffect(SkDashPathEffect::Make(interv2, 2, 0));
25 canvas->drawPath(path, p);
26
27 p.getFillPath(path, &path2);
28 p.setColor(0xFF000000);
29 p.setStrokeWidth(0);
30 p.setPathEffect(nullptr);
31 canvas->drawPath(path2, p);
32}
33} // END FIDDLE