Easings
The animation lib for Lazarus IDE projects.
- Active · last change 8-24-2025
README
💫 Easing animations.
Easing is a term for non linear animations. This lib has functions to animate float values(Single type), from initial(start) to final(end) values during a short time. We perform an animation frame for each change value of animation to get the effect. This provide fluid animation that accelerates and decelerates during the defined time, without complex implementation. The animation frame itself is just the execution of method called on animation change. The user may be able to create complex animation and effects like fad-in/fade-out, moviment, color, image fusion and more.
🗒️ Need to know
1 The kind of animation:
- Linear
- Sinusoidal
- Quintic
- Quartic
- Quadratic
- Exponential
- Elastic
- Cubic
- Circular
- Bounce
- Back
2 Also necessary accelerates/decelerates definition(Except for linear pick):
- Ease-In -> Easing that accelerates from zero.
- Ease-Out -> Easing that decelerates to zero.
- Ease-InOut -> Easing that accelerates then decelerates.
3 The during time for the animation in float value:
Ex: 1.0 -> One second.
(Animations more than 3 secs doesnt make sense. Except in cases of showcase and opening.)
4 The start/end of animation:
- The Start position; The float value to calc the animation.
- The End position; The float value that animation must be done.
- The Change position; The value generated and trigged to a animation frame.
5 How to engage the change value to your task:
- This is the animation itself. Use the change value to move a control or add some alpha in color, etc.
⚙️ Invoking
Using an exclusive thread or the LCL loop the animation must have the same precision.
- Invoke by thread when you need to call more than one, at same time or represent an execution(like a progress).
- Invoking with LCL loop when you need to repeat the animations as long the app lifetime or want begin/end events.
- Both ways for animation are of type Fire and forget, once created you only need to fillout and trigger Start(...).
- On end, the animation object is destroyed, you may not destroy or free by yourself.
- May be Stopped anytime without prejudice, so will be destroyed too.
- Both of invoking are precise and have OnBeforeEnd event as well an user-data attachment.
- Pay attention for the declaration of thread lib on main unit. OS like unix variants require
cthreadsin interface clause.
🚀 Quickstart
The animations requires the declaration of lcl.easings.pas for the objects. The easings.pas unit is where the
animations methods are placed. There are some enumerations types that represent the data for fillout the animation objects.
- The TAnimation object abstracts the animation. Use .Start(...) to initialize and .Stop() to break the animation while alive.
- For LCL loop you may create the object TAnimator to deal with animation start/end positions. It creates TAnimation object for use.
- Only one animation could be running at time for each TAnimator instance. When new one is created then the current is stopped.
- For exclusive thread invoke you may use TThreadAnimator.NewAnimation(...) to get the TAnimation object. Many objects you want.
- The animations uses single float value. Usually for apply it is required to round the value. Use Round(...) method.
The unit
lcl.easings.pashas a frames per second option to help the objects. Its not necessary adjust nothing, its default 60 FPS. The default value Works well for all kind of animations on modern machines. When you change that you must realize that more than 60 just excess and lessen than 24 is a bad choice. Old times some animations goes at 15 in linear animations for old computers, but for easing ones this must be a poor animation. For change this use SetFramePerSec(...) method and the unit set for you the correct delay calc for the objects.
📦 Package
This library is developed for use with lazarus IDE projects but dont require installation as a package. The recommendation is for just copy the units to target project folder. This library contains:
easings.pasunit with animations calcs.lcl.easings.pasunit with objects for animation.test/sample.lpiLazarus Project file for test and playground.
⌨️ Copyright notice
© 2025 Humberto Teófilo, All Rights Reserved.
☀️ License
This software is released under MIT license. See the file license.txt.
