blob: b9a24e05cc40983258c9580702bd53742ddf7de8 [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001// 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.
Mike Kleinc0bd9f92019-04-23 12:05:21 -05003#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04004// HASH=6c9688008cea8937ad5cc188b38ecf16
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(Path_Iter_setPath, 256, 256, true, 0) {
Hal Canary87515122019-03-15 14:22:51 -04006void draw(SkCanvas* canvas) {
7 auto debugster = [](const char* prefix, SkPath::Iter& iter) -> void {
8 SkDebugf("%s:\n", prefix);
9 const char* verbStr[] = { "Move", "Line", "Quad", "Conic", "Cubic", "Close", "Done" };
10 const int pointCount[] = { 1 , 2 , 3 , 3 , 4 , 1 , 0 };
11 SkPath::Verb verb;
12 do {
13 SkPoint points[4];
14 verb = iter.next(points);
15 SkDebugf("k%s_Verb ", verbStr[(int) verb]);
16 for (int i = 0; i < pointCount[(int) verb]; ++i) {
17 SkDebugf("{%g, %g}, ", points[i].fX, points[i].fY);
18 }
19 if (SkPath::kConic_Verb == verb) {
20 SkDebugf("weight = %g", iter.conicWeight());
21 }
22 SkDebugf("\n");
23 } while (SkPath::kDone_Verb != verb);
24 SkDebugf("\n");
25 };
26 SkPath path;
27 path.quadTo(10, 20, 30, 40);
28 SkPath::Iter iter(path, false);
29 debugster("quad open", iter);
30 SkPath path2;
31 path2.conicTo(1, 2, 3, 4, .5f);
32 iter.setPath(path2, true);
33 debugster("conic closed", iter);
34}
35} // END FIDDLE