Introduction

Introducing easing Functions

easing Functions - use for Object Animations in Excel

This Software uses Robert Penners easing Functions converted from JavaScript to VBA. It uses a variety of different resourses to pull together easing Functions that are presented in 4 Files, a legacy example Workbook with a plot Chart, a newer generic easing Function Workbook (legacy examples and my Flyout Animations on a separate Sheet without a plot Chart), a modern easing Cheat Sheet with a Donut demo and an ITeeen Object Animation Class Workbook which demonstrates not only Shape movement, but also UserForm movement. The ITween Class is powerful in that it can be added to any Object, which includes Shapes, Icons, UserForms etc. and it also includes easing on the Top, Bottom, Width and Height of the Object / Element with easing movement in all directions. Easing can be confusing, therefore I have spent considerable time ensuring the Cheat Sheet Demo plots the movement from a start position to an end position so that the easing demonstration and the Code make much more sense than in my legacy work. There is no direction in an easing, it is just that, an animation from the start position to the end position split by N number of Tweens ran every N Frame. VBA needs to be a little different than running easing in JavaScript where we can request the next frame, with VBA we need to do some timing and allow DoEvents. To ease backwards, you can swap the start and end positions of the Tweens

Prerequisites

  • Excel 2013 (Version 5) & Excel 2016 (32bit or 64bit, Version 8)
  • Basic to moderate Excel Skills and some VBA skills to Copy the Class or use the examples in your own Code
  • Windows PC · NOT a Mac!
  • No support is provided for customization of this Software

Features

  • Legacy easing Functions from my original work, which gives a basic grounding in how to animate a Shape in Excel, capture the easing output and also plot the easing on a Chart
  • Ported and slightly optimised easing Functions that drive a Donut Demo for right and left animations
  • So far I have ported 37 easing Functions to date (with one or two repetitions)
  • Swap the start and end positions of the Tweens to run the easing backwards
  • My own Timer routines that do not use API ie. Sleep
  • My own ITween Class, which is powerful, you can add to UserForms and it also includes easing on Top, Bottom, Width and Height for the Elements with easing movement in all directions
  • easeBackInCubic
    easeBackInQuartic
    easeInBack
    easeInCirc
    easeInCubic
    easeInExpo
    easeInOutCubic
    easeInOutQuintic
    easeInQuad
    easeInQuadratic
    easeInQuart
    easeInQuartic
    easeInQuintic
    easeInSine
    easeLinear
    easeOutBack
    easeOutBounce
    easeOutElastic
    easeOutInCubic
    easeOutInQuartic
    easeOutQuad
    easeOutQuartic
    easeOutQuintic
    easeOutSine
    easeInOutSine
    easeOutQuart
    easeOutCirc
    easeInOutQuad
    easeOutCubic
    easeInOutQuartic
    easeOutExpo
    easeInOutExpo
    easeInOutCirc
    easeOutElasticSmall
    easeOutElasticLarge
    easeInElasticSmall
    easeInElasticBig
    

This is a video of some of the Beachball easing Functions using the ITween Class

This is a video of my easing Cheat Sheet

Installation

easingFunctions.zip contains all of the example easing Files. Unzip the Archive to your PC (right-click, extract all...). There are 4 Files, a legacy example Workbook with a plot Chart, a newer generic easing Function Workbook (legacy examples and my Flyout Animations on a separate Sheet without a plot Chart), a modern easing Cheat Sheet with a Donut demo and an ITeeen Object Animation Class Workbook which demonstrates not only Shape movement, but also UserForm movement, with easing ran on Width, Height, Top and Bottom. Open each File and test out the Demos. To find out more information on how to use the easing Functions check out the Code or continue reading this online documentation

Usage

easingFunctions_v1.2.xlsm & easingFunctions_v2.xlsm


Legacy easing Functions Example Workbooks
Open either the 'easingFunctions_v1.2.xlsm' or the 'easingFunctions_v2.xlsm' File. One File includes a plot Chart and the other doesn't. Test the 9 examples in each Workbook by selecting them from the Drop-down Combo Box and pressing the 'Run Easing' Button. Press ALT+F11 to open the VBA Editor and examine the Code - you will find the easingFunctions(), Example Subroutine, a FrameTimer() Function and all of the Easing Functions. As an example suppose you had a Shape called shpWheel, then to animate the Shape you can modify the routine given in the easingFunctions() Subroutine and use shpWheel.Top = easeOutBounce(dblFrame, intStart, (intEnd - intStart), dblTotalFrames) to move the Shape using an "easeOutBounce" Easing Function. Please Note: a good level of VBA skills are required to use these Easing Functions - this Code gives you a method and Frame Time enabling the process and the ported Easing Functions as a starting point. Also note that the easing Functions have not been Code Inspected and are not optimised

easingFunctions Cheat Sheet.xlsm


A Cheat Sheet with various easing Functions and a Donut Demo for Excel
This Workbook is the result of spending more time looking at easing in Excel and tweaking how to use the easing Functions via VBA. This File still uses a Shape for its animation, however, it uses Code that is a little more intuitive than the two legacy Files above. For a start, where possible each easing Function has been optimised. Then, for the Code, the animation is ran by passing a start position of your Shape and an end position of your Shape. The only other parameters that you need to pass are the Frames per second and the Tweens per second values. Here are two of the ported easing Functions that are used to move the Donut:
 
' linear movement in steps that are uniform
Private Function easeLinear(ByVal t As Double, ByVal b As Double, ByVal c As Double, ByVal d As Double) As Variant
   easeLinear = c * t / d + b
End Function

' start slow, end up fast.  tiny steps, then larger ones
Private Function easeInQuad(ByVal t As Double, ByVal b As Double, ByVal c As Double, ByVal d As Double) As Variant
 easeInQuad = c * (t / d) * t + b
End Function

The timing loop is ran at a default refresh rate of 60 Frames per second ie. 60 per second, 1 / 60 = 0.0166666666666667. The Tweens per second is set at a default of 30, meaning that a number is returned 30 times from the easing Function that is used to move the Shape, you guessed it, 30 times. Both the number of Tweens and the output from the easing Function is detailed on the easingFunctions Worksheet so numerically, you can get an idea of how the Math is working in each easing Function. I have also included links to resources that I have found helpful when trying to port and use easing Funtions in Excel. If I run the 'easeInQuad' easing Function then the output from 100 to 400 can be shown to accelerate on a Chart like this with the steps on a second Axis and the easing (you can see the first 15 steps move and then the next 15 steps move 225 with the first 5 steps moving just 8):



And here is the Chart plot for my easeOutBounce:



And here is the Chart plot for my easeOutBounce (sometimes it's good to visual how the output looks - you can see the shape that the Bounce takes, one large hit at position 400 and then smaller hits or bounces). To call these easingFunctions in a Worksheet Code Module, I use a Timer loop and then within that loop just do something like this where TweenTime is a value between 0 and 1 split by the number of Tweens I want ie. 30 which will be 0.0333 (1 / 30), TweenFrom is the Shapes start postiton, TweenTo is the Shapes end position being the difference between the end and the start and TweenDuration which is always set to 1 (1 second):
   
Dim Sprite As Shape
Set Sprite = Me.Shapes("donut")
Sprite.Top = 228

 Do
  DoEvents
 
   Sprite.Left = easeLinear(TweenTime, TweenFrom, TweenTo - TweenFrom, TweenDuration)

There are lots of easing Functions for you to try and view, just press the 'Run easingFunction' Button to see the Orange Donut move across the Blue Rectangle. Swap the From and To values to see the easing in reverse



ITween Class.xlsm


An Object Animation Class for Excel - Beachball Sheet
This Workbook features the results of all of the above, wrapped up in a Class that can be used to add to Objects like Shapes, UserForms etc. to move Horizontally or Vertically and to adjust their Width or Height or a combination of all of these at once. Test out all of the finished Demos in the Workbook. I will build the Demos as I write this documentation, so you can see the progress and understand how to use the Class in different ways for animating. To Copy the Class into your own Workbooks, open the Visual Basic Editor and drag the Class Module into your own Project in the Explorer Window. Okay, so let's look at what you can do with this Class. I have deliberately left the Beachball for you to position or drag anywhere on the Worksheet. To start with, let's move a Beachball in the default direction horizontally - you can emulate this by clicking on the 'Right' Button. We will use easing of 'easeInBack':
Dim Sprite As ITween
Set Sprite = New ITween

Set Sprite.Tweener = Me.Shapes("Ball")

' normally you would set TweenFrom to the start position and TweenTo to the end position ie. 100 and 300.  for the Demo, I use the Shape Left and add 300 each time the button is pressed
Sprite.Tween Easing:=easeInBack, TweenFrom:=Sprite.Tweener.Left, TweenTo:=Sprite.Tweener.Left + 300, TweensPerSecond:=24, FramesPerSecond:=40

Here is the Animation using the Code above



Normally to go Left instead of Right, you can simply swap the TweenFrom and TweenTo values around, however for the Demo, I need to use the Shapes current position so to go Left I subtract the value I want to move ie. Sprite.Tween Easing:=easeInBack, TweenFrom:=Sprite.Tweener.Left, TweenTo:=Sprite.Tweener.Left - 300, TweensPerSecond:=24, FramesPerSecond:=40. Now let's move Vertically. When moving Horizontally we do need to adjust the TweenWhat parameter as the default is to move Horizontally. So to move up or down we need to set this to Vertical like this: TweenWhat:=TweenVertical. Here is the Code to move the Beachball Up:
Dim Sprite As ITween
Set Sprite = New ITween

Set Sprite.Tweener = Me.Shapes("Ball")
   
' normally you can go up by setting TweenFrom and TweenTo ie. 100 and 300.  for the Demo, I use the Shapes current .Top position and subtract the value 100 to move up
Sprite.Tween Easing:=easeInBack, TweenFrom:=Sprite.Tweener.Top, TweenTo:=Sprite.Tweener.Top - 100, TweensPerSecond:=24, FramesPerSecond:=40, TweenWhat:=TweenVertical

Here I have added more Buttons and the Demo is complete for the basic movements. I also added an Explicit Positioning Example to show you the default ways of moving from A to B



An Object Animation Class for Excel - UserForm Sheet
This Sheet is similar to the Beachball Sheet however it demonstrates how easy it is to add the Class to a UserForm and animate it to the center of the Excel Application. Select an easing from the available easings using the Radiobuttons and click the Right or Left Buttons to see the UserForm easing. To attach the Class just set the Object for the Tweener like this: Set Sprite.Tweener = UserForm1. Here is the Code to attach the Class to a UserForm and Animate it:
Dim Sprite As ITween
Set Sprite = New ITween

Set Sprite.Tweener = UserForm1
Sprite.Tweener.Width = 300
Sprite.Tweener.Height = 240
   
Dim Middle As Double
Dim LeftEdge As Double
With Sprite.Tweener
  Middle = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
  .Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
  LeftEdge = Application.Left
  .Show
 End With
   
Sprite.Tween Easing:=[Radiobuttons.Selected2].Value2, TweenFrom:=LeftEdge, TweenTo:=Middle, TweensPerSecond:=24, FramesPerSecond:=40

Here is a Demo of the UserForm Sheet. The Video appears jerky at the beginning but the transmitions are perfectly smooth - its just the recording..!



easing Functions

ITween Beachball Demo Sheet

ITween UserForm Demo Sheet

easing Functions Version 1.2 (legacy)

easing Functions Cheat Sheet

FAQ

There are no Q & A for the easing Functions


ITween Class

This is a video of some of the Beachball easing Functions using the ITween Class

ITween Class

This is a video of some of the UserForm easing Functions using the ITween Class. The Video appears jerky at the beginning but the transmitions are perfectly smooth - its just the recording..!

ITween Class - Additional easing Functions

This is a demo of some additional easing Functions in version 2.1

easing Functions

This is a video of my legacy easing Functions for Excel

easing Functions Cheat Sheet

This is a video of my modern easing Functions Cheat Sheet for Excel

easing Functions

This is a demo of some Button Shape animations, Bounce and Flyout available in Version 1.2

Support

Support is 100% optional and I provide it for your convenience, so please be patient, polite and respectful

Support for my Software

  • Responding to questions or problems regarding the Software and its features
  • Fixing valid (replicated) bugs and reported issues for the VERSION I HAVE WRITTEN

Software support does not include

  • Customization and installation services
  • Support for third party software or ANY kind of development whatsoever

Before seeking support

  • Make sure your question is a valid Software Issue and not a customization request
  • Make sure you have read through the FAQ's, online documentation and any related video guides before asking support on how to accomplish a task
  • Ensure that you access to the VBOM is allowed and that Macros can run in Excel
  • Make sure to provide 'proof of purchase' and state the name / version of the Software that you are having issues with when requesting support by Email or via Facebook

How to get Support

Contact Mark Kubiszyn on the Email address provided when you purchased the Software, including the Order Number
Remember to be patient, if there has been an issue with your download, Mark will always respond within 48 hours and will Email you the File directly if neccessary. For other issues the response time may be considerably longer and I may choose to respond to specific questions only (as is my right), depending on what has been asked

Future Builds

* Threaded Tweens!? (well as close as I could possibly get for a multi-threaded tweening Class for Excel)

Bug Fixes

* There are currently no bugs identified

Changelog

You can find the version history in the Code Module for any Macro-enabled Software or read more information on the status of each release
- the latest Version including a description of any changes made is always shown first

01.01.2021 - (Version 2.1) Released

Ported many more easing Functions that were missed off in version 2 as I could not get them working originally or I simply missed them off. There are some great new ones, I particularly like 'easeInOutExpo' and 'easeInElasticSmall'
Added comments to the easing Functions in the Cheat Sheet to try to explain better what the easing does
Changed the ByRef t, to ByVal t in the easingFunctions as 'easeOutBounce' was not working correctly

12.12.2020 - (Version 2) Released

Replicated version 1.2 and removed the Plot Chart to fix a bug where the Chart plotting was slowing down the animations
Created a new easing Functions Cheat Sheet with 24 easings. Optimised some of the easing Functions. Demo is a Donut moving in a Blue Rectangle. This Demo is the precursor for my ITween Class which will superceed all of my easing work in Excel
New ITween Class that allows easing on Shapes, Icons, UserForms etc. Created 2 Demos. Beachball Sheet demonstrates a Shape for Up, Down, Left and Right easings. UserForm Sheet demonstrates similar animations for a UserForm which is 'eased in' to the center of the Excel Application

28.10.2018 - (Version 1.2)

Added some Shape Flyout & Bounce animations on a new Worksheet

20.10.2016 - (Version 1) released