Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 1 | // Copyright 2019 Google LLC. |
| 2 | // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 3 | #include "tools/fiddle/examples.h" |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 4 | // HASH=1bdc07ad3b154c89b771722c2fcaee3f |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 5 | REG_FIDDLE(Canvas_drawDrawable_2, 256, 100, false, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 6 | struct MyDrawable : public SkDrawable { |
| 7 | SkRect onGetBounds() override { return SkRect::MakeWH(50, 100); } |
| 8 | void onDraw(SkCanvas* canvas) override { |
| 9 | SkPath path; |
| 10 | path.conicTo(10, 90, 50, 90, 0.9f); |
| 11 | SkPaint paint; |
| 12 | paint.setColor(SK_ColorBLUE); |
| 13 | canvas->drawRect(path.getBounds(), paint); |
| 14 | paint.setAntiAlias(true); |
| 15 | paint.setColor(SK_ColorWHITE); |
| 16 | canvas->drawPath(path, paint); |
| 17 | } |
| 18 | }; |
| 19 | |
| 20 | void draw(SkCanvas* canvas) { |
| 21 | sk_sp<SkDrawable> drawable(new MyDrawable); |
| 22 | canvas->drawDrawable(drawable.get(), 10, 10); |
| 23 | } |
| 24 | } // END FIDDLE |