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=9e0a2de2eb94dba4521d733e73f2bda5
REG_FIDDLE(Point_Distance, 256, 192, false, 0)6 REG_FIDDLE(Point_Distance, 256, 192, false, 0) {
7 void draw(SkCanvas* canvas) {
8 SkPaint paint;
9 paint.setAntiAlias(true);
10 const SkPoint lines[][2] = {{{-10, -10}, {90, 30}}, {{0, 0}, {150, 30}}, {{10, 25}, {120, 150}}};
11 const SkPoint origin = {30, 160};
12 for (auto line : lines) {
13 SkPoint a = origin + line[0];
14 const SkPoint& b = line[1];
15 canvas->drawLine(a, b, paint);
16 SkAutoCanvasRestore acr(canvas, true);
17 SkScalar angle = SkScalarATan2((b.fY - a.fY), b.fX - a.fX);
18 canvas->rotate(angle * 180 / SK_ScalarPI, a.fX, a.fY);
19 SkString distance("distance = ");
20 distance.appendScalar(SkPoint::Distance(a, b));
21 canvas->drawString(distance, a.fX + 25, a.fY - 4, paint);
22 }
23 }
24 } // END FIDDLE
25 #endif // Disabled until updated to use current API.
26