xref: /aosp_15_r20/external/skia/docs/examples/Conic_Weight_c.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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(Conic_Weight_c, 256, 256, true, 0) {
draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) {
6     const char* verbNames[] = { "move", "line", "quad", "conic", "cubic", "close", "done" };
7     const int pointCount[]  = {     1 ,     2 ,     3 ,      3 ,      4 ,      1 ,     0  };
8     SkPath path;
9     path.conicTo(20, 0, 20, 20, SK_ScalarInfinity);
10     SkPath::Iter iter(path, false);
11     SkPath::Verb verb;
12     do {
13        SkPoint points[4];
14        verb = iter.next(points);
15        SkDebugf("%s ", verbNames[(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 }
25 }  // END FIDDLE
26