1cb93a386Sopenharmony_ci// Copyright 2020 Google LLC.
2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h"
4cb93a386Sopenharmony_ciREG_FIDDLE(skpaint_path_2d_path_effect, 256, 256, false, 0) {
5cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
6cb93a386Sopenharmony_ci    SkScalar scale = 10.0f;
7cb93a386Sopenharmony_ci    SkPath path;
8cb93a386Sopenharmony_ci    static const int8_t pts[] = {2, 2, 1, 3, 0, 3, 2, 1, 3, 1, 4, 0, 4, 1,
9cb93a386Sopenharmony_ci                                 5, 1, 4, 2, 4, 3, 2, 5, 2, 4, 3, 3, 2, 3};
10cb93a386Sopenharmony_ci    path.moveTo(2 * scale, 3 * scale);
11cb93a386Sopenharmony_ci    for (size_t i = 0; i < sizeof(pts) / sizeof(pts[0]); i += 2) {
12cb93a386Sopenharmony_ci        path.lineTo(pts[i] * scale, pts[i + 1] * scale);
13cb93a386Sopenharmony_ci    }
14cb93a386Sopenharmony_ci    path.close();
15cb93a386Sopenharmony_ci    SkMatrix matrix = SkMatrix::Scale(4 * scale, 4 * scale);
16cb93a386Sopenharmony_ci    SkPaint paint;
17cb93a386Sopenharmony_ci    paint.setPathEffect(SkPath2DPathEffect::Make(matrix, path));
18cb93a386Sopenharmony_ci    paint.setAntiAlias(true);
19cb93a386Sopenharmony_ci    canvas->clear(SK_ColorWHITE);
20cb93a386Sopenharmony_ci    SkRect bounds{-4 * scale, -4 * scale, 256, 256};
21cb93a386Sopenharmony_ci    canvas->drawRect(bounds, paint);
22cb93a386Sopenharmony_ci}
23cb93a386Sopenharmony_ci}  // END FIDDLE
24