Sample2PtRadial.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. class TwoPtConicalView : public Sample {
  11. public:
  12. TwoPtConicalView() {}
  13. protected:
  14. virtual SkString name() { return SkString("2PtConical"); }
  15. virtual void onDrawContent(SkCanvas* canvas) {
  16. canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
  17. SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
  18. SkPoint c0 = { 0, 0 };
  19. SkScalar r0 = 100;
  20. SkPoint c1 = { 100, 100 };
  21. SkScalar r1 = 100;
  22. SkPaint paint;
  23. paint.setShader(SkGradientShader::MakeTwoPointConical(c0, r0, c1, r1, colors,
  24. nullptr, 2,
  25. SkTileMode::kClamp));
  26. canvas->drawPaint(paint);
  27. }
  28. private:
  29. typedef Sample INHERITED;
  30. };
  31. //////////////////////////////////////////////////////////////////////////////
  32. DEF_SAMPLE( return new TwoPtConicalView(); )