Hal Canary | 6c8422c | 2020-01-10 15:22:09 -0500 | [diff] [blame] | 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(skpaint_blur_mask_filter_2, 256, 256, false, 0) { |
| 5 | void 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 | |
| 18 | SkPaint paint; |
| 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(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 |