Debian Codegraph @

docs/examples/radial_gradient_test.cpp

raw
1 // 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"
4 REG_FIDDLE(radial_gradient_test, 256, 256, false, 0) {
5 void draw(SkCanvas* canvas) {
6 #define SIZE 121
7 SkScalar half = SIZE * 0.5f;
8 const SkColor4f preColor = {1,0,0,1}; // clamp color before start
9 const SkColor4f postColor = {0,0,1,1}; // clamp color after end
10 const SkColor4f color0 = {0,0,0,1};
11 const SkColor4f color1 = {0,1,0,1};
12
13 SkColor4f cs[] = {preColor, color0, color1, postColor};
14 SkScalar pos[] = {0, 0, 1, 1};
15
16 auto s = SkShaders::RadialGradient({half, half}, half - 10,
17 {{cs, pos, 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