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_skia, 256, 256, false, 0) { |
| 5 | // https://fiddle.skia.org/c/@skpaint_skia |
| 6 | |
| 7 | void draw(SkCanvas* canvas) { |
| 8 | SkPaint paint1, paint2, paint3; |
| 9 | |
| 10 | paint1.setAntiAlias(true); |
| 11 | paint1.setColor(SkColorSetRGB(255, 0, 0)); |
| 12 | paint1.setStyle(SkPaint::kFill_Style); |
| 13 | |
| 14 | paint2.setAntiAlias(true); |
| 15 | paint2.setColor(SkColorSetRGB(0, 136, 0)); |
| 16 | paint2.setStyle(SkPaint::kStroke_Style); |
| 17 | paint2.setStrokeWidth(SkIntToScalar(3)); |
| 18 | |
| 19 | paint3.setAntiAlias(true); |
| 20 | paint3.setColor(SkColorSetRGB(136, 136, 136)); |
| 21 | |
| 22 | sk_sp<SkTextBlob> blob1 = |
| 23 | SkTextBlob::MakeFromString("Skia!", SkFont(nullptr, 64.0f, 1.0f, 0.0f)); |
| 24 | sk_sp<SkTextBlob> blob2 = |
| 25 | SkTextBlob::MakeFromString("Skia!", SkFont(nullptr, 64.0f, 1.5f, 0.0f)); |
| 26 | |
| 27 | canvas->clear(SK_ColorWHITE); |
| 28 | canvas->drawTextBlob(blob1.get(), 20.0f, 64.0f, paint1); |
| 29 | canvas->drawTextBlob(blob1.get(), 20.0f, 144.0f, paint2); |
| 30 | canvas->drawTextBlob(blob2.get(), 20.0f, 224.0f, paint3); |
| 31 | } |
| 32 | } // END FIDDLE |