Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
skottie::internal::TransformAdapter2D Class Referencefinal

#include <Transform.h>

Inheritance diagram for skottie::internal::TransformAdapter2D:
skottie::internal::DiscardableAdapterBase< TransformAdapter2D, sksg::Matrix< SkMatrix > > skottie::internal::AnimatablePropertyContainer skottie::internal::Animator SkRefCnt SkRefCntBase

Public Member Functions

 TransformAdapter2D (const AnimationBuilder &, const skjson::ObjectValue *janchor_point, const skjson::ObjectValue *jposition, const skjson::ObjectValue *jscale, const skjson::ObjectValue *jrotation, const skjson::ObjectValue *jskew, const skjson::ObjectValue *jskew_axis, bool auto_orient=false)
 
 ~TransformAdapter2D () override
 
SkPoint getAnchorPoint () const
 
void setAnchorPoint (const SkPoint &)
 
SkPoint getPosition () const
 
void setPosition (const SkPoint &)
 
SkVector getScale () const
 
void setScale (const SkVector &)
 
float getRotation () const
 
void setRotation (float r)
 
float getSkew () const
 
void setSkew (float sk)
 
float getSkewAxis () const
 
void setSkewAxis (float sa)
 
SkMatrix totalMatrix () const
 
- Public Member Functions inherited from skottie::internal::DiscardableAdapterBase< TransformAdapter2D, sksg::Matrix< SkMatrix > >
const sk_sp< sksg::Matrix< SkMatrix > > & node () const
 
- Public Member Functions inherited from skottie::internal::AnimatablePropertyContainer
template<typename T >
bool bind (const AnimationBuilder &, const skjson::ObjectValue *, T *)
 
template<typename T >
bool bind (const AnimationBuilder &abuilder, const skjson::ObjectValue *jobject, T &v)
 
bool bindAutoOrientable (const AnimationBuilder &abuilder, const skjson::ObjectValue *jobject, SkV2 *v, float *orientation)
 
bool isStatic () const
 
template<>
bool bind (const AnimationBuilder &abuilder, const skjson::ObjectValue *jprop, ScalarValue *v)
 
template<>
bool bind (const AnimationBuilder &abuilder, const skjson::ObjectValue *jprop, ShapeValue *v)
 
template<>
bool bind (const AnimationBuilder &abuilder, const skjson::ObjectValue *jprop, TextValue *v)
 
template<>
bool bind (const AnimationBuilder &abuilder, const skjson::ObjectValue *jprop, Vec2Value *v)
 
template<>
bool bind (const AnimationBuilder &abuilder, const skjson::ObjectValue *jprop, VectorValue *v)
 
template<>
bool bind (const AnimationBuilder &abuilder, const skjson::ObjectValue *jprop, ColorValue *v)
 
- Public Member Functions inherited from skottie::internal::Animator
StateChanged seek (float t)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Private Member Functions

void onSync () override
 

Additional Inherited Members

- Public Types inherited from skottie::internal::Animator
using StateChanged = bool
 
- Static Public Member Functions inherited from skottie::internal::DiscardableAdapterBase< TransformAdapter2D, sksg::Matrix< SkMatrix > >
static sk_sp< TransformAdapter2DMake (Args &&... args)
 
- Protected Member Functions inherited from skottie::internal::DiscardableAdapterBase< TransformAdapter2D, sksg::Matrix< SkMatrix > >
 DiscardableAdapterBase ()
 
 DiscardableAdapterBase (sk_sp< sksg::Matrix< SkMatrix > > node)
 
- Protected Member Functions inherited from skottie::internal::AnimatablePropertyContainer
void shrink_to_fit ()
 
void attachDiscardableAdapter (sk_sp< AnimatablePropertyContainer >)
 
- Protected Member Functions inherited from skottie::internal::Animator
 Animator ()=default
 

Detailed Description

Definition at line 29 of file Transform.h.

Constructor & Destructor Documentation

◆ TransformAdapter2D()

skottie::internal::TransformAdapter2D::TransformAdapter2D ( const AnimationBuilder abuilder,
const skjson::ObjectValue janchor_point,
const skjson::ObjectValue jposition,
const skjson::ObjectValue jscale,
const skjson::ObjectValue jrotation,
const skjson::ObjectValue jskew,
const skjson::ObjectValue jskew_axis,
bool  auto_orient = false 
)

Definition at line 23 of file Transform.cpp.

32
33 this->bind(abuilder, janchor_point, fAnchorPoint);
34 this->bind(abuilder, jscale , fScale);
35 this->bind(abuilder, jrotation , fRotation);
36 this->bind(abuilder, jskew , fSkew);
37 this->bind(abuilder, jskew_axis , fSkewAxis);
38
39 this->bindAutoOrientable(abuilder, jposition, &fPosition, auto_orient ? &fOrientation
40 : nullptr);
41}
static const SkMatrix & I()
bool bindAutoOrientable(const AnimationBuilder &abuilder, const skjson::ObjectValue *jobject, SkV2 *v, float *orientation)
bool bind(const AnimationBuilder &, const skjson::ObjectValue *, T *)

◆ ~TransformAdapter2D()

skottie::internal::TransformAdapter2D::~TransformAdapter2D ( )
override

Definition at line 43 of file Transform.cpp.

43{}

Member Function Documentation

◆ getAnchorPoint()

SkPoint skottie::internal::TransformAdapter2D::getAnchorPoint ( ) const

Definition at line 72 of file Transform.cpp.

72 {
73 return { fAnchorPoint.x, fAnchorPoint.y };
74}
float x
Definition SkM44.h:20
float y
Definition SkM44.h:20

◆ getPosition()

SkPoint skottie::internal::TransformAdapter2D::getPosition ( ) const

Definition at line 81 of file Transform.cpp.

81 {
82 return { fPosition.x, fPosition.y };
83}

◆ getRotation()

float skottie::internal::TransformAdapter2D::getRotation ( ) const
inline

Definition at line 53 of file Transform.h.

53{ return fRotation; }

◆ getScale()

SkVector skottie::internal::TransformAdapter2D::getScale ( ) const

Definition at line 90 of file Transform.cpp.

90 {
91 return { fScale.x, fScale.y };
92}

◆ getSkew()

float skottie::internal::TransformAdapter2D::getSkew ( ) const
inline

Definition at line 56 of file Transform.h.

56{ return fSkew; }

◆ getSkewAxis()

float skottie::internal::TransformAdapter2D::getSkewAxis ( ) const
inline

Definition at line 59 of file Transform.h.

59{ return fSkewAxis; }

◆ onSync()

void skottie::internal::TransformAdapter2D::onSync ( )
overrideprivatevirtual

Implements skottie::internal::AnimatablePropertyContainer.

Definition at line 45 of file Transform.cpp.

45 {
46 this->node()->setMatrix(this->totalMatrix());
47}

◆ setAnchorPoint()

void skottie::internal::TransformAdapter2D::setAnchorPoint ( const SkPoint ap)

Definition at line 76 of file Transform.cpp.

76 {
77 fAnchorPoint = { ap.x(), ap.y() };
78 this->onSync();
79}
constexpr float y() const
constexpr float x() const

◆ setPosition()

void skottie::internal::TransformAdapter2D::setPosition ( const SkPoint p)

Definition at line 85 of file Transform.cpp.

85 {
86 fPosition = { p.x(), p.y() };
87 this->onSync();
88}

◆ setRotation()

void skottie::internal::TransformAdapter2D::setRotation ( float  r)

Definition at line 99 of file Transform.cpp.

99 {
100 fRotation = r;
101 this->onSync();
102}

◆ setScale()

void skottie::internal::TransformAdapter2D::setScale ( const SkVector s)

Definition at line 94 of file Transform.cpp.

94 {
95 fScale = { s.x(), s.y() };
96 this->onSync();
97}
struct MyStruct s

◆ setSkew()

void skottie::internal::TransformAdapter2D::setSkew ( float  sk)

Definition at line 104 of file Transform.cpp.

104 {
105 fSkew = sk;
106 this->onSync();
107}

◆ setSkewAxis()

void skottie::internal::TransformAdapter2D::setSkewAxis ( float  sa)

Definition at line 109 of file Transform.cpp.

109 {
110 fSkewAxis = sa;
111 this->onSync();
112}

◆ totalMatrix()

SkMatrix skottie::internal::TransformAdapter2D::totalMatrix ( ) const

Definition at line 49 of file Transform.cpp.

49 {
50 auto skew_matrix = [](float sk, float sa) {
51 if (!sk) return SkMatrix::I();
52
53 // AE control limit.
54 static constexpr float kMaxSkewAngle = 85;
55 sk = -SkDegreesToRadians(SkTPin(sk, -kMaxSkewAngle, kMaxSkewAngle));
56 sa = SkDegreesToRadians(sa);
57
58 // Similar to CSS/SVG SkewX [1] with an explicit rotation.
59 // [1] https://www.w3.org/TR/css-transforms-1/#SkewXDefined
60 return SkMatrix::RotateRad(sa)
61 * SkMatrix::Skew(std::tan(sk), 0)
63 };
64
65 return SkMatrix::Translate(fPosition.x, fPosition.y)
66 * SkMatrix::RotateDeg(fRotation + fOrientation)
67 * skew_matrix (fSkew, fSkewAxis)
68 * SkMatrix::Scale (fScale.x / 100, fScale.y / 100) // 100% based
69 * SkMatrix::Translate(-fAnchorPoint.x, -fAnchorPoint.y);
70}
#define SkDegreesToRadians(degrees)
Definition SkScalar.h:77
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
Definition SkTPin.h:19
static SkMatrix Scale(SkScalar sx, SkScalar sy)
Definition SkMatrix.h:75
static SkMatrix RotateDeg(SkScalar deg)
Definition SkMatrix.h:104
static SkMatrix RotateRad(SkScalar rad)
Definition SkMatrix.h:114
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition SkMatrix.h:91
static SkMatrix Skew(SkScalar kx, SkScalar ky)
Definition SkMatrix.h:124

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