Index: trunk/gm/cubicpaths.cpp |
=================================================================== |
--- trunk/gm/cubicpaths.cpp (revision 8048) |
+++ trunk/gm/cubicpaths.cpp (working copy) |
@@ -296,8 +296,60 @@ |
typedef skiagm::GM INHERITED; |
}; |
+#include "SkGeometry.h" |
+ |
+class TrickyStrokeCubicGM : public skiagm::GM { |
+public: |
+ TrickyStrokeCubicGM() {} |
+ |
+protected: |
+ SkString onShortName() { |
+ return SkString("strokecubic"); |
+ } |
+ |
+ SkISize onISize() { return SkISize::Make(640, 480); } |
+ |
+ virtual void onDraw(SkCanvas* canvas) { |
+ const SkPoint pts[] = {{10,20}, {0,40}, {10,0}, {50,10}}; |
+ SkPath path; |
+ |
+ path.moveTo(pts[0]); |
+ path.cubicTo(pts[1], pts[2], pts[3]); |
+ |
+ SkRect srcR; |
+ // hone in on the interesting part of the cubic |
+ srcR.set(6, 23, 9, 27); |
+ |
+ SkMatrix matrix; |
+ matrix.setRectToRect(srcR, SkRect::MakeLTRB(10, 10, 630, 470), |
+ SkMatrix::kCenter_ScaleToFit); |
+ canvas->concat(matrix); |
+ |
+ SkPaint paint; |
+ paint.setStyle(SkPaint::kStroke_Style); |
+ paint.setStrokeWidth(0.15f); |
+ SkPath stroke; |
+ paint.getFillPath(path, &stroke); |
+ |
+ paint.setAntiAlias(true); |
+ paint.setColor(SK_ColorLTGRAY); |
+ canvas->drawPath(path, paint); |
+ |
+ paint.setStrokeWidth(0); |
+ paint.setColor(SK_ColorBLUE); |
+ canvas->drawPath(path, paint); |
+ |
+ paint.setColor(SK_ColorRED); |
+ canvas->drawPath(stroke, paint); |
+ } |
+ |
+private: |
+ typedef skiagm::GM INHERITED; |
+}; |
+ |
////////////////////////////////////////////////////////////////////////////// |
DEF_GM( return new CubicPathGM; ) |
DEF_GM( return new CubicClosePathGM; ) |
+DEF_GM( return new TrickyStrokeCubicGM; ) |