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

Public Member Functions

 MegaStrokeSlide ()
 
bool onChar (SkUnichar uni) override
 
void draw (SkCanvas *canvas) override
 
void resize (SkScalar w, SkScalar h) override
 
bool animate (double) 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 13 of file MegaStrokeSlide.cpp.

Constructor & Destructor Documentation

◆ MegaStrokeSlide()

MegaStrokeSlide::MegaStrokeSlide ( )
inline

Definition at line 15 of file MegaStrokeSlide.cpp.

15 {
16 fClip.setLTRB(0, 0, 950, 600);
17 fAngle = 0;
18 fPlusMinus = 0;
19 SkRandom rand;
20 fMegaPath.reset();
21 for (int index = 0; index < 921; ++index) {
22 for (int segs = 0; segs < 40; ++segs) {
23 fMegaPath.lineTo(SkIntToScalar(index), SkIntToScalar(rand.nextRangeU(500, 600)));
24 }
25 }
26 fName = "MegaStroke";
27 }
#define SkIntToScalar(x)
Definition: SkScalar.h:57
SkPath & lineTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:728
SkPath & reset()
Definition: SkPath.cpp:370
uint32_t nextRangeU(uint32_t min, uint32_t max)
Definition: SkRandom.h:80
SkString fName
Definition: Slide.h:54
void setLTRB(float left, float top, float right, float bottom)
Definition: SkRect.h:865

Member Function Documentation

◆ animate()

bool MegaStrokeSlide::animate ( double  )
inlineoverridevirtual

Reimplemented from Slide.

Definition at line 65 of file MegaStrokeSlide.cpp.

65{ return true; }

◆ draw()

void MegaStrokeSlide::draw ( SkCanvas canvas)
inlineoverridevirtual

Implements Slide.

Definition at line 34 of file MegaStrokeSlide.cpp.

34 {
36 paint.setAntiAlias(true);
37 paint.setARGB(255,255,153,0);
39 paint.setStrokeWidth(1);
40
41 canvas->save();
42 canvas->clipRect(fClip);
43 canvas->clear(SK_ColorWHITE);
44 canvas->drawPath(fMegaPath, paint);
45 canvas->restore();
46
47 SkPaint divSimPaint;
48 divSimPaint.setColor(SK_ColorBLUE);
49 SkScalar x = SkScalarSin(fAngle * SK_ScalarPI / 180) * 200 + 250;
50 SkScalar y = SkScalarCos(fAngle * SK_ScalarPI / 180) * 200 + 250;
51
52 if ((fPlusMinus ^= 1)) {
53 fAngle += 5;
54 } else {
55 fAngle -= 5;
56 }
57 SkRect divSim = SkRect::MakeXYWH(x, y, 100, 100);
58 divSim.outset(30, 30);
59 canvas->drawRect(divSim, divSimPaint);
60 fClip = divSim;
61 }
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SkScalarSin(radians)
Definition: SkScalar.h:45
#define SkScalarCos(radians)
Definition: SkScalar.h:46
#define SK_ScalarPI
Definition: SkScalar.h:21
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
void clear(SkColor color)
Definition: SkCanvas.h:1199
int save()
Definition: SkCanvas.cpp:447
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
void setColor(SkColor color)
Definition: SkPaint.cpp:119
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
double y
double x
void outset(float dx, float dy)
Definition: SkRect.h:1077
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ onChar()

bool MegaStrokeSlide::onChar ( SkUnichar  uni)
inlineoverridevirtual

Reimplemented from Slide.

Definition at line 29 of file MegaStrokeSlide.cpp.

29 {
30 fClip.setLTRB(0, 0, 950, 600);
31 return true;
32 }

◆ resize()

void MegaStrokeSlide::resize ( SkScalar  w,
SkScalar  h 
)
inlineoverridevirtual

Reimplemented from Slide.

Definition at line 63 of file MegaStrokeSlide.cpp.

63{ fClip.setWH(950, 600); }
void setWH(float width, float height)
Definition: SkRect.h:944

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