blob: 28c1a89d57b6f0c4f0940c5b7701b79e67908589 [file] [log] [blame]
Hal Canary6c8422c2020-01-10 15:22:09 -05001// Copyright 2020 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3#include "tools/fiddle/examples.h"
4REG_FIDDLE(radial_gradient_test, 256, 256, false, 0) {
5void draw(SkCanvas* canvas) {
6#define SIZE 121
7 SkScalar half = SIZE * 0.5f;
8 const SkColor preColor = 0xFFFF0000; // clamp color before start
9 const SkColor postColor = 0xFF0000FF; // clamp color after end
10 const SkColor color0 = 0xFF000000;
11 const SkColor color1 = 0xFF00FF00;
12
13 SkColor cs[] = {preColor, color0, color1, postColor};
14 SkScalar pos[] = {0, 0, 1, 1};
15
16 auto s = SkGradientShader::MakeRadial({half, half}, half - 10, cs, pos, 4,
17 SkTileMode::kClamp);
18
19 SkPaint p;
20 const SkRect rect = SkRect::MakeWH(SIZE, SIZE);
21 p.setShader(s);
22 canvas->drawRect(rect, p);
23}
24} // END FIDDLE