- Pascal 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| Demo | ||
| Source | ||
| .gitignore | ||
| CodAnimationLib.dpk | ||
| CodAnimationLib.dproj | ||
| CodAnimationLib.dproj.local | ||
| CodAnimationLib.identcache | ||
| CodAnimationLib.res | ||
| Icons.dcr | ||
| LICENSE | ||
| README.md | ||
Codrut-Animation-Lib
Codruts Animation Library is a simple component-based animation library for Delphi VCL. It's similar to the official FMX counterpart.
It can also support sub-classes!
If a property like top works, you can also use margin.top to change the sub-property of the class margin!
You can also use as many sub-classes as you wish. Like Button1.Margin.Interior.Size.Left!
Component
| Image | Description |
|---|---|
| The animation control on the form | |
| To make the animation work, first select a component to animate, the animation, the start and end value and the property to change |
Start / stop animation
You can change the Running property, or use the Start or Stop procedures.
You may also pause the animation using the Paused property.
Properties
| Property | Type | Description |
|---|---|---|
| Component | TComponent | The component of which the property will be changed (optional) |
| CurrentValue | {AnimationType} | The current animation value (Read-only) |
| Delay | Single | The time waited before the animation actually starts in seconds, also can be in-between loops |
| DelayLoop | Toggle to wait the Delay amout inbetween loops | |
| Duration | Single | The animation duration |
| EndValue | {AnimationType} | The end value |
| Inverse | Boolean | Execute from End to Start |
| Kind | TAnimationKind | The animation function used |
| Loop | Boolean | Restart the animation on end |
| LoopInverse | Boolean | Toggle the inverse property on loop |
| Percent | Single | The percentage of the animation being finalised (Read-only) |
| PropertyName | String | The property to change. Can also access properties of sub-classes with the . separator. (optional) |
| StartFromCurrent | Boolean | Defines if the start value is determined by the current Component Value (Requires component and PropertyName) |
| StartValue | {AnimationType} | The value from which the animation starts. Can be overriden by StartFromCurrent |
| Steps | Integer | Set a custom steps value for the animation, instead of auto-calculating them. The less steps the greater the drawing performance |
Animation types
- Linear
- Exponential
- Pulse
- Random
- ReverseExpo
- Sinus
- SinusAr
- Wobblyc
- Spring
Note: Pulse and Wobbly do not reach their end value, as they return back to their start value.
Async animation example
You can use Async animations with the TAsyncAnim class. These, unlike the standard TIntAnim and TFloatAnim, are not components so you can easily use them wherever you'd like In your code. They run in the thread that called them until they finalise.
with TAsyncIntAnim.Create do
try
StartValue := Screen.DesktopRect.Left;
EndValue := Screen.DesktopRect.Right-Self.Width;
Duration := 1.00; // seconds
Kind := TAnimationKind.ReverseExpo;
// Events
OnValue := procedure(Value: integer) begin
Left := Value;
end;
// Start
Start;
finally
Free;
end;
Use without component
- Assign the OnStep notify event from the Object Inspector.
- Get the
CurrentValueproperty from the Sender - Use the value as needed Example:
procedure TForm1.NewAnimation1Step(Sender: TObject; Step, TotalSteps: Integer);
var
Value: integer;
begin
Value := TIntAnim(Sender).CurrentValue;
// now use the value
end;