Flutter Engine
The Flutter Engine
Functions
Canvas_drawDrawable.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (Canvas_drawDrawable, 256, 100, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Canvas_drawDrawable  ,
256  ,
100  ,
false  ,
 
)

Definition at line 4 of file Canvas_drawDrawable.cpp.

4 {
5struct MyDrawable : public SkDrawable {
6 SkRect onGetBounds() override { return SkRect::MakeWH(50, 100); }
7 void onDraw(SkCanvas* canvas) override {
9 path.conicTo(10, 90, 50, 90, 0.9f);
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
19void draw(SkCanvas* canvas) {
20 sk_sp<SkDrawable> drawable(new MyDrawable);
22 matrix.setTranslate(10, 10);
23 canvas->drawDrawable(drawable.get(), &matrix);
24}
25} // END FIDDLE
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawDrawable(SkDrawable *drawable, const SkMatrix *matrix=nullptr)
Definition: SkCanvas.cpp:2574
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
Definition: SkPath.h:59
const Paint & paint
Definition: color_source.cc:38
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
void onDraw(SkCanvas *canvas) override
Definition: drawable.cpp:21
SkRect onGetBounds() override
Definition: drawable.cpp:19
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609