diff options
author | reed <reed@google.com> | 2015-01-29 10:48:16 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-29 10:48:16 -0800 |
commit | 19d8f9f17373bcf7d352b77e72a6a46568ee8a8b (patch) | |
tree | b4deeff47a9af82a6877680f35eb3bf85c35a440 | |
parent | 416e39437971c66c38e0b244188378e344923d37 (diff) |
add new gm for SkPath::addArc()
BUG=skia:
TBR=
Review URL: https://codereview.chromium.org/888663002
-rw-r--r-- | gm/addarc.cpp | 48 | ||||
-rw-r--r-- | gyp/gmslides.gypi | 1 |
2 files changed, 49 insertions, 0 deletions
diff --git a/gm/addarc.cpp b/gm/addarc.cpp new file mode 100644 index 0000000000..209fb59aef --- /dev/null +++ b/gm/addarc.cpp @@ -0,0 +1,48 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "gm.h" +#include "SkCanvas.h" +#include "SkRandom.h" + +class AddArcGM : public skiagm::GM { +protected: + SkString onShortName() SK_OVERRIDE { return SkString("addarc"); } + + SkISize onISize() SK_OVERRIDE { return SkISize::Make(1040, 1040); } + + void onDraw(SkCanvas* canvas) SK_OVERRIDE { + canvas->translate(20, 20); + + SkRect r = SkRect::MakeWH(1000, 1000); + + SkPaint paint; + paint.setAntiAlias(true); + paint.setStyle(SkPaint::kStroke_Style); + paint.setStrokeWidth(15); + + const SkScalar inset = paint.getStrokeWidth() + 4; + const SkScalar sweepAngle = 345; + SkRandom rand; + + while (r.width() > paint.getStrokeWidth() * 3) { + paint.setColor(rand.nextU() | (0xFF << 24)); + SkScalar startAngle = rand.nextUScalar1() * 360; + + SkPath path; + path.addArc(r, startAngle, sweepAngle); + canvas->drawPath(path, paint); + + r.inset(inset, inset); + + } + } + +private: + typedef skiagm::GM INHERITED; +}; +DEF_GM( return new AddArcGM; ) diff --git a/gyp/gmslides.gypi b/gyp/gmslides.gypi index 9597ed680f..a285ee6aa3 100644 --- a/gyp/gmslides.gypi +++ b/gyp/gmslides.gypi @@ -15,6 +15,7 @@ 'sources': [ '../gm/aaclip.cpp', '../gm/aarectmodes.cpp', + '../gm/addarc.cpp', '../gm/alphagradients.cpp', '../gm/arcofzorro.cpp', '../gm/arithmode.cpp', |