xref: /aosp_15_r20/external/skia/docs/examples/Path_cubicTo.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(Path_cubicTo, 256, 256, false, 0) {
draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) {
6     SkPaint paint;
7     paint.setAntiAlias(true);
8     paint.setStyle(SkPaint::kStroke_Style);
9     SkPath path;
10     path.moveTo(0, -10);
11     for (int i = 0; i < 128; i += 16) {
12         SkScalar c = i * 0.5f;
13         path.cubicTo( 10 + c, -10 - i,  10 + i, -10 - c,  10 + i,       0);
14         path.cubicTo( 14 + i,  14 + c,  14 + c,  14 + i,       0,  14 + i);
15         path.cubicTo(-18 - c,  18 + i, -18 - i,  18 + c, -18 - i,       0);
16         path.cubicTo(-22 - i, -22 - c, -22 - c, -22 - i,       0, -22 - i);
17     }
18     path.offset(128, 128);
19     canvas->drawPath(path, paint);
20 }
21 }  // END FIDDLE
22