A package for managing animations of pygame surfaces
Project description
Pygame-Animation
This package provides a framework for managing animations using various smoothing techniques. The AnimationManager class is designed to handle the setup and progression of animations, allowing for smooth transitions and customizable easing methods.
Features
1. Customizable Smoothing:
Use different smoothing methods to control the animation's easing.
2. Flexible Activation:
Easily manage the activation and deactivation of animations.
3. Abstract Methods for Custom Animations:
Implement your own animations by extending the AnimationManager class.
Installation
Ensure that the module and its dependencies are included in your project. No additional installation steps are required.
pip install pygame-animations
Usage
Importing the Classes
from smoothing_methods import EaseOutSuperFastSmoothing, SmoothingInterface
from smooth_animation import SmoothAnimation
from target_manager import TargetManager
from animation_manager import AnimationManager"
Creating a Custom Animation Manager
To create a custom animation, extend the AnimationManager class and implement the abstract methods animate, activated_animation_setup, and deactivated_animation_setup.
class MyCustomAnimationManager(AnimationManager):
"""
A custom animation manager for manipulating the position of a surface.
Args:
surface: The surface object to be animated.
"""
def __init__(self, surface):
super().__init__()
self.surface = surface
def animate(self):
"""Animate the surface's position."""
self.surface.set_position(self.current_value)
def activated_animation_setup(self):
"""
Set up the animation for the activated state.
Initial position of the surface: 10
Target position of the surface: 20
"""
self.set_target(current_value=10, target_value=20)
def deactivated_animation_setup(self):
"""
Set up the animation for the deactivated state.
Initial position of the surface: 20
Target position of the surface: 10
"""
self.set_target(current_value=20, target_value=10)
Usage example
animation_manager = MyCustomAnimationManager(activated=False, percentage_per_iteration=0.05)
animation_manager.check_for_animation(activated=True)
Class Descriptions
AnimationManager
The AnimationManager class is an abstract base class for managing animations. It handles the setup and progression of animations using a SmoothAnimation instance.
Initialization
AnimationManager(activated: bool = False, percentage_per_iteration: float = 0.03, smoothing_method: SmoothingInterface = EaseOutSuperFastSmoothing())
activated:
Initial activation state of the animation (default: False).
percentage_per_iteration:
The percentage change per iteration for the animation (default: 0.03).
smoothing_method:
The smoothing method to use for the animation (default: EaseOutSuperFastSmoothing).
Smoothing Methods
This module also provides various smoothing methods to control the easing of animations. Each smoothing method implements the SmoothingInterface and provides a static method smooth_in_animation to calculate the smoothed value based on the elapsed time.
LinearSmoothing
Description:
Linear smoothing, returns the input time directly.
EaseOutQuadSmoothing
Description:
Quadratic ease-out smoothing.
QuadraticSmoothing
Description:
Quadratic smoothing with different behavior based on time.
ParametricSmoothing
Description:
Parametric smoothing using a specific parametric formula.
EaseOutQuintSmoothing
Description:
Quintic ease-out smoothing.
EaseOutCubicSmoothing
Description:
Cubic ease-out smoothing.
EaseOutBackSmoothing
Description:
Back ease-out smoothing with overshoot.
EaseInOutElasticSmoothing
Description:
Elastic ease-in-out smoothing with a bounce effect.
EaseOutElasticSmoothing
Description:
Elastic ease-out smoothing with a bounce effect.
EaseOutExpoSmoothing
Description:
Exponential ease-out smoothing.
EaseOutSuperFastSmoothing
Description:
Super fast ease-out smoothing, starts quickly then slows down exponentially.
Contributing
Contributions are welcome! Please open an issue or submit a pull request if you have suggestions for improvements or new features.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pygame_animation-1.0.0.tar.gz
.
File metadata
- Download URL: pygame_animation-1.0.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42bcec58f686dac89ca5e0947f887d8f33c0bab6e9127c441708d723e28761c4 |
|
MD5 | aae754453977ca02e7e00c98de3a2152 |
|
BLAKE2b-256 | f51b0cec362fd2c8139fd154514e97d1966b10e42796d1d4de104ee83d8585eb |
File details
Details for the file pygame_animation-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: pygame_animation-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5052dacca72f396417d97ef4a8d189720285d3c14ec7d03913c1f93d6a320895 |
|
MD5 | 6101e1935ee6ab301ba1fe7404ea4648 |
|
BLAKE2b-256 | fef5e17b42fca23375f93629220e90eb4b004ace4d2123f0cff4371f31ae6e86 |