Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
docs
examples
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.
3
#include "
tools/fiddle/examples.h
"
4
// HASH=935c8f8b9782d297a73d7186f6ef7945
5
REG_FIDDLE
(Canvas_drawTextRSXform, 256, 256,
false
, 0) {
6
void
draw
(
SkCanvas
* canvas) {
7
const
int
iterations = 26;
8
SkRSXform
transforms[iterations];
9
char
alphabet[iterations];
10
SkScalar
angle = 0;
11
SkScalar
scale
= 1;
12
for
(
size_t
i = 0; i < std::size(transforms); ++i) {
13
const
SkScalar
s
=
SkScalarSin
(angle) *
scale
;
14
const
SkScalar
c =
SkScalarCos
(angle) *
scale
;
15
transforms[i] =
SkRSXform::Make
(-c, -
s
, -
s
* 16, c * 16);
16
angle += .45f;
17
scale
+= .2f;
18
alphabet[i] =
'A'
+ i;
19
}
20
SkPaint
paint
;
21
SkFont
font(
fontMgr
->
matchFamilyStyle
(
nullptr
, {}), 20);
22
auto
spiral =
SkTextBlob::MakeFromRSXform
(alphabet,
sizeof
(alphabet), transforms, font);
23
canvas->
drawTextBlob
(spiral, 110, 138,
paint
);
24
}
25
}
// END FIDDLE
SkScalarSin
#define SkScalarSin(radians)
Definition
SkScalar.h:45
SkScalarCos
#define SkScalarCos(radians)
Definition
SkScalar.h:46
draw
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition
aaclip.cpp:27
SkCanvas
Definition
SkCanvas.h:106
SkCanvas::drawTextBlob
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition
SkCanvas.cpp:2911
SkFontMgr::matchFamilyStyle
sk_sp< SkTypeface > matchFamilyStyle(const char familyName[], const SkFontStyle &) const
Definition
SkFontMgr.cpp:109
SkFont
Definition
SkFont.h:35
SkPaint
Definition
SkPaint.h:44
SkTextBlob::MakeFromRSXform
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
paint
const Paint & paint
Definition
color_source.cc:38
fontMgr
sk_sp< SkFontMgr > fontMgr
Definition
examples.cpp:32
examples.h
REG_FIDDLE
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition
examples.h:60
SkScalar
float SkScalar
Definition
extension.cpp:12
s
struct MyStruct s
scale
const Scalar scale
Definition
stroke_path_geometry.cc:253
SkRSXform
Definition
SkRSXform.h:23
SkRSXform::Make
static SkRSXform Make(SkScalar scos, SkScalar ssin, SkScalar tx, SkScalar ty)
Definition
SkRSXform.h:24
Generated on Fri Apr 26 2024 06:15:34 for Flutter Engine by
1.9.8