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