blob: bb96907762e6bea031cc32f5e864e9d2cb37d3ff [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001#if 0 // Disabled until updated to use current API.
2// Copyright 2019 Google LLC.
3// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Mike Kleinc0bd9f92019-04-23 12:05:21 -05004#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04005// HASH=5acc77eba0cb4d00bbf3a8f4db0c0aee
Hal Canarya7181e7c2019-03-18 16:06:34 -04006REG_FIDDLE(Arc, 256, 128, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04007void draw(SkCanvas* canvas) {
8 SkRect oval = {8, 8, 56, 56};
9 SkPaint ovalPaint;
10 ovalPaint.setAntiAlias(true);
11 SkPaint textPaint(ovalPaint);
12 ovalPaint.setStyle(SkPaint::kStroke_Style);
13 SkPaint arcPaint(ovalPaint);
14 arcPaint.setStrokeWidth(5);
15 arcPaint.setColor(SK_ColorBLUE);
16 canvas->translate(-64, 0);
17 for (char arcStyle = '1'; arcStyle <= '6'; ++arcStyle) {
18 '4' == arcStyle ? canvas->translate(-96, 55) : canvas->translate(64, 0);
19 canvas->drawText(&arcStyle, 1, 30, 36, textPaint);
20 canvas->drawOval(oval, ovalPaint);
21 SkPath path;
22 path.moveTo({56, 32});
23 switch (arcStyle) {
24 case '1':
25 path.arcTo(oval, 0, 90, false);
26 break;
27 case '2':
28 canvas->drawArc(oval, 0, 90, false, arcPaint);
29 continue;
30 case '3':
31 path.addArc(oval, 0, 90);
32 break;
33 case '4':
34 path.arcTo({56, 56}, {32, 56}, 24);
35 break;
36 case '5':
Mike Reed30bc5272019-11-22 18:34:02 +000037 path.arcTo({24, 24}, 0, SkPath::kSmall_ArcSize, SkPathDirection::kCW, {32, 56});
Hal Canary87515122019-03-15 14:22:51 -040038 break;
39 case '6':
40 path.conicTo({56, 56}, {32, 56}, SK_ScalarRoot2Over2);
41 break;
42 }
43 canvas->drawPath(path, arcPaint);
44 }
45}
46} // END FIDDLE
47#endif // Disabled until updated to use current API.