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

Public Member Functions

 PathEffectSlide ()
 
void load (SkScalar w, SkScalar h) override
 
void draw (SkCanvas *canvas) override
 
bool animate (double nanos) override
 
- 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

- Protected Attributes inherited from Slide
SkString fName
 

Detailed Description

Definition at line 71 of file PathEffectsSlide.cpp.

Constructor & Destructor Documentation

◆ PathEffectSlide()

PathEffectSlide::PathEffectSlide ( )
inline

Definition at line 77 of file PathEffectsSlide.cpp.

77: fPhase(0) { fName = "PathEffects"; }
SkString fName
Definition: Slide.h:54

Member Function Documentation

◆ animate()

bool PathEffectSlide::animate ( double  nanos)
inlineoverridevirtual

Reimplemented from Slide.

Definition at line 131 of file PathEffectsSlide.cpp.

131 {
132 fPhase = TimeUtils::Scaled(1e-9 * nanos, 40);
133 return true;
134 }
static float Scaled(float time, float speed, float period=0)
Definition: TimeUtils.h:27

◆ draw()

void PathEffectSlide::draw ( SkCanvas canvas)
inlineoverridevirtual

Implements Slide.

Definition at line 107 of file PathEffectsSlide.cpp.

107 {
108 canvas->clear(0xFFDDDDDD);
109
111
112 canvas->translate(0, 50);
113
114 paint.setColor(SK_ColorBLUE);
115 paint.setPathEffect(make_pe(2, fPhase));
116 canvas->drawPath(fPath, paint);
117
118 canvas->translate(0, 50);
119
120 paint.setARGB(0xFF, 0, 0xBB, 0);
121 paint.setPathEffect(make_pe(3, fPhase));
122 canvas->drawPath(fPath, paint);
123
124 canvas->translate(0, 50);
125
126 paint.setARGB(0xFF, 0, 0, 0);
127 paint.setPathEffect(make_warp_pe(fPhase));
128 canvas->drawPath(fPath, paint);
129 }
static sk_sp< SkPathEffect > make_pe(int flags, SkScalar phase)
static sk_sp< SkPathEffect > make_warp_pe(SkScalar phase)
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void clear(SkColor color)
Definition: SkCanvas.h:1199
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
const Paint & paint
Definition: color_source.cc:38

◆ load()

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

Reimplemented from Slide.

Definition at line 79 of file PathEffectsSlide.cpp.

79 {
80 SkRandom rand;
81 int steps = 20;
82 SkScalar dist = SkIntToScalar(400);
85
86 fPath.moveTo(x, y);
87 for (int i = 0; i < steps; i++) {
88 x += dist/steps;
89 SkScalar tmpY = y + SkIntToScalar(rand.nextS() % 25);
90 if (i == steps/2) {
91 fPath.moveTo(x, tmpY);
92 } else {
93 fPath.lineTo(x, tmpY);
94 }
95 }
96
97 {
99 oval.setLTRB(20, 30, 100, 60);
100 oval.offset(x, 0);
102 }
103
104 fClickPt.set(SkIntToScalar(200), SkIntToScalar(200));
105 }
#define SkIntToScalar(x)
Definition: SkScalar.h:57
SkPath & moveTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:688
SkPath & lineTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:728
SkPath & addRoundRect(const SkRect &rect, SkScalar rx, SkScalar ry, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1093
int32_t nextS()
Definition: SkRandom.h:50
float SkScalar
Definition: extension.cpp:12
double y
double x
SkRect oval
Definition: SkRecords.h:249
void set(float x, float y)
Definition: SkPoint_impl.h:200
void offset(float dx, float dy)
Definition: SkRect.h:1016
void setLTRB(float left, float top, float right, float bottom)
Definition: SkRect.h:865

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