2011-07-28 14:26:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2011-06-01 16:11:58 +00:00
|
|
|
#include "SampleCode.h"
|
|
|
|
#include "SkView.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
|
|
|
|
class SimpleView : public SampleView {
|
|
|
|
public:
|
2012-08-23 18:19:56 +00:00
|
|
|
SimpleView() {
|
2011-06-01 16:11:58 +00:00
|
|
|
this->setBGColor(0xFFDDDDDD);
|
2012-08-23 18:19:56 +00:00
|
|
|
}
|
|
|
|
|
2011-06-01 16:11:58 +00:00
|
|
|
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);
|
|
|
|
}
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2011-06-01 16:11:58 +00:00
|
|
|
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);
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2011-06-01 16:11:58 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2011-06-01 16:11:58 +00:00
|
|
|
private:
|
|
|
|
typedef SampleView INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static SkView* MyFactory() { return new SimpleView; }
|
2012-08-14 20:27:54 +00:00
|
|
|
static SkViewRegister reg(MyFactory);
|
|
|
|
|