1 /* 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 */ 7 #include "include/core/SkCanvas.h" 8 #include "include/effects/SkGradientShader.h" 9 #include "samplecode/Sample.h" 10 11 12 class TwoPtConicalView : public Sample { 13 public: TwoPtConicalView()14 TwoPtConicalView() {} 15 16 protected: name()17 SkString name() override { return SkString("2PtConical"); } 18 onDrawContent(SkCanvas * canvas)19 void onDrawContent(SkCanvas* canvas) override { 20 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; 27 SkPaint paint; 28 paint.setShader(SkGradientShader::MakeTwoPointConical(c0, r0, c1, r1, colors, 29 nullptr, 2, 30 SkTileMode::kClamp)); 31 canvas->drawPaint(paint); 32 } 33 34 private: 35 using INHERITED = Sample; 36 }; 37 38 ////////////////////////////////////////////////////////////////////////////// 39 40 DEF_SAMPLE( return new TwoPtConicalView(); ) 41