Debian Codegraph @

docs/examples/Path_Iter_setPath.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_setPath, 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()
22 .quadTo(10, 20, 30, 40)
23 .detach();
24 SkPath::Iter iter(path, false);
25 debugster("quad open", iter);
26 SkPath path2 = SkPathBuilder()
27 .conicTo(1, 2, 3, 4, .5f)
28 .detach();
29 iter.setPath(path2, true);
30 debugster("conic closed", iter);
31 }
32 } // END FIDDLE