1 // Copyright 2019 Google LLC.
2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3 #include "tools/fiddle/examples.h"
4 REG_FIDDLE(Path_isLine, 256, 256, true, 0) {
draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) {
6 auto debugster = [](const char* prefix, const SkPath& path) -> void {
7 SkPoint line[2];
8 if (path.isLine(line)) {
9 SkDebugf("%s is line (%1.8g,%1.8g) (%1.8g,%1.8g)\n", prefix,
10 line[0].fX, line[0].fY, line[1].fX, line[1].fY);
11 } else {
12 SkDebugf("%s is not line\n", prefix);
13 }
14 };
15 SkPath path;
16 debugster("empty", path);
17 path.lineTo(0, 0);
18 debugster("zero line", path);
19 path.rewind();
20 path.moveTo(10, 10);
21 path.lineTo(20, 20);
22 debugster("line", path);
23 path.moveTo(20, 20);
24 debugster("second move", path);
25 }
26 } // END FIDDLE
27