Flutter Engine
The Flutter Engine
Functions
text_shadow.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (text_shadow, 128, 64, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( text_shadow  ,
128  ,
64  ,
false  ,
 
)

Definition at line 4 of file text_shadow.cpp.

4 {
5void 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));
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
fuzzy inside and outside
Definition: SkBlurTypes.h:12
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
Definition: SkFont.h:35
static sk_sp< SkMaskFilter > MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM=true)
static sk_sp< SkTextBlob > MakeFromString(const char *string, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
Definition: SkTextBlob.h:115
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
double y
double x