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

Public Member Functions

 FatStrokeSlide ()
 
bool onChar (SkUnichar uni) override
 
void draw (SkCanvas *canvas) 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
 

Protected Member Functions

ClickonFindClickHandler (SkScalar x, SkScalar y, skui::ModifierKey modi) override
 
bool onClick (ClickHandlerSlide::Click *) override
 
virtual ClickonFindClickHandler (SkScalar x, SkScalar y, skui::ModifierKey modi)=0
 
virtual bool onClick (Click *)=0
 

Additional Inherited Members

- Protected Attributes inherited from Slide
SkString fName
 

Detailed Description

Definition at line 292 of file PathSlide.cpp.

Constructor & Destructor Documentation

◆ FatStrokeSlide()

FatStrokeSlide::FatStrokeSlide ( )
inline

Definition at line 304 of file PathSlide.cpp.

305 : fClosed(false)
306 , fShowStroke(true)
307 , fShowHidden(false)
308 , fShowSkeleton(true)
309 , fJoinType(0)
310 , fCapType(0) {
311 SkRandom rand;
312 for (int i = 0; i < N; ++i) {
313 fPts[i].fX = 20 + rand.nextUScalar1() * 640;
314 fPts[i].fY = 20 + rand.nextUScalar1() * 480;
315 }
316
317 fPtsPaint.setAntiAlias(true);
318 fPtsPaint.setStrokeWidth(10);
320
321 fHiddenPaint.setAntiAlias(true);
322 fHiddenPaint.setStyle(SkPaint::kStroke_Style);
323 fHiddenPaint.setColor(0xFF0000FF);
324
325 fStrokePaint.setAntiAlias(true);
326 fStrokePaint.setStyle(SkPaint::kStroke_Style);
327 fStrokePaint.setStrokeWidth(50);
328 fStrokePaint.setColor(0x8000FF00);
329
330 fSkeletonPaint.setAntiAlias(true);
331 fSkeletonPaint.setStyle(SkPaint::kStroke_Style);
332 fSkeletonPaint.setColor(SK_ColorRED);
333
334 fName = "FatStroke";
335 }
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
@ kRound_Cap
adds circle
Definition: SkPaint.h:335
void setStyle(Style style)
Definition: SkPaint.cpp:105
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
void setStrokeCap(Cap cap)
Definition: SkPaint.cpp:179
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
SkScalar nextUScalar1()
Definition: SkRandom.h:101
SkString fName
Definition: Slide.h:54
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165

Member Function Documentation

◆ draw()

void FatStrokeSlide::draw ( SkCanvas canvas)
inlineoverridevirtual

Implements Slide.

Definition at line 352 of file PathSlide.cpp.

352 {
353 canvas->drawColor(0xFFEEEEEE);
354
355 SkPath path;
356 this->makePath(&path);
357
358 fStrokePaint.setStrokeWidth(fWidth);
359 fStrokePaint.setStrokeJoin((SkPaint::Join)fJoinType);
360 fStrokePaint.setStrokeCap((SkPaint::Cap)fCapType);
361
362 if (fShowStroke) {
363 canvas->drawPath(path, fStrokePaint);
364 }
365 if (fShowHidden) {
366 SkPath hidden;
367 skpathutils::FillPathWithPaint(path, fStrokePaint, &hidden);
368 canvas->drawPath(hidden, fHiddenPaint);
369 }
370 if (fShowSkeleton) {
371 canvas->drawPath(path, fSkeletonPaint);
372 }
373 canvas->drawPoints(SkCanvas::kPoints_PointMode, N, fPts, fPtsPaint);
374 }
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
Definition: SkCanvas.cpp:1710
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
@ kPoints_PointMode
draw each point separately
Definition: SkCanvas.h:1241
void setStrokeJoin(Join join)
Definition: SkPaint.cpp:189
Definition: SkPath.h:59
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

◆ onChar()

bool FatStrokeSlide::onChar ( SkUnichar  uni)
inlineoverridevirtual

Reimplemented from Slide.

Definition at line 336 of file PathSlide.cpp.

336 {
337 switch (uni) {
338 case '1': this->toggle(fShowSkeleton); return true;
339 case '2': this->toggle(fShowStroke); return true;
340 case '3': this->toggle(fShowHidden); return true;
341 case '4': this->toggle3(fJoinType); return true;
342 case '5': this->toggle3(fCapType); return true;
343 case '6': this->toggle(fClosed); return true;
344 case 'c': this->toggle(fAsCurves); return true;
345 case '-': fWidth -= 5; return true;
346 case '=': fWidth += 5; return true;
347 default: break;
348 }
349 return false;
350 }

◆ onClick()

bool FatStrokeSlide::onClick ( ClickHandlerSlide::Click )
inlineoverrideprotectedvirtual

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

Implements ClickHandlerSlide.

Definition at line 391 of file PathSlide.cpp.

391{ return false; }

◆ onFindClickHandler()

Click * FatStrokeSlide::onFindClickHandler ( SkScalar  x,
SkScalar  y,
skui::ModifierKey  modi 
)
inlineoverrideprotectedvirtual

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 377 of file PathSlide.cpp.

377 {
378 const SkScalar tol = 4;
379 const SkRect r = SkRect::MakeXYWH(x - tol, y - tol, tol * 2, tol * 2);
380 for (int i = 0; i < N; ++i) {
381 if (r.intersects(SkRect::MakeXYWH(fPts[i].fX, fPts[i].fY, 1, 1))) {
382 return new Click([this, i](Click* c) {
383 fPts[i] = c->fCurr;
384 return true;
385 });
386 }
387 }
388 return nullptr;
389 }
float SkScalar
Definition: extension.cpp:12
double y
double x
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659
bool intersects(const SkRect &r) const
Definition: SkRect.h:1121

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