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