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) {
draw(SkCanvas * canvas)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;
16 path.lineTo(20, 20);
17 path.lineTo(-10, -10);
18 uint8_t verbs[3];
19 debugster("no verbs", path, nullptr, 0);
20 debugster("zero max", path, verbs, 0);
21 debugster("too small", path, verbs, 2);
22 debugster("just right", path, verbs, path.countVerbs());
23 }
24 } // END FIDDLE
25