blob: 209fb59aef77cfc66a8dc2fdf8d0a5dda3816870 [file] [log] [blame]
reed19d8f9f2015-01-29 10:48:16 -08001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "gm.h"
9#include "SkCanvas.h"
10#include "SkRandom.h"
11
12class AddArcGM : public skiagm::GM {
13protected:
14 SkString onShortName() SK_OVERRIDE { return SkString("addarc"); }
15
16 SkISize onISize() SK_OVERRIDE { return SkISize::Make(1040, 1040); }
17
18 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
19 canvas->translate(20, 20);
20
21 SkRect r = SkRect::MakeWH(1000, 1000);
22
23 SkPaint paint;
24 paint.setAntiAlias(true);
25 paint.setStyle(SkPaint::kStroke_Style);
26 paint.setStrokeWidth(15);
27
28 const SkScalar inset = paint.getStrokeWidth() + 4;
29 const SkScalar sweepAngle = 345;
30 SkRandom rand;
31
32 while (r.width() > paint.getStrokeWidth() * 3) {
33 paint.setColor(rand.nextU() | (0xFF << 24));
34 SkScalar startAngle = rand.nextUScalar1() * 360;
35
36 SkPath path;
37 path.addArc(r, startAngle, sweepAngle);
38 canvas->drawPath(path, paint);
39
40 r.inset(inset, inset);
41
42 }
43 }
44
45private:
46 typedef skiagm::GM INHERITED;
47};
48DEF_GM( return new AddArcGM; )