Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
RotateAnimator Class Reference

Public Member Functions

void update (SkV3 axis, SkScalar angle)
 
SkM44 rotation ()
 
void start ()
 
void reset ()
 
bool isAnimating () const
 

Detailed Description

Definition at line 171 of file 3DSlide.cpp.

Member Function Documentation

◆ isAnimating()

bool RotateAnimator::isAnimating ( ) const
inline

Definition at line 231 of file 3DSlide.cpp.

231{ return fAngleSpeed != 0; }

◆ reset()

void RotateAnimator::reset ( )
inline

Definition at line 225 of file 3DSlide.cpp.

225 {
226 fAngleSpeed = 0;
227 fAngle = 0;
228 fPrevAngle = 1234567;
229 }

◆ rotation()

SkM44 RotateAnimator::rotation ( )
inline

Definition at line 197 of file 3DSlide.cpp.

197 {
198 if (fAngleSpeed > 0) {
199 double now = SkTime::GetSecs();
200 double dtime = now - fPrevNow;
201 fPrevNow = now;
202 double delta = fAngleSign * fAngleSpeed * dtime;
203 fAngle += delta;
204 fAngleSpeed -= kSlowDown * dtime;
205 if (fAngleSpeed < 0) {
206 fAngleSpeed = 0;
207 }
208 }
209 return SkM44::Rotate(fAxis, fAngle);
210
211 }
static SkM44 Rotate(SkV3 axis, SkScalar radians)
Definition: SkM44.h:239
double GetSecs()
Definition: SkTime.h:16

◆ start()

void RotateAnimator::start ( )
inline

Definition at line 213 of file 3DSlide.cpp.

213 {
214 if (fPrevNow != fNow) {
215 fAngleSpeed = (fAngle - fPrevAngle) / (fNow - fPrevNow);
216 fAngleSign = fAngleSpeed < 0 ? -1 : 1;
217 fAngleSpeed = std::min(kMaxSpeed, std::abs(fAngleSpeed));
218 } else {
219 fAngleSpeed = 0;
220 }
221 fPrevNow = SkTime::GetSecs();
222 fAngle = 0;
223 }
static float min(float r, float g, float b)
Definition: hsl.cpp:48
SIN Vec< N, float > abs(const Vec< N, float > &x)
Definition: SkVx.h:707

◆ update()

void RotateAnimator::update ( SkV3  axis,
SkScalar  angle 
)
inline

Definition at line 185 of file 3DSlide.cpp.

185 {
186 if (angle != fPrevAngle) {
187 fPrevAngle = fAngle;
188 fAngle = angle;
189
190 fPrevNow = fNow;
191 fNow = SkTime::GetSecs();
192
193 fAxis = axis;
194 }
195 }

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