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:
|
2020-07-21 21:03:56 +00:00
|
|
|
SkString name() override { return SkString("2PtConical"); }
|
2011-07-08 20:12:55 +00:00
|
|
|
|
2020-07-21 21:03:56 +00:00
|
|
|
void onDrawContent(SkCanvas* canvas) override {
|
2011-07-08 20:12:55 +00:00
|
|
|
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:
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = Sample;
|
2011-07-08 20:12:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-08-08 15:36:17 +00:00
|
|
|
DEF_SAMPLE( return new TwoPtConicalView(); )
|