| 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 { |
| 6 |
SkRect onGetBounds() override { return SkRect::MakeWH(50, 100); } |
| 7 |
void onDraw(SkCanvas* canvas) override { |
| 8 |
SkPath path = SkPathBuilder() |
| 9 |
.conicTo(10, 90, 50, 90, 0.9f) |
| 10 |
.detach(); |
| 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 |