AnimationTextureMapper
A TextureMapper with animation capabilities. Note that the angles of the TextureMapper is normalized to lie in the range [0; 2PI[ at the beginning at the animation. The end angles should be relative to this and are limited to values in the range [-32.7; 32.7].
Inherits from: TextureMapper, Image, Widget, Drawable
Protected Classes
struct | AnimationSetting |
Information about how a specific animation parameter should be animated. | |
Public Types
enum | AnimationParameter { X_ROTATION, Y_ROTATION, Z_ROTATION, SCALE } |
Values that represent different animation parameter. | |
Public Functions
AnimationTextureMapper() | |
virtual void | cancelAnimationTextureMapperAnimation() |
Cancel move animation. | |
virtual uint16_t | getAnimationStep() |
Gets the current animation step measured in ticks since the call to startAnimation(). | |
virtual void | handleTickEvent() |
Called periodically by the framework if the Drawable instance has subscribed to timer ticks. | |
virtual bool | isTextureMapperAnimationRunning() const |
Gets whether or not the animation is running. | |
void | setTextureMapperAnimationEndedAction(GenericCallback< const AnimationTextureMapper & > & callback) |
Associates an action to be performed when the animation ends. | |
void | setTextureMapperAnimationStepAction(GenericCallback< const AnimationTextureMapper & > & callback) |
Associates an action to be performed for every step in the animation. | |
virtual void | setupAnimation(AnimationParameter parameter, float endValue, uint16_t duration, uint16_t delay, EasingEquation progressionEquation =&EasingEquations::linearEaseNone) |
Sets up the animation for a specific parameter (angle/scale) for the next animation. | |
virtual void | startAnimation() |
Starts the animation from the current position to the specified end angles/scale, as specified by one or more calls to setupAnimation(). | |
Public Attributes
const int | NUMBER_OF_ANIMATION_PARAMETERS |
Number of animation parameters. | |
Protected Attributes
uint16_t | animationCounter |
Counter that is equal to the current step in the animation. | |
bool | animationRunning |
Boolean that is true if the animation is running. | |
AnimationSetting | animations |
Descriptions of the animation of specific animation parameters. | |
GenericCallback< const AnimationTextureMapper & > * | textureMapperAnimationEndedCallback |
Callback that is executed after the animation ends. | |
GenericCallback< const AnimationTextureMapper & > * | textureMapperAnimationStepCallback |
Callback that is executed after every step of the animation. | |
Additional inherited members
Public Types inherited from TextureMapper
enum | RenderingAlgorithm { NEAREST_NEIGHBOR, BILINEAR_INTERPOLATION } |
Rendering algorithm to use when scaling the bitmap. | |
Public Functions inherited from TextureMapper
virtual void | draw(const Rect & invalidatedArea) const |
Draw this drawable. | |
virtual float | getBitmapPositionX() const |
Gets bitmap position x coordinate. | |
virtual float | getBitmapPositionY() const |
Gets bitmap position y coordinate. | |
virtual float | getCameraDistance() const |
Gets camera distance. | |
virtual float | getCameraX() const |
Gets camera x coordinate. | |
virtual float | getCameraY() const |
Gets camera y coordinate. | |
virtual float | getOrigoX() const |
Gets transformation origo x coordinate. | |
virtual float | getOrigoY() const |
Gets transformation origo y coordinate. | |
virtual float | getOrigoZ() const |
Gets transformation origo z coordinate. | |
virtual RenderingAlgorithm | getRenderingAlgorithm() const |
Gets the algorithm used when rendering. | |
virtual float | getScale() const |
Gets the scale of the image. | |
virtual Rect | getSolidRect() const |
Get (the largest possible) rectangle that is guaranteed to be solid (opaque). | |
virtual float | getX0() const |
Get the x coordinate of the top left corner of the transformed bitmap. | |
virtual float | getX1() const |
Get the x coordinate of the top right corner of the transformed bitmap. | |
virtual float | getX2() const |
Get the x coordinate of the bottom right of the transformed bitmap. | |
virtual float | getX3() const |
Get the x coordinate of the bottom left corner of the transformed bitmap. | |
virtual float | getXAngle() const |
Get the x angle in radians. | |
virtual float | getY0() const |
Get the y coordinate of the top left corner of the transformed bitmap. | |
virtual float | getY1() const |
Get the y coordinate of the top right corner of the transformed bitmap. | |
virtual float | getY2() const |
Get the y coordinate of the bottom right corner of the transformed bitmap. | |
virtual float | getY3() const |
Get the y coordinate of the bottom left corner of the transformed bitmap. | |
virtual float | getYAngle() const |
Get the y angle in radians. | |
virtual float | getZ0() const |
Get the z coordinate of the top left corner of the transformed bitmap. | |
virtual float | getZ1() const |
Get the z coordinate of the top right corner of the transformed bitmap. | |
virtual float | getZ2() const |
Get the z coordinate of the bottom right corner of the transformed bitmap. | |
virtual float | getZ3() const |
Get the z coordinate of the bottom left corner of the transformed bitmap. | |
virtual float | getZAngle() const |
Get the z angle in radians. | |
virtual void | invalidateContent() const |
Tell the framework that the contents of the Drawable needs to be redrawn. | |
virtual void | setAngles(float newXAngle, float newYAngle, float newZAngle) |
Sets the angles in radians of the image. | |
virtual void | setBitmap(const Bitmap & bmp) |
Sets the bitmap for this TextureMapper and updates the width and height of this widget to match those of the Bitmap. | |
virtual void | setBitmapPosition(float x, float y) |
Sets the position of the bitmap within the TextureMapper. | |
virtual void | setBitmapPosition(int x, int y) |
Sets the position of the bitmap within the TextureMapper. | |
virtual void | setCamera(float x, float y) |
Sets the camera coordinate. | |
virtual void | setCameraDistance(float d) |
Sets camera distance. | |
virtual void | setOrigo(float x, float y) |
Sets the transformation origo (center) in two dimensions. | |
virtual void | setOrigo(float x, float y, float z) |
Sets the transformation origo (center). | |
virtual void | setRenderingAlgorithm(RenderingAlgorithm algorithm) |
Sets the render algorithm to be used. | |
virtual void | setScale(float newScale) |
Sets the scale of the image. | |
virtual void | setXAngle(float newXAngle) |
Sets the x angle in radians. | |
virtual void | setYAngle(float newYAngle) |
Sets the y angle in radians. | |
virtual void | setZAngle(float newZAngle) |
Sets the z angle in radians. | |
TextureMapper(const Bitmap & bmp =Bitmap()) | |
Constructs a new TextureMapper with a default alpha value of 255 (solid) and a default Bitmap (undefined) if none is specified. | |
TOUCHGFX_DEPRECATED("Please use invalidateContent() instead." , void invalidateBoundingRect() const ) | |
Invalidate the bounding rectangle of the transformed bitmap. | |
virtual void | updateAngles(float newXAngle, float newYAngle, float newZAngle) |
Updates the angles in radians of the image. | |
virtual void | updateScale(float newScale) |
Updates the scale of the image. | |
virtual void | updateXAngle(float newXAngle) |
Updates the x angle in radians. | |
virtual void | updateYAngle(float newYAngle) |
Updates the y angle in radians. | |
virtual void | updateZAngle(float newZAngle) |
Updates the z angle in radians. | |
Protected Functions inherited from TextureMapper
void | applyTransformation() |
Transform the bitmap using the supplied origo, scale, rotation and camera. | |
void | drawQuad(const Rect & invalidatedArea, uint16_t fb, const float triangleXs, const float triangleYs, const float triangleZs, const float triangleUs, const float triangleVs) const |
The TextureMapper will draw the transformed bitmap by drawing one transformed quad. | |
Rect | getBoundingRect() const |
Gets bounding rectangle of the transformed bitmap. | |
RenderingVariant | lookupRenderVariant() const |
Returns the rendering variant based on the bitmap format, alpha value and rendering algorithm. | |
Protected Attributes inherited from TextureMapper
float | cameraDistance |
The camera distance. | |
RenderingAlgorithm | currentRenderingAlgorithm |
The current rendering algorithm. | |
float | imageX0 |
The coordinate for the image points. | |
float | imageX1 |
The coordinate for the image points. | |
float | imageX2 |
The coordinate for the image points. | |
float | imageX3 |
The coordinate for the image points. | |
float | imageY0 |
The coordinate for the image points. | |
float | imageY1 |
The coordinate for the image points. | |
float | imageY2 |
The coordinate for the image points. | |
float | imageY3 |
The coordinate for the image points. | |
float | imageZ0 |
The coordinate for the image points. | |
float | imageZ1 |
The coordinate for the image points. | |
float | imageZ2 |
The coordinate for the image points. | |
float | imageZ3 |
The coordinate for the image points. | |
float | scale |
The scale. | |
uint16_t | subDivisionSize |
The size of the affine sub divisions. | |
float | xAngle |
The angle x in radians. | |
float | xBitmapPosition |
The bitmap position x. | |
float | xCamera |
The camera x coordinate. | |
float | xOrigo |
The origo x coordinate. | |
float | yAngle |
The angle y in radians. | |
float | yBitmapPosition |
The bitmap position y. | |
float | yCamera |
The camera y coordinate. | |
float | yOrigo |
The origo y coordinate. | |
float | zAngle |
The angle z in radians. | |
float | zOrigo |
The origo z coordinate. | |
const int | MINIMAL_CAMERA_DISTANCE |
The minimal camera distance. | |
Public Functions inherited from Image
virtual void | draw(const Rect & invalidatedArea) const |
Draw this drawable. | |
uint8_t | getAlpha() const |
Gets the current alpha value of the widget. | |
Bitmap | getBitmap() const |
Gets the Bitmap currently assigned to the Image widget. | |
BitmapId | getBitmapId() const |
Gets the BitmapId currently assigned to the Image widget. | |
virtual Rect | getSolidRect() const |
Get (the largest possible) rectangle that is guaranteed to be solid (opaque). | |
Image(const Bitmap & bmp =Bitmap()) | |
Constructs a new Image with a default alpha value of 255 (solid) and a default Bitmap (undefined) if none is specified. | |
virtual void | invalidateContent() const |
Tell the framework that the contents of the Drawable needs to be redrawn. | |
void | setAlpha(uint8_t newAlpha) |
Sets the opacity (alpha value). | |
virtual void | setBitmap(const Bitmap & bmp) |
Sets the bitmap for this Image and updates the width and height of this widget to match those of the Bitmap. | |
Protected Attributes inherited from Image
Public Functions inherited from Widget
virtual void | getLastChild(int16_t , int16_t , Drawable ** last) |
Since a Widget is only one Drawable, Widget::getLastChild simply yields itself as result, but only if the Widget isVisible and isTouchable. | |
Public Functions inherited from Drawable
void | center() |
Centers the Drawable inside its parent. | |
void | centerX() |
Center the Drawable horizontally inside its parent. | |
void | centerY() |
Center the Drawable vertically inside its parent. | |
virtual void | childGeometryChanged() |
This function can be called on parent nodes to signal that the size or position of one or more of its children has changed. | |
virtual void | draw(const Rect & invalidatedArea) const =0 |
Draw this drawable. | |
Drawable() | |
Initializes a new instance of the Drawable class. | |
void | drawToDynamicBitmap(BitmapId id) |
Render the Drawable object into a dynamic bitmap. | |
void | expand(int margin =0) |
Expands the Drawable to have the same size as its parent with a given margin around the edge. | |
Rect | getAbsoluteRect() const |
Helper function for obtaining the rectangle this Drawable covers, expressed in absolute coordinates. | |
virtual Drawable * | getFirstChild() |
Function for obtaining the first child of this drawable if any. | |
int16_t | getHeight() const |
Gets the height of this Drawable. | |
virtual void | getLastChild(int16_t x, int16_t y, Drawable ** last) =0 |
Function for obtaining the the last child of this drawable that intersects with the specified point. | |
Drawable * | getNextSibling() |
Gets the next sibling node. | |
Drawable * | getParent() const |
Returns the parent node. | |
const Rect & | getRect() const |
Gets the rectangle this Drawable covers, in coordinates relative to its parent. | |
virtual Rect | getSolidRect() const =0 |
Get (the largest possible) rectangle that is guaranteed to be solid (opaque). | |
virtual Rect | getSolidRectAbsolute() |
Helper function for obtaining the largest solid rect (as implemented by getSolidRect()) expressed in absolute coordinates. | |
virtual void | getVisibleRect(Rect & rect) const |
Function for finding the visible part of this drawable. | |
int16_t | getWidth() const |
Gets the width of this Drawable. | |
int16_t | getX() const |
Gets the x coordinate of this Drawable, relative to its parent. | |
int16_t | getY() const |
Gets the y coordinate of this Drawable, relative to its parent. | |
virtual void | handleClickEvent(const ClickEvent & event) |
Defines the event handler interface for ClickEvents. | |
virtual void | handleDragEvent(const DragEvent & event) |
Defines the event handler interface for DragEvents. | |
virtual void | handleGestureEvent(const GestureEvent & event) |
Defines the event handler interface for GestureEvents. | |
virtual void | invalidate() const |
Tell the framework that this entire Drawable needs to be redrawn. | |
virtual void | invalidateContent() const |
Tell the framework that the contents of the Drawable needs to be redrawn. | |
virtual void | invalidateRect(Rect & invalidatedArea) const |
Request that a region of this drawable is redrawn. | |
bool | isTouchable() const |
Gets whether this Drawable receives touch events or not. | |
bool | isVisible() const |
Gets whether this Drawable is visible. | |
virtual void | moveRelative(int16_t x, int16_t y) |
Moves the drawable. | |
virtual void | moveTo(int16_t x, int16_t y) |
Moves the drawable. | |
virtual void | setHeight(int16_t height) |
Sets the height of this drawable. | |
void | setPosition(const Drawable & drawable) |
Sets the position of the Drawable to the same as the given Drawable. | |
void | setPosition(int16_t x, int16_t y, int16_t width, int16_t height) |
Sets the size and position of this Drawable, relative to its parent. | |
void | setTouchable(bool touch) |
Controls whether this Drawable receives touch events or not. | |
void | setVisible(bool vis) |
Controls whether this Drawable should be visible. | |
virtual void | setWidth(int16_t width) |
Sets the width of this drawable. | |
void | setWidthHeight(const Bitmap & bitmap) |
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates). | |
void | setWidthHeight(const Drawable & drawable) |
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates). | |
void | setWidthHeight(const Rect & other) |
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates). | |
void | setWidthHeight(int16_t width, int16_t height) |
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates). | |
virtual void | setX(int16_t x) |
Sets the x coordinate of this Drawable, relative to its parent. | |
void | setXY(const Drawable & drawable) |
Sets the x and y coordinates of this Drawable. | |
void | setXY(int16_t x, int16_t y) |
Sets the x and y coordinates of this Drawable, relative to its parent. | |
virtual void | setY(int16_t y) |
Sets the y coordinate of this Drawable, relative to its parent. | |
virtual void | translateRectToAbsolute(Rect & r) const |
Helper function for converting a region of this Drawable to absolute coordinates. | |
virtual | ~Drawable() |
Finalizes an instance of the Drawable class. | |
Protected Attributes inherited from Drawable
Drawable * | nextSibling |
Pointer to the next Drawable. | |
Drawable * | parent |
Pointer to this drawable's parent. | |
Rect | rect |
The coordinates of this Drawable, relative to its parent. | |
bool | touchable |
True if this drawable should receive touch events. | |
bool | visible |
True if this drawable should be drawn. | |
Public Types Documentation
AnimationParameter
enum AnimationParameter
Values that represent different animation parameter.
X_ROTATION | Rotation around the X axis. |
Y_ROTATION | Rotation around the Y axis. |
Z_ROTATION | Rotation around the Z axis. |
SCALE | Scaling of the image. |
Public Functions Documentation
AnimationTextureMapper
cancelAnimationTextureMapperAnimation
virtual void cancelAnimationTextureMapperAnimation | ( | ) |
Cancel move animation.
Stops any running animation at the current position regardless of the progress made so far. Disables all animation parameters set using setupAnimation and mark the animation as stopped.
getAnimationStep
virtual uint16_t getAnimationStep | ( | ) |
Gets the current animation step measured in ticks since the call to startAnimation().
The steps during the initial delay are also counted.
The current animation step.
handleTickEvent
virtual void handleTickEvent | ( | ) |
Called periodically by the framework if the Drawable instance has subscribed to timer ticks.
Reimplements: touchgfx::Drawable::handleTickEvent
isTextureMapperAnimationRunning
virtual bool isTextureMapperAnimationRunning | ( | ) | const |
Gets whether or not the animation is running.
true if the animation is running.
setTextureMapperAnimationEndedAction
void setTextureMapperAnimationEndedAction | ( | GenericCallback< const AnimationTextureMapper & > & | callback | ) | |
Associates an action to be performed when the animation ends.
callback | The callback to be executed. The callback will be given a reference to the AnimationTextureMapper. |
setTextureMapperAnimationStepAction
void setTextureMapperAnimationStepAction | ( | GenericCallback< const AnimationTextureMapper & > & | callback | ) | |
Associates an action to be performed for every step in the animation.
Will not be called during the delay period.
callback | The callback to be executed. The callback will be given a reference to the AnimationTextureMapper. |
setupAnimation
virtual void setupAnimation | ( | AnimationParameter | parameter , | ||
float | endValue , | ||||
uint16_t | duration , | ||||
uint16_t | delay , | ||||
EasingEquation | progressionEquation =&EasingEquations::linearEaseNone | ||||
) |
Sets up the animation for a specific parameter (angle/scale) for the next animation.
The specific parameter is chosen using the AnimationType enum. AnimationTypes that are not setup using this method will keep their value during the animation.
parameter | The parameter of the TextureMapper that should be animated. |
endValue | The end value for the parameter. |
duration | The duration for the animation of the parameter. Specified in ticks. |
delay | The delay before the animation of the parameter starts. Specified in ticks. |
progressionEquation | (Optional) the progression equation for the animation of this parameter. Default is EasingEquations::linearEaseNone. |
startAnimation
virtual void startAnimation | ( | ) |
Starts the animation from the current position to the specified end angles/scale, as specified by one or more calls to setupAnimation().
Public Attributes Documentation
NUMBER_OF_ANIMATION_PARAMETERS
const int NUMBER_OF_ANIMATION_PARAMETERS = SCALE + 1
Number of animation parameters.
Protected Attributes Documentation
animationCounter
uint16_t animationCounter
Counter that is equal to the current step in the animation.
animationRunning
bool animationRunning
Boolean that is true if the animation is running.
animations
AnimationSetting animations
Descriptions of the animation of specific animation parameters.
textureMapperAnimationEndedCallback
GenericCallback< const AnimationTextureMapper & > * textureMapperAnimationEndedCallback
Callback that is executed after the animation ends.
textureMapperAnimationStepCallback
GenericCallback< const AnimationTextureMapper & > * textureMapperAnimationStepCallback
Callback that is executed after every step of the animation.