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_Iter_next, 256, 256, true, 0) {
draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) {
6 SkPath path;
7 path.moveTo(10, 10);
8 path.moveTo(20, 20);
9 path.quadTo(10, 20, 30, 40);
10 path.moveTo(1, 1);
11 path.close();
12 path.moveTo(30, 30);
13 path.lineTo(30.00001f, 30);
14
15 SkPath::Iter iter(path, false);
16 const char* verbStr[] = { "Move", "Line", "Quad", "Conic", "Cubic", "Close", "Done" };
17 const int pointCount[] = { 1 , 2 , 3 , 3 , 4 , 1 , 0 };
18 SkPath::Verb verb;
19 do {
20 SkPoint points[4];
21 verb = iter.next(points);
22 SkDebugf("k%s_Verb ", verbStr[(int) verb]);
23 for (int i = 0; i < pointCount[(int) verb]; ++i) {
24 SkDebugf("{%1.8g, %1.8g}, ", points[i].fX, points[i].fY);
25 }
26 SkDebugf("\n");
27 } while (SkPath::kDone_Verb != verb);
28 SkDebugf("\n");
29 }
30 } // END FIDDLE
31