skia2/docs/examples/bug5252.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

35 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(bug5252, 256, 256, false, 0) {
void draw(SkCanvas* canvas) {
canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
SkPath clip1;
clip1.addOval(SkRect::MakeWH(225, 200));
canvas->clipPath(clip1); // bug
SkPath clip2;
clip2.addRect(SkRect::MakeWH(220, 200));
// canvas->clipPath(clip2); // ok
SkPaint pa;
pa.setStyle(SkPaint::kStroke_Style);
pa.setAntiAlias(true);
pa.setStrokeWidth(1.0f);
for (int i = 0; i < 15; i++) {
for (int j = 0; j < 10; j++) {
SkAutoCanvasRestore acs(canvas, true);
canvas->translate(i * 15, j * 20);
canvas->drawRect(SkRect::MakeXYWH(5, 5, 10, 15), pa);
SkPath path;
path.moveTo(6, 6);
path.cubicTo(14, 10, 13, 12, 10, 12);
path.cubicTo(7, 15, 8, 17, 14, 18);
canvas->drawPath(path, pa);
}
}
}
} // END FIDDLE