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-07-08 20:12:55 +00:00
|
|
|
#include "SampleCode.h"
|
|
|
|
#include "SkView.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkGradientShader.h"
|
|
|
|
|
|
|
|
|
2015-05-04 15:32:51 +00:00
|
|
|
class TwoPtConicalView : public SampleView {
|
2011-07-08 20:12:55 +00:00
|
|
|
public:
|
2015-05-04 15:32:51 +00:00
|
|
|
TwoPtConicalView() {}
|
2011-07-08 20:12:55 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// overrides from SkEventSink
|
|
|
|
virtual bool onQuery(SkEvent* evt) {
|
|
|
|
if (SampleCode::TitleQ(*evt)) {
|
2015-05-04 15:32:51 +00:00
|
|
|
SampleCode::TitleR(evt, "2PtConical");
|
2011-07-08 20:12:55 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return this->INHERITED::onQuery(evt);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void onDrawContent(SkCanvas* canvas) {
|
|
|
|
canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
|
|
|
|
|
|
|
|
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
|
|
|
|
SkPoint c0 = { 0, 0 };
|
|
|
|
SkScalar r0 = 100;
|
|
|
|
SkPoint c1 = { 100, 100 };
|
|
|
|
SkScalar r1 = 100;
|
|
|
|
SkPaint paint;
|
2016-03-09 02:50:00 +00:00
|
|
|
paint.setShader(SkGradientShader::MakeTwoPointConical(c0, r0, c1, r1, colors,
|
|
|
|
nullptr, 2,
|
|
|
|
SkShader::kClamp_TileMode));
|
2011-07-08 20:12:55 +00:00
|
|
|
canvas->drawPaint(paint);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef SampleView INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-05-04 15:32:51 +00:00
|
|
|
static SkView* MyFactory() { return new TwoPtConicalView; }
|
2011-07-08 20:12:55 +00:00
|
|
|
static SkViewRegister reg(MyFactory);
|