Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
skcanvas_star.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.
4REG_FIDDLE(skcanvas_star, 256, 256, false, 0) {
5void draw(SkCanvas* canvas) {
6 const SkScalar scale = 256.0f;
7 const SkScalar R = 0.45f * scale;
8 const SkScalar TAU = 6.2831853f;
9 SkPath path;
10 path.moveTo(R, 0.0f);
11 for (int i = 1; i < 7; ++i) {
12 SkScalar theta = 3 * i * TAU / 7;
13 path.lineTo(R * cos(theta), R * sin(theta));
14 }
15 path.close();
16 SkPaint p;
17 p.setAntiAlias(true);
18 canvas->clear(SK_ColorWHITE);
19 canvas->translate(0.5f * scale, 0.5f * scale);
20 canvas->drawPath(path, p);
21}
22} // END FIDDLE
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void translate(SkScalar dx, SkScalar dy)
void clear(SkColor color)
Definition SkCanvas.h:1199
void drawPath(const SkPath &path, const SkPaint &paint)
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition examples.h:60
float SkScalar
Definition extension.cpp:12
#define R(r)
const Scalar scale