skia2/samplecode/SampleBox.cpp
rmistry@google.com bda03db289 Fixing source files that do not have newlines at the end.
Found using the new unsubmitted newline_checker slave script:
piraeus.cnc.corp.google.com:10125/builders/Skia_House_Keeping/builds/5/steps/shell_1/logs/stdio
Review URL: https://codereview.appspot.com/6443124

git-svn-id: http://skia.googlecode.com/svn/trunk@5097 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-08-14 20:27:54 +00:00

57 lines
1.4 KiB
C++

/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SampleCode.h"
#include "SkView.h"
#include "SkCanvas.h"
class SimpleView : public SampleView {
public:
SimpleView() {
this->setBGColor(0xFFDDDDDD);
}
protected:
// overrides from SkEventSink
virtual bool onQuery(SkEvent* evt) {
if (SampleCode::TitleQ(*evt)) {
SampleCode::TitleR(evt, "Box Gradient");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual void onDrawContent(SkCanvas* canvas) {
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(SkScalarHalf(SkIntToScalar(3)));
paint.setStyle(SkPaint::kFill_Style);
SkRect r;
SkScalar x,y;
x = 10;
y = 10;
r.set(x, y, x + SkIntToScalar(100), y + SkIntToScalar(100));
for (int i = 0; i < 256; ++i) {
canvas->translate(1, 1);
paint.setColor(0xFF000000 + i * 0x00010000);
canvas->drawRect(r, paint);
}
}
private:
typedef SampleView INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
static SkView* MyFactory() { return new SimpleView; }
static SkViewRegister reg(MyFactory);