Debian Codegraph @

docs/examples/Path_Iter_const_SkPath.cpp

raw
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) {
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 while (auto rec = iter.next()) {
10 SkDebugf("k%s_Verb ", verbStr[(int)rec->fVerb]);
11 for (SkPoint p : rec->fPoints) {
12 SkDebugf("{%g, %g}, ", p.fX, p.fY);
13 }
14 if (SkPathVerb::kConic == rec->fVerb) {
15 SkDebugf("weight = %g", rec->conicWeight());
16 }
17 SkDebugf("\n");
18 }
19 SkDebugf("\n");
20 };
21 SkPath path = SkPathBuilder().quadTo(10, 20, 30, 40).detach();
22 SkPath::Iter openIter(path, false);
23 debugster("open", openIter);
24 SkPath::Iter closedIter(path, true);
25 debugster("closed", closedIter);
26 }
27 } // END FIDDLE