Flutter Engine
The Flutter Engine
third_party
skia
docs
examples
text_shadow.cpp
Go to the documentation of this file.
1
// Copyright 2020 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
REG_FIDDLE
(text_shadow, 128, 64,
false
, 0) {
5
void
draw
(
SkCanvas
* canvas) {
6
const
SkScalar
sigma = 1.65f;
7
const
SkScalar
xDrop = 2.0f;
8
const
SkScalar
yDrop = 2.0f;
9
const
SkScalar
x
= 8.0f;
10
const
SkScalar
y
= 52.0f;
11
const
SkScalar
textSize = 48.0f;
12
const
uint8_t blurAlpha = 127;
13
auto
blob =
SkTextBlob::MakeFromString
(
"Skia"
,
SkFont
(
nullptr
, textSize));
14
SkPaint
paint
;
15
paint
.setAntiAlias(
true
);
16
SkPaint
blur(
paint
);
17
blur.
setAlpha
(blurAlpha);
18
blur.
setMaskFilter
(
SkMaskFilter::MakeBlur
(
kNormal_SkBlurStyle
, sigma, 0));
19
canvas->
drawColor
(
SK_ColorWHITE
);
20
canvas->
drawTextBlob
(blob.get(),
x
+ xDrop,
y
+ yDrop, blur);
21
canvas->
drawTextBlob
(blob.get(),
x
,
y
,
paint
);
22
}
23
}
// END FIDDLE
kNormal_SkBlurStyle
@ kNormal_SkBlurStyle
fuzzy inside and outside
Definition:
SkBlurTypes.h:12
SK_ColorWHITE
constexpr SkColor SK_ColorWHITE
Definition:
SkColor.h:122
draw
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition:
aaclip.cpp:27
SkCanvas
Definition:
SkCanvas.h:106
SkCanvas::drawColor
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition:
SkCanvas.h:1182
SkCanvas::drawTextBlob
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition:
SkCanvas.cpp:2484
SkFont
Definition:
SkFont.h:35
SkMaskFilter::MakeBlur
static sk_sp< SkMaskFilter > MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM=true)
Definition:
SkBlurMaskFilterImpl.cpp:535
SkPaint
Definition:
SkPaint.h:44
SkPaint::setAlpha
void setAlpha(U8CPU a)
Definition:
SkPaint.h:279
SkPaint::setMaskFilter
void setMaskFilter(sk_sp< SkMaskFilter > maskFilter)
SkTextBlob::MakeFromString
static sk_sp< SkTextBlob > MakeFromString(const char *string, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
Definition:
SkTextBlob.h:115
paint
const Paint & paint
Definition:
color_source.cc:38
examples.h
SkScalar
float SkScalar
Definition:
extension.cpp:12
y
double y
Definition:
mouse-input-test.cc:83
x
double x
Definition:
mouse-input-test.cc:82
REG_FIDDLE
REG_FIDDLE(text_shadow, 128, 64, false, 0)
Definition:
text_shadow.cpp:4
Generated on Sun Jun 23 2024 21:55:56 for Flutter Engine by
1.9.4