Debian Codegraph @

docs/examples/fivearcs.cpp

raw
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(fivearcs, 256, 128, false, 0) {
5 void draw(SkCanvas* canvas) {
6 canvas->clear(SkColorSetARGB(255, 255, 255, 255));
7 SkPaint ovalPaint;
8 ovalPaint.setAntiAlias(true);
9 ovalPaint.setStyle(SkPaint::kStroke_Style);
10 SkPaint arcPaint(ovalPaint);
11 arcPaint.setStrokeWidth(5);
12 arcPaint.setColor(SK_ColorBLUE);
13 SkRect oval = {8, 8, 56, 56};
14
15 canvas->drawOval(oval, ovalPaint);
16 SkPath arcPath = SkPathBuilder().arcTo(oval, 0, 90, false).detach();
17 canvas->drawPath(arcPath, arcPaint);
18
19 canvas->translate(64, 0);
20 canvas->drawOval(oval, ovalPaint);
21 canvas->drawArc(oval, 0, 90, false, arcPaint);
22
23 canvas->translate(64, 0);
24 canvas->drawOval(oval, ovalPaint);
25 arcPath = SkPathBuilder().addArc(oval, 0, 90).detach();
26 canvas->drawPath(arcPath, arcPaint);
27
28 canvas->translate(-96, 64);
29 canvas->drawOval(oval, ovalPaint);
30 arcPath = SkPathBuilder()
31 .moveTo({56, 32})
32 .arcTo({56, 56}, {32, 56}, 24)
33 .detach();
34 canvas->drawPath(arcPath, arcPaint);
35
36 canvas->translate(64, 0);
37 canvas->drawOval(oval, ovalPaint);
38 arcPath = SkPathBuilder()
39 .moveTo({56, 32})
40 .arcTo({24, 24}, 0, SkPathBuilder::kSmall_ArcSize, SkPathDirection::kCW, {32, 56})
41 .detach();
42 canvas->drawPath(arcPath, arcPaint);
43 }
44 } // END FIDDLE