Flutter Engine
The Flutter Engine
drawarcs.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(drawarcs, 256, 256, false, 0) {
8void draw(SkCanvas* canvas) {
10 paint.setAntiAlias(true);
12 paint.setStrokeWidth(8);
13
14 std::default_random_engine rng;
15 const auto randScalar = [&rng](SkScalar min, SkScalar max) -> SkScalar {
16 return std::uniform_real_distribution<SkScalar>(min, max)(rng);
17 };
18 const auto randOpaqueColor = [&rng]() -> SkColor {
19 return std::uniform_int_distribution<uint32_t>(0, 0xFFFFFF)(rng) | 0xFF000000;
20 };
22
23 for (int i = 0; i < 100; ++i) {
24 SkScalar x = randScalar(0, 200);
25 SkScalar y = randScalar(0, 200);
26
27 path.rewind();
28 path.addArc(SkRect::MakeXYWH(x, y, 70, 70), randScalar(0, 360),
29 randScalar(0, 360));
30 paint.setColor(randOpaqueColor());
31 canvas->drawPath(path, paint);
32 }
33}
34} // 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 drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
Definition: SkPath.h:59
const Paint & paint
Definition: color_source.cc:38
REG_FIDDLE(drawarcs, 256, 256, false, 0)
Definition: drawarcs.cpp:7
float SkScalar
Definition: extension.cpp:12
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48
double y
double x
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659