Debian Codegraph @

docs/examples/Path_getVerbs.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_getVerbs, 256, 256, true, 0) {
5 void draw(SkCanvas* canvas) {
6 auto debugster = [](const char* prefix, const SkPath& path, uint8_t* verbs, int max) -> void {
7 int count = path.getVerbs({verbs, max});
8 SkDebugf("%s verb count: %d ", prefix, count);
9 const char* verbStr[] = { "move", "line", "quad", "conic", "cubic", "close" };
10 for (int i = 0; i < std::min(count, max) && verbs; ++i) {
11 SkDebugf("%s ", verbStr[verbs[i]]);
12 }
13 SkDebugf("\n");
14 };
15 SkPath path = SkPathBuilder()
16 .lineTo(20, 20)
17 .lineTo(-10, -10)
18 .detach();
19 uint8_t verbs[3];
20 debugster("no verbs", path, nullptr, 0);
21 debugster("zero max", path, verbs, 0);
22 debugster("too small", path, verbs, 2);
23 debugster("just right", path, verbs, path.countVerbs());
24 }
25 } // END FIDDLE