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.
|
|
|
|
*/
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/effects/SkGradientShader.h"
|
|
|
|
#include "samplecode/Sample.h"
|
2011-07-08 20:12:55 +00:00
|
|
|
|
|
|
|
|
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:
|
2019-07-03 14:55:44 +00:00
|
|
|
virtual SkString name() { return SkString("2PtConical"); }
|
2011-07-08 20:12:55 +00:00
|
|
|
|
|
|
|
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,
|
2019-04-03 14:27:45 +00:00
|
|
|
SkTileMode::kClamp));
|
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(); )
|