2 * Copyright 2017 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
11 #include "SkGradientShader.h"
14 class TestGradientGM : public skiagm::GM {
19 SkString onShortName() override {
20 return SkString("testgradient");
23 SkISize onISize() override {
24 return SkISize::Make(800, 800);
27 void onDraw(SkCanvas* canvas) override {
28 // Set up a gradient paint for a rect.
29 // And non-gradient paint for other objects.
30 canvas->drawColor(SK_ColorWHITE);
33 paint.setStyle(SkPaint::kFill_Style);
34 paint.setAntiAlias(true);
35 paint.setStrokeWidth(4);
36 paint.setColor(0xFFFE938C);
38 SkRect rect = SkRect::MakeXYWH(10, 10, 100, 160);
41 SkPoint::Make(0.0f, 0.0f),
42 SkPoint::Make(256.0f, 256.0f)
44 SkColor colors[2] = {SK_ColorBLUE, SK_ColorYELLOW};
45 SkPaint newPaint(paint);
46 newPaint.setShader(SkGradientShader::MakeLinear(
47 points, colors, nullptr, 2,
48 SkShader::kClamp_TileMode, 0, nullptr));
49 canvas->drawRect(rect, newPaint);
54 paint.setColor(0xFFE6B89C);
55 canvas->drawRRect(oval, paint);
57 paint.setColor(0xFF9CAFB7);
58 canvas->drawCircle(180, 50, 25, paint);
61 paint.setColor(0xFF4281A4);
62 paint.setStyle(SkPaint::kStroke_Style);
63 canvas->drawRoundRect(rect, 10, 10, paint);
67 typedef skiagm::GM INHERITED;
71 DEF_GM( return new TestGradientGM; )