blob: f404d149a7c73ebe24e8e69e888cb2c4c4768579 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
Mike Kleinc0bd9f92019-04-23 12:05:21 -05007#include "include/core/SkCanvas.h"
8#include "include/effects/SkGradientShader.h"
9#include "samplecode/Sample.h"
reed@google.com4de4d602011-07-08 20:12:55 +000010
11
Ben Wagnerb2c4ea62018-08-08 11:36:17 -040012class TwoPtConicalView : public Sample {
reed@google.com4de4d602011-07-08 20:12:55 +000013public:
reed71a6cbf2015-05-04 08:32:51 -070014 TwoPtConicalView() {}
reed@google.com4de4d602011-07-08 20:12:55 +000015
16protected:
Brian Salomond0072812020-07-21 17:03:56 -040017 SkString name() override { return SkString("2PtConical"); }
reed@google.com4de4d602011-07-08 20:12:55 +000018
Brian Salomond0072812020-07-21 17:03:56 -040019 void onDrawContent(SkCanvas* canvas) override {
reed@google.com4de4d602011-07-08 20:12:55 +000020 canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
21
22 SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
23 SkPoint c0 = { 0, 0 };
24 SkScalar r0 = 100;
25 SkPoint c1 = { 100, 100 };
26 SkScalar r1 = 100;
reed@google.com4de4d602011-07-08 20:12:55 +000027 SkPaint paint;
reed8a21c9f2016-03-08 18:50:00 -080028 paint.setShader(SkGradientShader::MakeTwoPointConical(c0, r0, c1, r1, colors,
29 nullptr, 2,
Mike Reedfae8fce2019-04-03 10:27:45 -040030 SkTileMode::kClamp));
reed@google.com4de4d602011-07-08 20:12:55 +000031 canvas->drawPaint(paint);
32 }
33
34private:
John Stiles7571f9e2020-09-02 22:42:33 -040035 using INHERITED = Sample;
reed@google.com4de4d602011-07-08 20:12:55 +000036};
37
38//////////////////////////////////////////////////////////////////////////////
39
Ben Wagnerb2c4ea62018-08-08 11:36:17 -040040DEF_SAMPLE( return new TwoPtConicalView(); )