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

Go to the source code of this file.

Functions

 REG_FIDDLE (skpaint_blur_mask_filter_2, 256, 256, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( skpaint_blur_mask_filter_2  ,
256  ,
256  ,
false  ,
 
)

Definition at line 4 of file skpaint_blur_mask_filter_2.cpp.

4 {
5void draw(SkCanvas* canvas) {
6 const SkScalar blurSigma = 3.4f;
7 const SkColor blurColor = SkColorSetRGB(96, 96, 0);
8 const uint8_t blurAlpha = 127;
9 const SkScalar xDrop = 5.0f;
10 const SkScalar yDrop = 5.0f;
11
12 const char text[] = "Skia";
13 const SkScalar x = 0.0f;
14 const SkScalar y = 160.0f;
15
16 canvas->drawColor(SK_ColorWHITE);
17
19 paint.setAntiAlias(true);
20
21 SkPaint blur(paint);
22 blur.setColor(blurColor);
23 blur.setAlpha(blurAlpha);
24 blur.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, blurSigma, false));
25
26 SkFont font(fontMgr->matchFamilyStyle(nullptr, {}), 120);
27
28 // Draw once with drop shadow blur;
29 canvas->drawString(text, x + xDrop, y + yDrop, font, blur);
30
31 // Overdraw with with no blur mask
32 canvas->drawString(text, x, y, font, paint);
33}
34} // END FIDDLE
@ kNormal_SkBlurStyle
fuzzy inside and outside
Definition: SkBlurTypes.h:12
uint32_t SkColor
Definition: SkColor.h:37
#define SkColorSetRGB(r, g, b)
Definition: SkColor.h:57
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 drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
sk_sp< SkTypeface > matchFamilyStyle(const char familyName[], const SkFontStyle &) const
Definition: SkFontMgr.cpp:109
Definition: SkFont.h:35
static sk_sp< SkMaskFilter > MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM=true)
const Paint & paint
Definition: color_source.cc:38
sk_sp< SkFontMgr > fontMgr
Definition: examples.cpp:32
float SkScalar
Definition: extension.cpp:12
std::u16string text
double y
double x
font
Font Metadata and Metrics.