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

Go to the source code of this file.

Functions

 REG_FIDDLE (example3ps, 320, 256, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( example3ps  ,
320  ,
256  ,
false  ,
 
)

Definition at line 4 of file example3ps.cpp.

4 {
5static SkMatrix setpsmatrix(float sx, float kx, float ky, float sy, float tx, float ty, int h) {
7
8 m.setAll(sx, -kx, -tx * sx - (ty - h) * kx, -ky, sy, (ty - h) * sy + tx * ky, 0, 0, 1);
9 return m;
10}
11
12void draw(SkCanvas* canvas) {
13 canvas->save();
14 canvas->scale(15, -15);
15 canvas->translate(0, -28);
17 path.moveTo(2, 2);
18 path.lineTo(3, 3);
19 path.lineTo(3, 4);
20 path.lineTo(2, 4);
21 path.lineTo(1, 5);
22 path.close();
23 SkPaint p;
24 p.setAntiAlias(true);
25 p.setStrokeWidth(0.1f);
26
27 canvas->save();
28 canvas->translate(0, 18);
29 p.setColor(SK_ColorGRAY);
30 canvas->drawPath(path, p);
31 canvas->restore();
32
33 p.setStyle(SkPaint::kStroke_Style);
34 canvas->save();
35 canvas->translate(8, 19);
36 canvas->rotate(90);
37 p.setColor(SK_ColorRED);
38 canvas->drawPath(path, p);
39 canvas->restore();
40
41 canvas->save();
42 canvas->translate(5, 23);
43 canvas->rotate(-90);
44 p.setColor(SK_ColorBLUE);
45 canvas->drawPath(path, p);
46 canvas->restore();
47
48 canvas->save();
49 canvas->translate(14, 18);
50 canvas->scale(-1, 1);
51 p.setColor(0xFF007F00);
52 canvas->drawPath(path, p);
53 canvas->restore();
54 canvas->restore();
55
56 canvas->scale(15, 15);
57 canvas->translate(0, 24);
58
59 SkMatrix m;
60 unsigned char d[] = {0x00, 0x00, 0x00, 0x00, 0xff, 0xff};
61 sk_sp<SkData> data = SkData::MakeWithoutCopy((unsigned char*)d, sizeof(d));
65
66 canvas->save();
67 m = setpsmatrix(1, 0, 0, 1, -1, -24, 2);
68 // m.setAll(1, 0, -1, 0, 1, -24, 0, 0, 1);
69 canvas->concat(m);
70 canvas->drawImage(image, 0, 0);
71 canvas->restore();
72
73 canvas->save();
74 m = setpsmatrix(0, 1, 1, 0, -24, -5, 2);
75 // m.setAll(0, -1, 5, -1, 0, -22, 0, 0, 1);
76 canvas->concat(m);
77 canvas->drawImage(image, 0, 0);
78 canvas->restore();
79
80 canvas->save();
81 m = setpsmatrix(0, 1, -1, 0, 27, -8, 2);
82 // m.setAll(0, -1, 8, 1, 0, -25, 0, 0, 1);
83 canvas->concat(m);
84 canvas->drawImage(image, 0, 0);
85 canvas->restore();
86
87 canvas->save();
88 m = setpsmatrix(0, -1, -1, 0, -24, 13, 2);
89 // m.setAll(0, 1, 9, -1, 0, -22, 0, 0, 1);
90 canvas->concat(m);
91 canvas->drawImage(image, 0, 0);
92 canvas->restore();
93
94 canvas->save();
95 m = setpsmatrix(-1, 0, 0, -1, 17, 26, 2);
96 // m.setAll(-1, 0, 15, 0, -1, -22, 0, 0, 1);
97 canvas->concat(m);
98 canvas->drawImage(image, 0, 0);
99 canvas->restore();
100
101 canvas->save();
102 m = setpsmatrix(-1, 0, 0, 1, 21, -24, 2);
103 // m.setAll(-1, 0, 19, 0, 1, -24, 0, 0, 1);
104 canvas->concat(m);
105 canvas->drawImage(image, 0, 0);
106 canvas->restore();
107}
108} // END FIDDLE
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition: SkColorType.h:35
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void rotate(SkScalar degrees)
Definition: SkCanvas.cpp:1300
int save()
Definition: SkCanvas.cpp:447
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static sk_sp< SkData > MakeWithoutCopy(const void *data, size_t length)
Definition: SkData.h:116
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
Definition: SkPath.h:59
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19
SK_API sk_sp< SkImage > RasterFromData(const SkImageInfo &info, sk_sp< SkData > pixels, size_t rowBytes)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
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
SkScalar h
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63