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=888edd4c4a91ca62ceb01bce8ab675b2
5cb93a386Sopenharmony_ciREG_FIDDLE(Path_addRRect_2, 256, 256, false, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    SkPaint paint;
8cb93a386Sopenharmony_ci    paint.setAntiAlias(true);
9cb93a386Sopenharmony_ci    SkRRect rrect;
10cb93a386Sopenharmony_ci    rrect.setRectXY({40, 40, 215, 215}, 50, 50);
11cb93a386Sopenharmony_ci    SkPath path;
12cb93a386Sopenharmony_ci    path.addRRect(rrect);
13cb93a386Sopenharmony_ci    canvas->drawPath(path, paint);
14cb93a386Sopenharmony_ci    for (int start = 0; start < 8; ++start) {
15cb93a386Sopenharmony_ci        SkPath textPath;
16cb93a386Sopenharmony_ci        textPath.addRRect(rrect, SkPathDirection::kCW, start);
17cb93a386Sopenharmony_ci        SkPathMeasure pathMeasure(textPath, false);
18cb93a386Sopenharmony_ci        SkPoint position;
19cb93a386Sopenharmony_ci        SkVector tangent;
20cb93a386Sopenharmony_ci        if (!pathMeasure.getPosTan(0, &position, &tangent)) {
21cb93a386Sopenharmony_ci            continue;
22cb93a386Sopenharmony_ci        }
23cb93a386Sopenharmony_ci        SkRSXform rsxForm = SkRSXform::Make(tangent.fX, tangent.fY,
24cb93a386Sopenharmony_ci               position.fX + tangent.fY * 5, position.fY - tangent.fX * 5);
25cb93a386Sopenharmony_ci        SkFont font(nullptr, 12);
26cb93a386Sopenharmony_ci        auto labels = SkTextBlob::MakeFromRSXform(&"01234567"[start], 1, &rsxForm, font);
27cb93a386Sopenharmony_ci        canvas->drawTextBlob(labels, 0, 0, paint);
28cb93a386Sopenharmony_ci    }
29cb93a386Sopenharmony_ci}
30cb93a386Sopenharmony_ci}  // END FIDDLE
31