Flutter Engine
The Flutter Engine
radial_gradient_test.cpp
Go to the documentation of this file.
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.
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,
18
19 SkPaint p;
21 p.setShader(s);
22 canvas->drawRect(rect, p);
23}
24} // END FIDDLE
SkPoint pos
uint32_t SkColor
Definition: SkColor.h:37
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
static sk_sp< SkShader > MakeRadial(const SkPoint &center, SkScalar radius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
float SkScalar
Definition: extension.cpp:12
struct MyStruct s
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
#define SIZE
REG_FIDDLE(radial_gradient_test, 256, 256, false, 0)
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609