| 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 |
|
| 5 |
#include <random> |
| 6 |
|
| 7 |
REG_FIDDLE(sweep_gradient_talk_lots, 256, 256, false, 0) { |
| 8 |
void 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 |
SkColor4f colors[100]; |
| 14 |
for (auto& color : colors) { |
| 15 |
color = SkColor4f::FromColor(randOpaqueColor()); |
| 16 |
} |
| 17 |
float cx = 128, cy = 128; |
| 18 |
SkPaint paint; |
| 19 |
paint.setShader(SkShaders::SweepGradient({cx, cy}, {{colors, {}, SkTileMode::kClamp}, {}})); |
| 20 |
canvas->drawPaint(paint); |
| 21 |
} |
| 22 |
} // END FIDDLE |