Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 1 | #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 Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 4 | #include "tools/fiddle/examples.h" |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 5 | // HASH=5acc77eba0cb4d00bbf3a8f4db0c0aee |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 6 | REG_FIDDLE(Arc, 256, 128, false, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 7 | void 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 Reed | 30bc527 | 2019-11-22 18:34:02 +0000 | [diff] [blame] | 37 | path.arcTo({24, 24}, 0, SkPath::kSmall_ArcSize, SkPathDirection::kCW, {32, 56}); |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 38 | 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. |