Skip to content

Python library, that helps you create animation with ease, to any GUI framework.

License

Notifications You must be signed in to change notification settings

edenb-dev/Ez-Animations

Repository files navigation

Ez-Animations

Python library, that helps you create animation with ease, to any python GUI framework.

Example 1 Example 2
Tkinter Example 1 Tkinter Example 2
Animation script, that combines multiple animations. One animation script, that changes the speed of the animation, base on the button's y value.

Intorduction

The Ez-Animations lib, add's the abilty to create animation scripts, link them to objects / groups of objects, and then animate them separately or all at once.
Also the lib provides you with the ability to control the fps of the animation scripts, based on your preferences.

  • Animation Scripts (Animation Sequences) - Reusable sequence of animations, that will perform the animation on the selected object.

Pre-Knowledge Requirements.

Before you do anything with this lib, you need to understand fully the GUI framework that you are working with.
You need to know exactly how to move, scale, rotate, change alpha, etc, inorder to create your own animation scripts, that supports those actions.

How to use

This example will show you how to create a simple animaiton using the library with the Tkinter GUI framework.

  1. Download the files, and place it in a known directory.
  2. Import the modules 'Animation', 'Animation_Manager' and 'tkinter' to your python project.
from Animator import Animation
from Animation_Manager import Animation_Manager

import tkinter as tk # GUI Framework
  1. Initialize the Animation_Manager object, with the FPS count you would like to use.
Animation_M = Animation_Manager(FPS=60)
  1. Create & Load your animaiton sequence.

The animaiton sequence is an array filled with Animation objects. Each Animation object has several settings.

  • Start_Value - The starting value.
  • End_Value - The ending value.
  • Animation_Duration - The duration the animation will take.
  • Function - The logic on how to perform the animation.
  • Time_Till_Animation_Start - The duration to wait before the animation will start. ( Optional )

This simple script will move the object given, along the border of the window, and will complete a full rotation

Click To Show Code
  Animation_Name = 'Movment_Along_Border'

  Animation_Sequence = lambda Object: [
          Animation(Start_Value=50,   # Moving From Left To Right.
                    End_Value=500,
                    Animation_Duration=1,
                    Function=lambda New_X_Cords: Object.place(x=New_X_Cords, y=Object.winfo_y())),
          Animation(Start_Value=50,   # Moving From Top To Bottom.
                    End_Value=310,
                    Animation_Duration=1,
                    Function=lambda New_Y_Cords: Object.place(x=Object.winfo_x(), y=New_Y_Cords),
                    Time_Till_Animation_Start=1),
          Animation(Start_Value=500,  # Moving From Right To Left.
                    End_Value=50,
                    Animation_Duration=1,
                    Function=lambda New_X_Cords: Object.place(x=New_X_Cords, y=Object.winfo_y()),
                    Time_Till_Animation_Start=2),
          Animation(Start_Value=310,  # Moving From Bottom To Top.
                    End_Value=50,
                    Animation_Duration=1,
                    Function=lambda New_Y_Cords: Object.place(x=Object.winfo_x(), y=New_Y_Cords),
                    Time_Till_Animation_Start=3)
  ]

  # Adding/Loading The Animation Sequence.
  Animation_M.Add_Animation_Sequence(Animation_Name, Animation_Sequence)
  1. Add a function to start the animation.

Start Animation takes several parameters :

  • Animation Name - The name of the animation, that was added to the Animation_Manager
  • Object - The object that the animation will be performed on.
  • On_Finish - Function that will excute once the animation finishes. ( Optional )
          Also the object used in the animation passes as a parameter to the function.
def run_Animation(Object):

    Animation_M.Start_Animation('Movment_Along_Border', Object, On_Finish=on_AnimationFinished)

Add the following code, only if you added the On_Finish parameter.

def on_AnimationFinished(Object):
    print("Finished Animating !~!")
  1. Finally create the tkinter window with a button, that when clicked excutes the run_Animation function.
    root = tk.Tk()
    root.geometry("640x360")

    My_Button = tk.Button(root, text="Animate Me", command=lambda: run_animation(My_Button))
    My_Button.place(x=50, y=50)

    root.mainloop()

More Examples Could Be Found In Here

Built With

About

Python library, that helps you create animation with ease, to any GUI framework.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages