Mike Klein | fd35c74 | 2017-05-15 15:55:54 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "gm/gm.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 9 | #include "include/core/SkCanvas.h" |
| 10 | #include "include/core/SkColor.h" |
| 11 | #include "include/core/SkPaint.h" |
| 12 | #include "include/core/SkPoint.h" |
| 13 | #include "include/core/SkScalar.h" |
| 14 | #include "include/core/SkShader.h" |
| 15 | #include "include/core/SkTileMode.h" |
| 16 | #include "include/core/SkTypes.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 17 | #include "include/effects/SkGradientShader.h" |
Mike Klein | fd35c74 | 2017-05-15 15:55:54 -0400 | [diff] [blame] | 18 | |
| 19 | // All we're looking for here is that we see a smooth gradient. |
| 20 | DEF_SIMPLE_GM(radial_gradient_precision, canvas, 200, 200) { |
Mike Klein | 1b25818 | 2019-03-13 15:49:23 -0500 | [diff] [blame] | 21 | SkPoint center = {1000, 1000}; |
Mike Klein | fd35c74 | 2017-05-15 15:55:54 -0400 | [diff] [blame] | 22 | SkScalar radius = 40; |
Mike Klein | 1b25818 | 2019-03-13 15:49:23 -0500 | [diff] [blame] | 23 | SkColor colors[] = {SK_ColorBLACK, SK_ColorGREEN}; |
Mike Klein | fd35c74 | 2017-05-15 15:55:54 -0400 | [diff] [blame] | 24 | |
| 25 | SkPaint p; |
| 26 | p.setShader(SkGradientShader::MakeRadial(center, radius, |
| 27 | colors, nullptr, SK_ARRAY_COUNT(colors), |
Mike Reed | fae8fce | 2019-04-03 10:27:45 -0400 | [diff] [blame] | 28 | SkTileMode::kRepeat)); |
Mike Klein | fd35c74 | 2017-05-15 15:55:54 -0400 | [diff] [blame] | 29 | canvas->drawPaint(p); |
| 30 | } |