1cb93a386Sopenharmony_ci// Copyright 2019 Google LLC.
2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h"
4cb93a386Sopenharmony_ci// HASH=13044dbf68885c0f15322c0633b633a3
5cb93a386Sopenharmony_ciREG_FIDDLE(Path_Iter_const_SkPath, 256, 256, true, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    auto debugster = [](const char* prefix, SkPath::Iter& iter) -> void {
8cb93a386Sopenharmony_ci        SkDebugf("%s:\n", prefix);
9cb93a386Sopenharmony_ci        const char* verbStr[] =  { "Move", "Line", "Quad", "Conic", "Cubic", "Close", "Done" };
10cb93a386Sopenharmony_ci        const int pointCount[] = {     1 ,     2 ,     3 ,      3 ,      4 ,      1 ,     0  };
11cb93a386Sopenharmony_ci        SkPath::Verb verb;
12cb93a386Sopenharmony_ci        do {
13cb93a386Sopenharmony_ci           SkPoint points[4];
14cb93a386Sopenharmony_ci           verb = iter.next(points);
15cb93a386Sopenharmony_ci           SkDebugf("k%s_Verb ", verbStr[(int) verb]);
16cb93a386Sopenharmony_ci           for (int i = 0; i < pointCount[(int) verb]; ++i) {
17cb93a386Sopenharmony_ci                SkDebugf("{%g, %g}, ", points[i].fX, points[i].fY);
18cb93a386Sopenharmony_ci           }
19cb93a386Sopenharmony_ci           if (SkPath::kConic_Verb == verb) {
20cb93a386Sopenharmony_ci               SkDebugf("weight = %g", iter.conicWeight());
21cb93a386Sopenharmony_ci           }
22cb93a386Sopenharmony_ci           SkDebugf("\n");
23cb93a386Sopenharmony_ci        } while (SkPath::kDone_Verb != verb);
24cb93a386Sopenharmony_ci        SkDebugf("\n");
25cb93a386Sopenharmony_ci    };
26cb93a386Sopenharmony_ci    SkPath path;
27cb93a386Sopenharmony_ci    path.quadTo(10, 20, 30, 40);
28cb93a386Sopenharmony_ci    SkPath::Iter openIter(path, false);
29cb93a386Sopenharmony_ci    debugster("open", openIter);
30cb93a386Sopenharmony_ci    SkPath::Iter closedIter(path, true);
31cb93a386Sopenharmony_ci    debugster("closed", closedIter);
32cb93a386Sopenharmony_ci}
33cb93a386Sopenharmony_ci}  // END FIDDLE
34