• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 #include "tools/fiddle/examples.h"
5 // HASH=78f3c65fa900610bb52518989b547095
6 REG_FIDDLE(Path_arcTo_2_b, 256, 128, false, 0) {
7 void draw(SkCanvas* canvas) {
8     SkPaint tangentPaint;
9     tangentPaint.setAntiAlias(true);
10     SkPaint textPaint(tangentPaint);
11     tangentPaint.setStyle(SkPaint::kStroke_Style);
12     tangentPaint.setColor(SK_ColorGRAY);
13     SkPaint arcPaint(tangentPaint);
14     arcPaint.setStrokeWidth(5);
15     arcPaint.setColor(SK_ColorBLUE);
16     SkPath path;
17     SkPoint pts[] = { {156, 20}, {200, 20}, {170, 50} };
18     SkScalar radius = 50;
19     path.moveTo(pts[0]);
20     path.arcTo(pts[1], pts[2], radius);
21     canvas->drawLine(pts[0], pts[1], tangentPaint);
22     canvas->drawLine(pts[1], pts[2], tangentPaint);
23     SkPoint lastPt;
24     (void) path.getLastPt(&lastPt);
25     SkVector radial = pts[2] - pts[1];
26     radial.setLength(radius);
27     SkPoint center = { lastPt.fX - radial.fY, lastPt.fY + radial.fX };
28     canvas->drawLine(lastPt, center, tangentPaint);
29     radial = pts[1] - pts[0];
30     radial.setLength(radius);
31     SkPoint arcStart = { center.fX + radial.fY, center.fY - radial.fX };
32     canvas->drawLine(center, arcStart, tangentPaint);
33     canvas->drawPath(path, arcPaint);
34     canvas->drawString("(x0, y0)", pts[0].fX, pts[0].fY - 7, textPaint);
35     canvas->drawString("(x1, y1)", pts[1].fX + 5, pts[1].fY, textPaint);
36     canvas->drawString("(x2, y2)", pts[2].fX, pts[2].fY + 15, textPaint);
37     canvas->drawString("radius", center.fX + 15, center.fY + 25, textPaint);
38     canvas->drawString("radius", center.fX - 5, center.fY - 20, textPaint);
39 }
40 }  // END FIDDLE
41 #endif  // Disabled until updated to use current API.
42