| 1 |
// 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" |
| 4 |
REG_FIDDLE(zero_off_dashing, 256, 256, false, 0) { |
| 5 |
static constexpr float kPi = 3.14159265358979323846f; |
| 6 |
void 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, 0.5)); |
| 17 |
|
| 18 |
SkPath path = SkPath::Circle(128, 128, 60); |
| 19 |
canvas->drawPath(path, p); |
| 20 |
|
| 21 |
p.setColor(0x8800FF00); |
| 22 |
SkScalar interv2[2] = {120 * kPi / 6 - 0.05f, 10000.0000f}; |
| 23 |
p.setPathEffect(SkDashPathEffect::Make(interv2, 0)); |
| 24 |
canvas->drawPath(path, p); |
| 25 |
|
| 26 |
SkPath path2 = skpathutils::FillPathWithPaint(path, p); |
| 27 |
p.setColor(0xFF000000); |
| 28 |
p.setStrokeWidth(0); |
| 29 |
p.setPathEffect(nullptr); |
| 30 |
canvas->drawPath(path2, p); |
| 31 |
} |
| 32 |
} // END FIDDLE |