Flutter Engine
The Flutter Engine
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.
4REG_FIDDLE(text_shadow, 128, 64, false, 0) {
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);
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)
void setAlpha(U8CPU a)
Definition: SkPaint.h:279
void setMaskFilter(sk_sp< SkMaskFilter > maskFilter)
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
REG_FIDDLE(text_shadow, 128, 64, false, 0)
Definition: text_shadow.cpp:4