| 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 |
REG_FIDDLE(skcanvas_star, 256, 256, false, 0) { |
| 5 |
void draw(SkCanvas* canvas) { |
| 6 |
const SkScalar scale = 256.0f; |
| 7 |
const SkScalar R = 0.45f * scale; |
| 8 |
const SkScalar TAU = 6.2831853f; |
| 9 |
SkPathBuilder 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.detach(), p); |
| 21 |
} |
| 22 |
} // END FIDDLE |