Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
patharcto.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPathBuilder.h"
#include "include/utils/SkParsePath.h"

Go to the source code of this file.

Functions

 DEF_SIMPLE_GM (shallow_angle_path_arcto, canvas, 300, 300)
 
 DEF_SIMPLE_GM (arcto_skbug_9272, canvas, 150, 150)
 
static SkPath old_school_polygon (const SkPoint pts[], size_t count, bool isClosed)
 
static SkPath new_school_polygon (const SkPoint pts[], size_t count, bool isClosed)
 
 DEF_SIMPLE_GM (path_append_extend, canvas, 400, 400)
 

Function Documentation

◆ DEF_SIMPLE_GM() [1/3]

DEF_SIMPLE_GM ( arcto_skbug_9272  ,
canvas  ,
150  ,
150   
)

Definition at line 44 of file patharcto.cpp.

44 {
45 const char* str = "M66.652,65.509c0.663,-2 -0.166,-4.117 -2.117,-5.212 -0.673,-0.378 -1.36,-0.733 -2.04,-1.1a1647300864,1647300864 0,0 1,-31.287 -16.86c-5.39,-2.903 -10.78,-5.808 -16.171,-8.713 -1.626,-0.876 -3.253,-1.752 -4.88,-2.63 -1.224,-0.659 -2.4,-1.413 -3.851,-1.413 -1.135,0 -2.242,0.425 -3.049,1.197 0.08,-0.083 0.164,-0.164 0.248,-0.246l5.309,-5.13 9.37,-9.054 9.525,-9.204 5.903,-5.704C34.237,0.836 34.847,0.297 35.75,0.13c0.982,-0.182 1.862,0.127 2.703,0.592l6.23,3.452L55.76,10.31l11.951,6.62 9.02,4.996c1.74,0.963 4.168,1.854 4.205,4.21 0.011,0.678 -0.246,1.28 -0.474,1.9l-1.005,2.733 -5.665,15.42 -7.106,19.338 -0.034,-0.018z";
48
49 const char* str2 = "M10.156,30.995l4.881,2.63 16.17,8.713a1647300736,1647300736 0,0 0,31.287 16.86c0.68,0.366 1.368,0.721 2.041,1.1 2.242,1.257 3.002,3.864 1.72,6.094 -0.659,1.147 -1.296,2.31 -1.978,3.442 -1.276,2.117 -3.973,2.632 -6.102,1.536 -0.244,-0.125 -0.485,-0.259 -0.727,-0.388l-4.102,-2.19 -15.401,-8.225 -18.536,-9.9 -13.893,-7.419c-0.939,-0.501 -1.88,-0.998 -2.816,-1.504C1.2,40.935 0.087,39.5 0.004,37.75c-0.08,-1.672 1.078,-3.277 1.826,-4.702 0.248,-0.471 0.479,-0.958 0.75,-1.416 0.772,-1.306 2.224,-2.05 3.726,-2.05 1.45,0 2.627,0.754 3.85,1.414z";
52
55 canvas->translate(30, 30);
56 canvas->drawPath(path, paint);
57 canvas->drawPath(path2, paint);
58}
static SkPath path2()
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
static bool FromSVGString(const char str[], SkPath *)
const Paint & paint
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

◆ DEF_SIMPLE_GM() [2/3]

DEF_SIMPLE_GM ( path_append_extend  ,
canvas  ,
400  ,
400   
)

Definition at line 70 of file patharcto.cpp.

70 {
71 const SkPoint p0[] = {
72 { 10, 30 }, {30, 10}, {50, 30},
73 };
74 const SkPoint p1[] = {
75 { 10, 50 }, {30, 70}, {50, 50},
76 };
77
78 const SkPath path1 = SkPath::Polygon(p1, std::size(p1), false);
79
81 paint.setStroke(true);
82 paint.setStrokeWidth(9);
83 paint.setAntiAlias(true);
84
85 // addPath() sometimes checks for perspective, so we want to test that
86 const SkScalar x = 0.0001f; // tiny amount of perspective
87 const SkMatrix perspective = SkMatrix::MakeAll(1, 0, 0,
88 0, 1, 0,
89 x, 0, 1);
90
91 for (bool isClosed : {false, true}) {
92 for (auto proc : {old_school_polygon, new_school_polygon}) {
93 canvas->save();
94
95 SkPath path0 = proc(p0, std::size(p0), isClosed);
96
97 canvas->drawPath(path0, paint);
98 canvas->drawPath(path1, paint);
99
100 canvas->translate(80, 0);
101 {
102 SkPath path = path0;
104 canvas->drawPath(path, paint);
105 }
106
107 canvas->translate(80, 0);
108 {
109 SkPath path = path0;
110 path.addPath(path1, perspective, SkPath::kAppend_AddPathMode);
111 canvas->drawPath(path, paint);
112 }
113
114 canvas->translate(80, 0);
115 {
116 SkPath path = path0;
118 canvas->drawPath(path, paint);
119 }
120
121 canvas->translate(80, 0);
122 {
123 SkPath path = path0;
124 path.addPath(path1, perspective, SkPath::kExtend_AddPathMode);
125 canvas->drawPath(path, paint);
126 }
127
128 canvas->restore();
129 canvas->translate(0, 100);
130 }
131 }
132
133}
static SkPath path1()
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
Definition SkMatrix.h:179
@ kExtend_AddPathMode
Definition SkPath.h:1285
@ kAppend_AddPathMode
Definition SkPath.h:1278
static SkPath Polygon(const SkPoint pts[], int count, bool isClosed, SkPathFillType=SkPathFillType::kWinding, bool isVolatile=false)
Definition SkPath.cpp:3546
float SkScalar
Definition extension.cpp:12
double x
static SkPath new_school_polygon(const SkPoint pts[], size_t count, bool isClosed)
Definition patharcto.cpp:66
static SkPath old_school_polygon(const SkPoint pts[], size_t count, bool isClosed)
Definition patharcto.cpp:60

◆ DEF_SIMPLE_GM() [3/3]

DEF_SIMPLE_GM ( shallow_angle_path_arcto  ,
canvas  ,
300  ,
300   
)

Definition at line 20 of file patharcto.cpp.

20 {
24
25 path.moveTo(313.44189096331155f, 106.6009423589212f)
26 .arcTo({284.3113082008462f, 207.1407719157063f},
27 {255.15053777129728f, 307.6718505416374f},
28 697212.0011054524f)
29 .lineTo(255.15053777129728f, 307.6718505416374f)
30 .arcTo({340.4737465981018f, 252.6907319346971f},
31 {433.54333477716153f, 212.18116363345337f},
32 1251.2484277907251f)
33 .lineTo(433.54333477716153f, 212.18116363345337f)
34 .arcTo({350.19513833839466f, 185.89280014838369f},
35 {313.44189096331155f, 106.6009423589212f},
36 198.03116885327813f);
37
38 canvas->translate(-200, -50);
39 canvas->drawPath(path.detach(), paint);
40};

◆ new_school_polygon()

static SkPath new_school_polygon ( const SkPoint  pts[],
size_t  count,
bool  isClosed 
)
static

Definition at line 66 of file patharcto.cpp.

66 {
67 return SkPath::Polygon(pts, count, isClosed);
68}
int count

◆ old_school_polygon()

static SkPath old_school_polygon ( const SkPoint  pts[],
size_t  count,
bool  isClosed 
)
static

Definition at line 60 of file patharcto.cpp.

60 {
62 path.addPoly(pts, count, isClosed);
63 return path;
64}