Flutter Engine
The Flutter Engine
Canvas_drawTextRSXform.cpp
Go to the documentation of this file.
1// Copyright 2019 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4REG_FIDDLE(Canvas_drawTextRSXform, 256, 256, false, 0) {
5void draw(SkCanvas* canvas) {
6 const int iterations = 26;
7 SkRSXform transforms[iterations];
8 char alphabet[iterations];
9 SkScalar angle = 0;
10 SkScalar scale = 1;
11 for (size_t i = 0; i < std::size(transforms); ++i) {
12 const SkScalar s = SkScalarSin(angle) * scale;
13 const SkScalar c = SkScalarCos(angle) * scale;
14 transforms[i] = SkRSXform::Make(-c, -s, -s * 16, c * 16);
15 angle += .45f;
16 scale += .2f;
17 alphabet[i] = 'A' + i;
18 }
20 SkFont font(fontMgr->matchFamilyStyle(nullptr, {}), 20);
21 auto spiral = SkTextBlob::MakeFromRSXform(alphabet, sizeof(alphabet), transforms, font);
22 canvas->drawTextBlob(spiral, 110, 138, paint);
23}
24} // END FIDDLE
REG_FIDDLE(Canvas_drawTextRSXform, 256, 256, false, 0)
#define SkScalarSin(radians)
Definition: SkScalar.h:45
#define SkScalarCos(radians)
Definition: SkScalar.h:46
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
sk_sp< SkTypeface > matchFamilyStyle(const char familyName[], const SkFontStyle &) const
Definition: SkFontMgr.cpp:109
Definition: SkFont.h:35
static sk_sp< SkTextBlob > MakeFromRSXform(const void *text, size_t byteLength, const SkRSXform xform[], const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
Definition: SkTextBlob.cpp:831
const Paint & paint
Definition: color_source.cc:38
sk_sp< SkFontMgr > fontMgr
Definition: examples.cpp:32
float SkScalar
Definition: extension.cpp:12
struct MyStruct s
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
font
Font Metadata and Metrics.
const Scalar scale
static SkRSXform Make(SkScalar scos, SkScalar ssin, SkScalar tx, SkScalar ty)
Definition: SkRSXform.h:24