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.
3 #include "tools/fiddle/examples.h"
4 REG_FIDDLE(Canvas_drawDrawable_2, 256, 100, false, 0) {
5 struct MyDrawable : public SkDrawable {
onGetBoundsMyDrawable6 SkRect onGetBounds() override { return SkRect::MakeWH(50, 100); }
onDrawMyDrawable7 void onDraw(SkCanvas* canvas) override {
8 SkPath path;
9 path.conicTo(10, 90, 50, 90, 0.9f);
10 SkPaint paint;
11 paint.setColor(SK_ColorBLUE);
12 canvas->drawRect(path.getBounds(), paint);
13 paint.setAntiAlias(true);
14 paint.setColor(SK_ColorWHITE);
15 canvas->drawPath(path, paint);
16 }
17 };
18
draw(SkCanvas * canvas)19 void draw(SkCanvas* canvas) {
20 sk_sp<SkDrawable> drawable(new MyDrawable);
21 canvas->drawDrawable(drawable.get(), 10, 10);
22 }
23 } // END FIDDLE
24