Flutter Engine
The Flutter Engine
Functions
sweep_gradient_talk_lots.cpp File Reference
#include "tools/fiddle/examples.h"
#include <random>

Go to the source code of this file.

Functions

 REG_FIDDLE (sweep_gradient_talk_lots, 256, 256, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( sweep_gradient_talk_lots  ,
256  ,
256  ,
false  ,
 
)

Definition at line 7 of file sweep_gradient_talk_lots.cpp.

7 {
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