Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / docs / examples / compose_path.cpp
1 // Copyright 2020 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(compose_path, 256, 256, false, 0) {
5 SkPath star() {
6     const SkScalar R = 115.2f, C = 128.0f;
7     SkPath path;
8     path.moveTo(C + R, C);
9     for (int i = 1; i < 8; ++i) {
10         SkScalar a = 2.6927937f * i;
11         path.lineTo(C + R * cos(a), C + R * sin(a));
12     }
13     return path;
14 }
15 void draw(SkCanvas* canvas) {
16     const SkScalar intervals[] = {10.0f, 5.0f, 2.0f, 5.0f};
17     size_t count = sizeof(intervals) / sizeof(intervals[0]);
18     SkPaint paint;
19     paint.setPathEffect(
20             SkPathEffect::MakeCompose(SkDashPathEffect::Make(intervals, count, 0.0f),
21                                       SkDiscretePathEffect::Make(10.0f, 4.0f)));
22     paint.setStyle(SkPaint::kStroke_Style);
23     paint.setStrokeWidth(2.0f);
24     paint.setAntiAlias(true);
25     paint.setColor(0xff4285F4);
26     canvas->clear(SK_ColorWHITE);
27     SkPath path(star());
28     canvas->drawPath(path, paint);
29 }
30 }  // END FIDDLE