Skip to content

Instantly share code, notes, and snippets.

@Zamlox
Created October 29, 2016 21:11
Show Gist options
  • Save Zamlox/640a9cbc7a0bd074e45d6808edae3b04 to your computer and use it in GitHub Desktop.
Save Zamlox/640a9cbc7a0bd074e45d6808edae3b04 to your computer and use it in GitHub Desktop.
void draw(SkCanvas* canvas) {
const SkScalar scale = 256.0f;
const SkScalar R = 0.45f * scale;
const SkScalar TAU = 6.2831853f;
SkPath path;
path.moveTo(R, 0.0f);
for (int i = 1; i < 7; ++i) {
SkScalar theta = 3 * i * TAU / 7;
path.lineTo(R * cos(theta), R * sin(theta));
}
path.close();
SkPaint p;
p.setAntiAlias(true);
canvas->clear(SK_ColorWHITE);
canvas->translate(0.5f * scale, 0.5f * scale);
canvas->clipPath(path);
canvas->clear(SK_ColorBLACK);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment