diff options
author | Mike Reed <reed@google.com> | 2018-03-07 17:02:47 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-07 22:32:20 +0000 |
commit | 4123223ccc85e4f712495403dd1a2869110fd8c4 (patch) | |
tree | ccb587567bd48f2a1b77885e92f8a0c44649fff2 /gm/dashcubics.cpp | |
parent | 23d23892cad305117fb8e46bcf8e15c3174c47f4 (diff) |
add TrimPathEffect
Bug: skia:
Change-Id: I453fb81ded4435b33567e9c8a6f3abe9535d687f
Reviewed-on: https://skia-review.googlesource.com/112820
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'gm/dashcubics.cpp')
-rw-r--r-- | gm/dashcubics.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/gm/dashcubics.cpp b/gm/dashcubics.cpp index e8d7f5bc8e..1d80d75b4a 100644 --- a/gm/dashcubics.cpp +++ b/gm/dashcubics.cpp @@ -58,3 +58,43 @@ DEF_SIMPLE_GM(dashcubics, canvas, 865, 750) { } } } + +#include "SkTrimPathEffect.h" +class TrimGM : public skiagm::GM { +public: + TrimGM() {} + +protected: + SkString onShortName() override { return SkString("trimpatheffect"); } + + SkISize onISize() override { return SkISize::Make(1240, 390); } + + void onDraw(SkCanvas* canvas) override { + SkPaint paint; + paint.setPathEffect(SkTrimPathEffect::Make(0.25 + fOffset, 0.75)); + paint.setStyle(SkPaint::kStroke_Style); + paint.setAntiAlias(true); + paint.setStrokeWidth(10); + + SkPath path; + path.moveTo(50, 300); + path.cubicTo(100, 50, 150, 550, 200, 300); + + paint.setColor(0xFF888888); + canvas->drawPath(path, paint); + paint.setPathEffect(nullptr); + paint.setStrokeWidth(0); + paint.setColor(0xFF000000); + canvas->drawPath(path, paint); + } + + bool onAnimate(const SkAnimTimer&) override { + // fOffset += 1; + return true; + } +private: + SkScalar fOffset = 0; + typedef skiagm::GM INHERITED; +}; +DEF_GM(return new TrimGM;) + |