aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/dashcubics.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-13 15:55:15 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-13 15:55:15 +0000
commit8d850be3aa5164879cdaee5e98caaa507eb3d117 (patch)
tree84017bb590ef662c74f5caf49864bcf0f81e4dac /gm/dashcubics.cpp
parentc4fc0e60e7a03fcc93a4f06cf3e2be1ca58df63e (diff)
don't add circles on chopped cubics
git-svn-id: http://skia.googlecode.com/svn/trunk@4600 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/dashcubics.cpp')
-rw-r--r--gm/dashcubics.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/gm/dashcubics.cpp b/gm/dashcubics.cpp
new file mode 100644
index 0000000000..d245070007
--- /dev/null
+++ b/gm/dashcubics.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2012 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 "SkPath.h"
+#include "SkParsePath.h"
+#include "SkDashPathEffect.h"
+
+/*
+ * Inspired by http://code.google.com/p/chromium/issues/detail?id=112145
+ */
+
+class DashCubicsGM : public skiagm::GM {
+public:
+ DashCubicsGM() {}
+
+protected:
+ virtual SkString onShortName() {
+ return SkString("dashcubics");
+ }
+
+ virtual SkISize onISize() {
+ return SkISize::Make(640, 480);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) {
+ SkPath path;
+ const char* d = "M 337,98 C 250,141 250,212 250,212 C 250,212 250,212 250,212"
+ "C 250,212 250,212 250,212 C 250,212 250,141 163,98 C 156,195 217,231 217,231"
+ "C 217,231 217,231 217,231 C 217,231 217,231 217,231 C 217,231 156,195 75,250"
+ "C 156,305 217,269 217,269 C 217,269 217,269 217,269 C 217,269 217,269 217,269"
+ "C 217,269 156,305 163,402 C 250,359 250,288 250,288 C 250,288 250,288 250,288"
+ "C 250,288 250,288 250,288 C 250,288 250,359 338,402 C 345,305 283,269 283,269"
+ "C 283,269 283,269 283,269 C 283,269 283,269 283,269 C 283,269 345,305 425,250"
+ "C 344,195 283,231 283,231 C 283,231 283,231 283,231 C 283,231 283,231 283,231"
+ "C 283,231 344,195 338,98";
+
+ SkParsePath::FromSVGString(d, &path);
+
+ SkScalar intervals[] = { 5, 10 };
+ SkPathEffect* pe = new SkDashPathEffect(intervals, 2, 0);
+
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kStroke_Style);
+
+ paint.setStrokeWidth(42);
+ canvas->drawPath(path, paint);
+
+ paint.setColor(SK_ColorRED);
+ paint.setStrokeWidth(21);
+ paint.setPathEffect(pe)->unref();
+ canvas->drawPath(path, paint);
+
+ paint.setColor(SK_ColorGREEN);
+ paint.setPathEffect(NULL);
+ paint.setStrokeWidth(0);
+ canvas->drawPath(path, paint);
+ }
+
+private:
+ typedef GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+static skiagm::GM* MyFactory(void*) { return new DashCubicsGM; }
+static skiagm::GMRegistry reg(MyFactory);
+