Download
(19 Kb)
Download
Updated: 07-22-13 11:09 AM
Updated:07-22-13 11:09 AM
Created:02-04-13 07:07 PM
Downloads:27
Favorites:1
MD5:
LibAnimate
Version: 1.0.7
by: Imhothar [More]
General Information
LibAnimate is a library for performing time-based interpolation of values.

It gives you the ability to animate properties of Rift frames out-of-the-box with very little code. It has a comprehensive set of interpolation functions for a high variety of animation curves. All you need to provide are starting values, end values, a duration and the name the of interpolation function, and the rest is handled behind the scenes for you.

Simple Example
In this example, we are going to animate a frame's alpha value from 0.0 to 1.0 over a duration of 3.0 seconds using the cubic Hermite interpolation also known as smoothstep.

First we need a template to represent the animation curves and value projection:
Code:
local template = LibAnimate.CreateTemplate({ false, "smoothstep" })
CreateTemplate receives a single argument: a table containing the interpolation methods for each component of the animation. The concrete values mean:
  • false: The first value is not animated at all but is always the starting value.
  • "smoothstep": The second value is interpolated using the smoothstep function.
This is required once at Addon startup and the template should be stored somewhere for later use. Now we can start spawning animations from this template. Note the number of animations you create from a template is not limited. In the following snippet the Frame object frame's alpha is animated from 0.0 to 1.0:
Code:
local animation = LibAnimate.CreateAnimation(template, frame.SetAlpha, 3.0, { frame, 0.0 }, { frame, 1.0 })
animation:Start()
The following happens: Over the next 3 seconds the library will call the target function (in this example frame.SetAlpha) in its Event.Syste.Update.Begin cycle with the interpolated arguments, starting at alpha 0.0 and ending at alpha 1.0 using the smoothstep interpolation function as defined in the template creation.

Now it becomes apparent why the animation template requires 2 values even though we are only interpolating a single property (the alpha value). The template requires exactly the same amount of values as the target function. In this example it is Frame:SetAlpha(alpha) which has the hidden self argument which needs to be provided. Note that animation is not necessarily a fire and forget variable. The reference can be used to stop, pause and resume the animation later. The :Start() method can optionally take a new independent set of start values, end values or duration which override the values the animation was created with for the started run. For a detailed listing of the available methods check the Animation reference page.

More Information
This was just a little example.
There are also a few convenience methods for all widget objects. This is the current list:
  • Frame:AnimateAlpha()
  • Frame:AnimateBackgroundColor()
  • Text:AnimateFontColor() (only for Text frames)
  • Frame:AnimateHeight()
  • Frame:AnimatePoint()
  • Frame:AnimateWidth()
  • Frame:FadeIn()
  • Frame:FadeOut()
There are more detailed descriptions of all the functions and how the animation/template system works. The Wiki at CurseForge has the full documentation. I hope you don't mind it's hosted on a different site, but I don't want to repeat the documentation all over the interwebs.
Optional Files (0)


Archived Files (4)
File Name
Version
Size
Author
Date
1.0.6
13kB
Imhothar
03-11-13 03:47 PM
1.0.5
13kB
Imhothar
02-24-13 12:18 AM
1.0.4
13kB
Imhothar
02-23-13 08:18 PM
1.0.3
13kB
Imhothar
02-04-13 07:07 PM


There have been no comments posted to this file.
Be the first to add one.



Category Jump: