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=935c8f8b9782d297a73d7186f6ef7945
5cb93a386Sopenharmony_ciREG_FIDDLE(Canvas_drawTextRSXform, 256, 256, false, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    const int iterations = 26;
8cb93a386Sopenharmony_ci    SkRSXform transforms[iterations];
9cb93a386Sopenharmony_ci    char alphabet[iterations];
10cb93a386Sopenharmony_ci    SkScalar angle = 0;
11cb93a386Sopenharmony_ci    SkScalar scale = 1;
12cb93a386Sopenharmony_ci    for (size_t i = 0; i < SK_ARRAY_COUNT(transforms); ++i) {
13cb93a386Sopenharmony_ci        const SkScalar s = SkScalarSin(angle) * scale;
14cb93a386Sopenharmony_ci        const SkScalar c = SkScalarCos(angle) * scale;
15cb93a386Sopenharmony_ci        transforms[i] = SkRSXform::Make(-c, -s, -s * 16, c * 16);
16cb93a386Sopenharmony_ci        angle += .45f;
17cb93a386Sopenharmony_ci        scale += .2f;
18cb93a386Sopenharmony_ci        alphabet[i] = 'A' + i;
19cb93a386Sopenharmony_ci    }
20cb93a386Sopenharmony_ci    SkPaint paint;
21cb93a386Sopenharmony_ci    SkFont font(nullptr, 20);
22cb93a386Sopenharmony_ci    auto spiral = SkTextBlob::MakeFromRSXform(alphabet, sizeof(alphabet), transforms, font);
23cb93a386Sopenharmony_ci    canvas->drawTextBlob(spiral, 110, 138, paint);
24cb93a386Sopenharmony_ci}
25cb93a386Sopenharmony_ci}  // END FIDDLE
26