blob: d445df7596ebc44ae3981afcc48b6cb5f1b09127 [file] [log] [blame]
yangsu@google.com4c295a32011-06-01 16:11:58 +00001#include "SampleCode.h"
2#include "SkView.h"
3#include "SkCanvas.h"
4
5class SimpleView : public SampleView {
6public:
7 SimpleView() {
8 this->setBGColor(0xFFDDDDDD);
9 }
10
11protected:
12 // overrides from SkEventSink
13 virtual bool onQuery(SkEvent* evt) {
14 if (SampleCode::TitleQ(*evt)) {
15 SampleCode::TitleR(evt, "Box Gradient");
16 return true;
17 }
18 return this->INHERITED::onQuery(evt);
19 }
20
21 virtual void onDrawContent(SkCanvas* canvas) {
22 SkPaint paint;
23 paint.setAntiAlias(true);
24 paint.setStyle(SkPaint::kStroke_Style);
25 paint.setStrokeWidth(SkScalarHalf(SkIntToScalar(3)));
26 paint.setStyle(SkPaint::kFill_Style);
27
28 SkRect r;
29 SkScalar x,y;
30 x = 10;
31 y = 10;
32
33 r.set(x, y, x + SkIntToScalar(100), y + SkIntToScalar(100));
34 for (int i = 0; i < 256; ++i) {
35 canvas->translate(1, 1);
36 paint.setColor(0xFF000000 + i * 0x00010000);
37 canvas->drawRect(r, paint);
38 }
39 }
40
41private:
42 typedef SampleView INHERITED;
43};
44
45//////////////////////////////////////////////////////////////////////////////
46
47static SkView* MyFactory() { return new SimpleView; }
48static SkViewRegister reg(MyFactory);