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=9e0a2de2eb94dba4521d733e73f2bda5 |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 6 | REG_FIDDLE(Point_Distance, 256, 192, false, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 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. |