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.
|
|
|
|
*/
|
2018-08-08 15:36:17 +00:00
|
|
|
#include "Sample.h"
|
2011-07-08 20:12:55 +00:00
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkGradientShader.h"
|
|
|
|
|
|
|
|
|
2018-08-08 15:36:17 +00:00
|
|
|
class TwoPtConicalView : public Sample {
|
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:
|
2018-08-08 15:36:17 +00:00
|
|
|
virtual bool onQuery(Sample::Event* evt) {
|
|
|
|
if (Sample::TitleQ(*evt)) {
|
|
|
|
Sample::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:
|
2018-08-08 15:36:17 +00:00
|
|
|
typedef Sample INHERITED;
|
2011-07-08 20:12:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-08-08 15:36:17 +00:00
|
|
|
DEF_SAMPLE( return new TwoPtConicalView(); )
|