blob: 087df59eecf7ba8a5e6b6423a2868b9187d78d26 [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=944a80c7ff8c04e1fecc4aec4a47ea60
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(Path_RawIter_next, 256, 256, true, 0) {
Hal Canary87515122019-03-15 14:22:51 -04006void draw(SkCanvas* canvas) {
7 SkPath path;
8 path.moveTo(50, 60);
9 path.quadTo(10, 20, 30, 40);
10 path.close();
11 path.lineTo(30, 30);
12 path.conicTo(1, 2, 3, 4, .5f);
13 path.cubicTo(-1, -2, -3, -4, -5, -6);
14 SkPath::RawIter iter(path);
15 const char* verbStr[] = { "Move", "Line", "Quad", "Conic", "Cubic", "Close", "Done" };
16 const int pointCount[] = { 1 , 2 , 3 , 3 , 4 , 1 , 0 };
17 SkPath::Verb verb;
18 do {
19 SkPoint points[4];
20 verb = iter.next(points);
21 SkDebugf("k%s_Verb ", verbStr[(int) verb]);
22 for (int i = 0; i < pointCount[(int) verb]; ++i) {
23 SkDebugf("{%1.8g, %1.8g}, ", points[i].fX, points[i].fY);
24 }
25 if (SkPath::kConic_Verb == verb) {
26 SkDebugf("weight = %g", iter.conicWeight());
27 }
28 SkDebugf("\n");
29 } while (SkPath::kDone_Verb != verb);
30}
31} // END FIDDLE