2 * Copyright 2011 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #include "SampleCode.h"
11 #include "SkCornerPathEffect.h"
12 #include "SkGradientShader.h"
13 #include "SkGraphics.h"
14 #include "SkImageDecoder.h"
20 #include "SkColorPriv.h"
21 #include "SkColorFilter.h"
23 #include "SkTypeface.h"
24 #include "SkXfermode.h"
27 #include "SkXMLParser.h"
28 #include "SkColorPriv.h"
29 #include "SkImageDecoder.h"
31 class LinesView : public SampleView {
36 // overrides from SkEventSink
37 virtual bool onQuery(SkEvent* evt) {
38 if (SampleCode::TitleQ(*evt)) {
39 SampleCode::TitleR(evt, "Lines");
42 return this->INHERITED::onQuery(evt);
46 0x1F * x + 0x1F * (32 - x)
48 void drawRings(SkCanvas* canvas) {
49 canvas->scale(SkIntToScalar(1)/2, SkIntToScalar(1)/2);
52 SkScalar x = SkIntToScalar(10);
53 SkScalar y = SkIntToScalar(10);
54 r.set(x, y, x + SkIntToScalar(100), y + SkIntToScalar(100));
57 // paint.setAntiAlias(true);
58 paint.setStyle(SkPaint::kStroke_Style);
59 paint.setStrokeWidth(SkScalarHalf(SkIntToScalar(3)));
60 paint.setColor(0xFFFF8800);
61 // paint.setColor(0xFFFFFFFF);
62 canvas->drawRect(r, paint);
65 virtual void onDrawContent(SkCanvas* canvas) {
67 SkImageDecoder::DecodeFile("/kill.gif", &bm);
68 canvas->drawBitmap(bm, 0, 0, NULL);
70 this->drawRings(canvas);
76 paint.setColor(SK_ColorWHITE);
77 paint.setAlpha(fAlpha & 0xFF);
80 SkScalar x = SkIntToScalar(10);
81 SkScalar y = SkIntToScalar(10);
82 r.set(x, y, x + SkIntToScalar(100), y + SkIntToScalar(100));
83 canvas->drawRect(r, paint);
86 paint.setColor(0xffffff00); // yellow
87 paint.setStyle(SkPaint::kStroke_Style);
88 paint.setStrokeWidth(SkIntToScalar(2));
92 canvas->drawLine(x, y, x + SkIntToScalar(90), y + SkIntToScalar(90), paint);
94 paint.setAntiAlias(true); // with anti-aliasing
95 y += SkIntToScalar(10);
96 canvas->drawLine(x, y, x + SkIntToScalar(90), y + SkIntToScalar(90), paint);
99 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override {
100 fAlpha = SkScalarRoundToInt(y);
107 typedef SampleView INHERITED;
110 //////////////////////////////////////////////////////////////////////////////
112 static SkView* MyFactory() { return new LinesView; }
113 static SkViewRegister reg(MyFactory);