| 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 |