skia2/docs/examples/zero_off_dashing.cpp
Hal Canary 6c8422c671 add more docs/examples from named fiddles.
ignore offscreen, srgb, and animated fiddles for now.

Change-Id: I923131b684865698e6cda138b004930e11f504d5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263713
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2020-01-14 19:22:26 +00:00

34 lines
1.1 KiB
C++

// Copyright 2020 Google LLC.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include "tools/fiddle/examples.h"
REG_FIDDLE(zero_off_dashing, 256, 256, false, 0) {
static constexpr float kPi = 3.14159265358979323846f;
void draw(SkCanvas* canvas) {
SkPaint p;
canvas->drawCircle(128, 128, 60, p);
p.setColor(0x88FF0000);
p.setAntiAlias(true);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeCap(SkPaint::kSquare_Cap);
p.setStrokeWidth(80);
SkScalar interv[2] = {120 * kPi / 6 - 0.05f, 0.0000f};
p.setPathEffect(SkDashPathEffect::Make(interv, 2, 0.5));
SkPath path, path2;
path.addCircle(128, 128, 60);
canvas->drawPath(path, p);
p.setColor(0x8800FF00);
SkScalar interv2[2] = {120 * kPi / 6 - 0.05f, 10000.0000f};
p.setPathEffect(SkDashPathEffect::Make(interv2, 2, 0));
canvas->drawPath(path, p);
p.getFillPath(path, &path2);
p.setColor(0xFF000000);
p.setStrokeWidth(0);
p.setPathEffect(nullptr);
canvas->drawPath(path2, p);
}
} // END FIDDLE