Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
PathSlide Class Reference
Inheritance diagram for PathSlide:
ClickHandlerSlide Slide SkRefCnt SkRefCntBase

Public Member Functions

 PathSlide ()
 
void load (SkScalar w, SkScalar h) override
 
void drawPath (SkCanvas *canvas, const SkPath &path, SkPaint::Join j)
 
void draw (SkCanvas *canvas) override
 
bool animate (double nanos) override
 
ClickonFindClickHandler (SkScalar x, SkScalar y, skui::ModifierKey modi) override
 
bool onClick (ClickHandlerSlide::Click *) override
 
- Public Member Functions inherited from ClickHandlerSlide
bool onMouse (SkScalar x, SkScalar y, skui::InputState clickState, skui::ModifierKey modifierKeys) final
 
- Public Member Functions inherited from Slide
virtual SkISize getDimensions () const
 
virtual void gpuTeardown ()
 
virtual void draw (SkCanvas *canvas)=0
 
virtual bool animate (double nanos)
 
virtual void load (SkScalar winWidth, SkScalar winHeight)
 
virtual void resize (SkScalar winWidth, SkScalar winHeight)
 
virtual void unload ()
 
virtual bool onChar (SkUnichar c)
 
virtual bool onMouse (SkScalar x, SkScalar y, skui::InputState state, skui::ModifierKey modifiers)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
const SkStringgetName ()
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Additional Inherited Members

virtual ClickonFindClickHandler (SkScalar x, SkScalar y, skui::ModifierKey modi)=0
 
virtual bool onClick (Click *)=0
 
- Protected Attributes inherited from Slide
SkString fName
 

Detailed Description

Definition at line 76 of file PathSlide.cpp.

Constructor & Destructor Documentation

◆ PathSlide()

PathSlide::PathSlide ( )
inline

Definition at line 83 of file PathSlide.cpp.

83 {
84 fPrevSecs = 0;
85 fName = "Paths";
86 }
SkString fName
Definition: Slide.h:54

Member Function Documentation

◆ animate()

bool PathSlide::animate ( double  nanos)
inlineoverridevirtual

Reimplemented from Slide.

Definition at line 172 of file PathSlide.cpp.

172 {
173 SkScalar currSecs = TimeUtils::Scaled(1e-9 * nanos, 100);
174 SkScalar delta = currSecs - fPrevSecs;
175 fPrevSecs = currSecs;
176
177 fStroke += fDStroke * delta;
178 if (fStroke > fMaxStroke || fStroke < fMinStroke) {
179 fDStroke = -fDStroke;
180 }
181 return true;
182 }
float SkScalar
Definition: extension.cpp:12
static float Scaled(float time, float speed, float period=0)
Definition: TimeUtils.h:27

◆ draw()

void PathSlide::draw ( SkCanvas canvas)
inlineoverridevirtual

Implements Slide.

Definition at line 149 of file PathSlide.cpp.

149 {
150 canvas->clear(0xFFDDDDDD);
151
152 canvas->translate(50, 50);
153
154 static const SkPaint::Join gJoins[] = {
158 };
159
160 for (size_t i = 0; i < std::size(gJoins); i++) {
161 canvas->save();
162 for (size_t j = 0; j < std::size(fPath); j++) {
163 this->drawPath(canvas, fPath[j], gJoins[i]);
164 canvas->translate(200, 0);
165 }
166 canvas->restore();
167
168 canvas->translate(0, 200);
169 }
170 }
void drawPath(SkCanvas *canvas, const SkPath &path, SkPaint::Join j)
Definition: PathSlide.cpp:126
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void clear(SkColor color)
Definition: SkCanvas.h:1199
int save()
Definition: SkCanvas.cpp:447
@ kRound_Join
adds circle
Definition: SkPaint.h:360
@ kMiter_Join
extends to miter limit
Definition: SkPaint.h:359
@ kBevel_Join
connects outside edges
Definition: SkPaint.h:361
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ drawPath()

void PathSlide::drawPath ( SkCanvas canvas,
const SkPath path,
SkPaint::Join  j 
)
inline

Definition at line 126 of file PathSlide.cpp.

126 {
128
129 paint.setAntiAlias(true);
131 paint.setStrokeJoin(j);
132 paint.setStrokeWidth(fStroke);
133
134 if (fShowHairline) {
135 SkPath fill;
136
138 paint.setStrokeWidth(0);
139 canvas->drawPath(fill, paint);
140 } else {
141 canvas->drawPath(path, paint);
142 }
143
144 paint.setColor(SK_ColorRED);
145 paint.setStrokeWidth(0);
146 canvas->drawPath(path, paint);
147 }
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
Definition: SkPath.h:59
const Paint & paint
Definition: color_source.cc:38
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
SK_API bool FillPathWithPaint(const SkPath &src, const SkPaint &paint, SkPath *dst, const SkRect *cullRect, SkScalar resScale=1)
Definition: SkPathUtils.cpp:23

◆ load()

void PathSlide::load ( SkScalar  w,
SkScalar  h 
)
inlineoverridevirtual

Reimplemented from Slide.

Definition at line 88 of file PathSlide.cpp.

88 {
89 test_cubic();
91
92 fShowHairline = false;
93
94 fDStroke = 1;
95 fStroke = 10;
96 fMinStroke = 10;
97 fMaxStroke = 180;
98
99 const SkScalar V = 85;
100
101 fPath[0].moveTo(40, 70);
102 fPath[0].lineTo(70, 70 + SK_ScalarHalf);
103 fPath[0].lineTo(110, 70);
104
105 fPath[1].moveTo(40, 70);
106 fPath[1].lineTo(70, 70 - SK_ScalarHalf);
107 fPath[1].lineTo(110, 70);
108
109 fPath[2].moveTo(V, V);
110 fPath[2].lineTo(50, V);
111 fPath[2].lineTo(50, 50);
112
113 fPath[3].moveTo(50, 50);
114 fPath[3].lineTo(50, V);
115 fPath[3].lineTo(V, V);
116
117 fPath[4].moveTo(50, 50);
118 fPath[4].lineTo(50, V);
119 fPath[4].lineTo(52, 50);
120
121 fPath[5].moveTo(52, 50);
122 fPath[5].lineTo(50, V);
123 fPath[5].lineTo(50, 50);
124 }
static void test_cubic2()
Definition: PathSlide.cpp:52
static void test_cubic()
Definition: PathSlide.cpp:32
#define SK_ScalarHalf
Definition: SkScalar.h:19
SkPath & moveTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:688
SkPath & lineTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:728
T __attribute__((ext_vector_type(N))) V

◆ onClick()

bool PathSlide::onClick ( ClickHandlerSlide::Click )
inlineoverridevirtual

Override to track clicks. Return true as long as you want to track the pen/mouse.

Implements ClickHandlerSlide.

Definition at line 189 of file PathSlide.cpp.

189{ return false; }

◆ onFindClickHandler()

Click * PathSlide::onFindClickHandler ( SkScalar  x,
SkScalar  y,
skui::ModifierKey  modi 
)
inlineoverridevirtual

Return a Click object to handle the click. onClick will be called repeatedly with the latest mouse state tracked on the Click object until it returns false.

Implements ClickHandlerSlide.

Definition at line 184 of file PathSlide.cpp.

184 {
185 fShowHairline = !fShowHairline;
186 return nullptr;
187 }

The documentation for this class was generated from the following file: