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

Public Member Functions

 FlutterAnimateView ()
 
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 23 of file FlutterAnimateSlide.cpp.

Constructor & Destructor Documentation

◆ FlutterAnimateView()

FlutterAnimateView::FlutterAnimateView ( )
inline

Definition at line 25 of file FlutterAnimateSlide.cpp.

25: fCurrTime(0), fResetTime(0) { fName = "FlutterAnimate"; }
SkString fName
Definition: Slide.h:54

Member Function Documentation

◆ animate()

bool FlutterAnimateView::animate ( double  nanos)
inlineoverridevirtual

Reimplemented from Slide.

Definition at line 54 of file FlutterAnimateSlide.cpp.

54 {
55 fCurrTime = 1e-9 * nanos - fResetTime;
56 if (fCurrTime > kDuration) {
57 this->initChars();
58 fResetTime = 1e-9 * nanos;
59 fCurrTime = 0;
60 }
61
62 return true;
63 }

◆ draw()

void FlutterAnimateView::draw ( SkCanvas canvas)
inlineoverridevirtual

Implements Slide.

Definition at line 33 of file FlutterAnimateSlide.cpp.

33 {
34 SkFont font(fTypeface, 50);
36
37 // rough center of each glyph
38 static constexpr auto kMidX = 35;
39 static constexpr auto kMidY = 50;
40
41 canvas->clear(SK_ColorWHITE);
42 for (int i = 0; i < kNumChars; ++i) {
43 canvas->save();
44 double rot = SkScalarInterp(fChars[i].fStartRotation, fChars[i].fEndRotation,
45 fCurrTime/kDuration);
46 canvas->translate(fChars[i].fPosition.fX + kMidX, fChars[i].fPosition.fY - kMidY);
47 canvas->rotate(SkRadiansToDegrees(rot));
48 canvas->translate(-35,+50);
49 canvas->drawString(fChars[i].fChar, 0, 0, font, paint);
50 canvas->restore();
51 }
52 }
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SkRadiansToDegrees(radians)
Definition: SkScalar.h:78
static SkScalar SkScalarInterp(SkScalar A, SkScalar B, SkScalar t)
Definition: SkScalar.h:131
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void clear(SkColor color)
Definition: SkCanvas.h:1199
void rotate(SkScalar degrees)
Definition: SkCanvas.cpp:1300
int save()
Definition: SkCanvas.cpp:447
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
Definition: SkFont.h:35
const Paint & paint
Definition: color_source.cc:38
font
Font Metadata and Metrics.

◆ load()

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

Reimplemented from Slide.

Definition at line 28 of file FlutterAnimateSlide.cpp.

28 {
29 fTypeface = ToolUtils::TestFontMgr()->makeFromFile("/skimages/samplefont.ttf");
30 initChars();
31 }
sk_sp< SkTypeface > makeFromFile(const char path[], int ttcIndex=0) const
Definition: SkFontMgr.cpp:143
sk_sp< SkFontMgr > TestFontMgr()

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