blob: 6781225fbe81983a70a8059cf506756fe217f272 [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=9e0a2de2eb94dba4521d733e73f2bda5
Hal Canarya7181e7c2019-03-18 16:06:34 -04006REG_FIDDLE(Point_Distance, 256, 192, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04007void 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.