3 * Copyright 2011 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
8 #include "SampleCode.h"
9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h"
13 #include "SkGradientShader.h"
14 #include "SkGraphics.h"
15 #include "SkImageDecoder.h"
21 #include "SkXfermode.h"
22 #include "SkColorPriv.h"
23 #include "SkColorFilter.h"
25 #include "SkTypeface.h"
31 class TextAlphaView : public SampleView {
38 // overrides from SkEventSink
39 bool onQuery(SkEvent* evt) SK_OVERRIDE {
40 if (SampleCode::TitleQ(*evt)) {
41 SampleCode::TitleR(evt, "TextAlpha");
44 return this->INHERITED::onQuery(evt);
47 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE {
48 const char* str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
50 SkScalar x = SkIntToScalar(10);
51 SkScalar y = SkIntToScalar(20);
53 paint.setFlags(0x105);
55 paint.setARGB(fByte, 0xFF, 0xFF, 0xFF);
57 paint.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
58 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3))));
59 paint.getMaskFilter()->unref();
63 for (int ps = 6; ps <= 35; ps++) {
64 paint.setColor(rand.nextU() | (0xFF << 24));
65 paint.setTextSize(SkIntToScalar(ps));
66 paint.setTextSize(SkIntToScalar(24));
67 canvas->drawText(str, strlen(str), x, y, paint);
68 y += paint.getFontMetrics(NULL);
72 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) SK_OVERRIDE {
73 return new Click(this);
76 bool onClick(Click* click) SK_OVERRIDE {
77 int y = click->fICurr.fY;
91 typedef SampleView INHERITED;
94 //////////////////////////////////////////////////////////////////////////////
96 static SkView* MyFactory() { return new TextAlphaView; }
97 static SkViewRegister reg(MyFactory);