blob: bdef217b172404a208fb8f44dd01e3a3cd8c7fbb [file] [log] [blame]
Hal Canary83c2f702019-03-07 14:53:03 -05001// 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 "fiddle/examples.h"
4// HASH=3a4dfcd08838866b5cfc0d82489195ba
5REG_FIDDLE(Canvas_126, 256, 100, false, 0) {
6struct 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
20void draw(SkCanvas* canvas) {
21 sk_sp<SkDrawable> drawable(new MyDrawable);
22 SkMatrix matrix;
23 matrix.setTranslate(10, 10);
24 canvas->drawDrawable(drawable.get(), &matrix);
25}
26} // END FIDDLE