diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-18 17:39:44 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-18 17:39:44 -0700 |
commit | af527e02dce280c269d751322e9f60aac8cb97da (patch) | |
tree | 19faf6d47cdd3d589a6dfcff0f8f75fcbb03aa20 /samplecode/SamplePath.cpp | |
parent | 5956d1c224aadf1d2712b46b32d3fc69a19915bd (diff) | |
download | external_skia-af527e02dce280c269d751322e9f60aac8cb97da.zip external_skia-af527e02dce280c269d751322e9f60aac8cb97da.tar.gz external_skia-af527e02dce280c269d751322e9f60aac8cb97da.tar.bz2 |
auto import from //branches/cupcake_rel/...@140373
Diffstat (limited to 'samplecode/SamplePath.cpp')
-rw-r--r-- | samplecode/SamplePath.cpp | 163 |
1 files changed, 0 insertions, 163 deletions
diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp deleted file mode 100644 index 98f1a5b..0000000 --- a/samplecode/SamplePath.cpp +++ /dev/null @@ -1,163 +0,0 @@ -#include "SampleCode.h" -#include "SkView.h" -#include "SkCanvas.h" -#include "SkGradientShader.h" -#include "SkGraphics.h" -#include "SkImageDecoder.h" -#include "SkPath.h" -#include "SkPorterDuff.h" -#include "SkRegion.h" -#include "SkShader.h" -#include "SkUtils.h" -#include "SkXfermode.h" -#include "SkColorPriv.h" -#include "SkColorFilter.h" -#include "SkTime.h" -#include "SkTypeface.h" - -class PathView : public SkView { -public: - int fDStroke, fStroke, fMinStroke, fMaxStroke; - SkPath fPath[6]; - bool fShowHairline; - - PathView() - { - fShowHairline = false; - - fDStroke = 1; - fStroke = 10; - fMinStroke = 10; - fMaxStroke = 180; - - const int V = 85; - - fPath[0].moveTo(SkIntToScalar(40), SkIntToScalar(70)); - fPath[0].lineTo(SkIntToScalar(70), SkIntToScalar(70) + SK_Scalar1/1); - fPath[0].lineTo(SkIntToScalar(110), SkIntToScalar(70)); - - fPath[1].moveTo(SkIntToScalar(40), SkIntToScalar(70)); - fPath[1].lineTo(SkIntToScalar(70), SkIntToScalar(70) - SK_Scalar1/1); - fPath[1].lineTo(SkIntToScalar(110), SkIntToScalar(70)); - - fPath[2].moveTo(SkIntToScalar(V), SkIntToScalar(V)); - fPath[2].lineTo(SkIntToScalar(50), SkIntToScalar(V)); - fPath[2].lineTo(SkIntToScalar(50), SkIntToScalar(50)); - - fPath[3].moveTo(SkIntToScalar(50), SkIntToScalar(50)); - fPath[3].lineTo(SkIntToScalar(50), SkIntToScalar(V)); - fPath[3].lineTo(SkIntToScalar(V), SkIntToScalar(V)); - - fPath[4].moveTo(SkIntToScalar(50), SkIntToScalar(50)); - fPath[4].lineTo(SkIntToScalar(50), SkIntToScalar(V)); - fPath[4].lineTo(SkIntToScalar(52), SkIntToScalar(50)); - - fPath[5].moveTo(SkIntToScalar(52), SkIntToScalar(50)); - fPath[5].lineTo(SkIntToScalar(50), SkIntToScalar(V)); - fPath[5].lineTo(SkIntToScalar(50), SkIntToScalar(50)); - } - - virtual ~PathView() - { - } - - void nextStroke() - { - fStroke += fDStroke; - if (fStroke > fMaxStroke || fStroke < fMinStroke) - fDStroke = -fDStroke; - } - -protected: - // overrides from SkEventSink - virtual bool onQuery(SkEvent* evt) - { - if (SampleCode::TitleQ(*evt)) - { - SampleCode::TitleR(evt, "Paths"); - return true; - } - return this->INHERITED::onQuery(evt); - } - - void drawBG(SkCanvas* canvas) - { - canvas->drawColor(0xFFDDDDDD); -// canvas->drawColor(SK_ColorWHITE); - } - - void drawPath(SkCanvas* canvas, const SkPath& path, SkPaint::Join j) - { - SkPaint paint; - - paint.setAntiAlias(true); - paint.setStyle(SkPaint::kStroke_Style); - paint.setStrokeJoin(j); - paint.setStrokeWidth(SkIntToScalar(fStroke)); - - if (fShowHairline) - { - SkPath fill; - - paint.getFillPath(path, &fill); - paint.setStrokeWidth(0); - canvas->drawPath(fill, paint); - } - else - canvas->drawPath(path, paint); - - paint.setColor(SK_ColorRED); - paint.setStrokeWidth(0); - canvas->drawPath(path, paint); - } - - virtual void onDraw(SkCanvas* canvas) - { - this->drawBG(canvas); - - canvas->translate(SkIntToScalar(50), SkIntToScalar(50)); - - static const SkPaint::Join gJoins[] = { - SkPaint::kBevel_Join, - SkPaint::kMiter_Join, - SkPaint::kRound_Join - }; - - for (int i = 0; i < SK_ARRAY_COUNT(gJoins); i++) - { - canvas->save(); - for (int j = 0; j < SK_ARRAY_COUNT(fPath); j++) - { - this->drawPath(canvas, fPath[j], gJoins[i]); - canvas->translate(SkIntToScalar(200), 0); - } - canvas->restore(); - - canvas->translate(0, SkIntToScalar(200)); - } - - this->nextStroke(); - this->inval(NULL); - } - - virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) - { - fShowHairline = !fShowHairline; - this->inval(NULL); - return this->INHERITED::onFindClickHandler(x, y); - } - - virtual bool onClick(Click* click) - { - return this->INHERITED::onClick(click); - } - -private: - typedef SkView INHERITED; -}; - -////////////////////////////////////////////////////////////////////////////// - -static SkView* MyFactory() { return new PathView; } -static SkViewRegister reg(MyFactory); - |