Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
drawarcs.cpp File Reference
#include "tools/fiddle/examples.h"
#include <random>

Go to the source code of this file.

Functions

 REG_FIDDLE (drawarcs, 256, 256, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( drawarcs  ,
256  ,
256  ,
false  ,
 
)

Definition at line 7 of file drawarcs.cpp.

7 {
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)
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
const Paint & paint
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