1cb93a386Sopenharmony_ci// Copyright 2019 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_ci// HASH=81a2aac1b8f0ff3d4c8d35ccb9149b16
5cb93a386Sopenharmony_ciREG_FIDDLE(Path_isRect, 256, 256, true, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    auto debugster = [](const char* prefix, const SkPath& path) -> void {
8cb93a386Sopenharmony_ci        SkRect rect;
9cb93a386Sopenharmony_ci        SkPathDirection direction;
10cb93a386Sopenharmony_ci        bool isClosed;
11cb93a386Sopenharmony_ci        path.isRect(&rect, &isClosed, &direction) ?
12cb93a386Sopenharmony_ci                SkDebugf("%s is rect (%g, %g, %g, %g); is %s" "closed; direction %s\n", prefix,
13cb93a386Sopenharmony_ci                         rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, isClosed ? "" : "not ",
14cb93a386Sopenharmony_ci                         SkPathDirection::kCW == direction ? "CW" : "CCW") :
15cb93a386Sopenharmony_ci                SkDebugf("%s is not rect\n", prefix);
16cb93a386Sopenharmony_ci    };
17cb93a386Sopenharmony_ci    SkPath path;
18cb93a386Sopenharmony_ci    debugster("empty", path);
19cb93a386Sopenharmony_ci    path.addRect({10, 20, 30, 40});
20cb93a386Sopenharmony_ci    debugster("addRect", path);
21cb93a386Sopenharmony_ci    path.moveTo(60, 70);
22cb93a386Sopenharmony_ci    debugster("moveTo", path);
23cb93a386Sopenharmony_ci    path.lineTo(60, 70);
24cb93a386Sopenharmony_ci    debugster("lineTo", path);
25cb93a386Sopenharmony_ci    path.reset();
26cb93a386Sopenharmony_ci    const SkPoint pts[] = { {0, 0}, {0, 80}, {80, 80}, {80, 0}, {40, 0}, {20, 0} };
27cb93a386Sopenharmony_ci    path.addPoly(pts, SK_ARRAY_COUNT(pts), false);
28cb93a386Sopenharmony_ci    debugster("addPoly", path);
29cb93a386Sopenharmony_ci}
30cb93a386Sopenharmony_ci}  // END FIDDLE
31