Flutter Engine
The Flutter Engine
sweep_gradient_talk_lots.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.
4
5#include <random>
6
7REG_FIDDLE(sweep_gradient_talk_lots, 256, 256, false, 0) {
8void draw(SkCanvas* canvas) {
9 std::default_random_engine rng;
10 const auto randOpaqueColor = [&rng]() -> SkColor {
11 return std::uniform_int_distribution<uint32_t>(0, 0xFFFFFF)(rng) | 0xFF000000;
12 };
13 SkColor colors[100];
14 for (auto& color : colors) {
15 color = randOpaqueColor();
16 }
17 float cx = 128, cy = 128;
19 paint.setShader(SkGradientShader::MakeSweep(cx, cy, colors, nullptr, 100));
20 canvas->drawPaint(paint);
21}
22} // END FIDDLE
uint32_t SkColor
Definition: SkColor.h:37
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawPaint(const SkPaint &paint)
Definition: SkCanvas.cpp:1668
static sk_sp< SkShader > MakeSweep(SkScalar cx, SkScalar cy, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, SkScalar startAngle, SkScalar endAngle, uint32_t flags, const SkMatrix *localMatrix)
const Paint & paint
Definition: color_source.cc:38
DlColor color
PODArray< SkColor > colors
Definition: SkRecords.h:276
REG_FIDDLE(sweep_gradient_talk_lots, 256, 256, false, 0)