Open DragonMoffon opened 1 year ago
Here is an idea on how to provide a callback system. It works with properties making it perfect for sprites.
class Animator2D:
# All the implementation guff
def set_property_callback(self, _instance: Any, _property: CorrectType ):
def call_back(_value: Tuple[float, float]):
_property.fset( _instance, _value )
self._call_back = call_back
def set_callback(self, _call_back: Callable[[Tuple[float, float]], Any]):
self._call_back = _call_back
While working on some controllers for cameras, I started forumlating an idea for a general animation class.
I was going to add it to the Camera PR, but I realised it was a major scope creep.
Basically, I've written a while bunch of bezier (like photoshop pen tool) curves that are commonly used in animation. They take a number of points and a value from 0 to 1 (similar to easing functions). It returns an interpolated point. If mixed with easing methods, you get some extremely clean looking animations.
So my idea is you would have a queue of these curves and a callback method.
It was going to originally just be for cameras, but I realised I could generalize for any method that accepted the correct type.
Anyway, it'd be a big undertaking that would be fully backward compatible (I believe) so it can come in 3.1 or later.
Here are some more deets from Discord:
I propose we put together a generalised animator that uses a callback to change a 1D, 2D, and 3D value.
There should be a standard interface/object for defining part of an animation.
It should also provide timestamping and some form of event system (could be even more callbacks) for syncing effects.
There should be a way to fire one-off events repeatedly.
There should be a way to fire an animation after a delay.
Should have flexibility to use any clock system we come up with.
The length and speed of the animations should be controllable (non-uniform b-splines, knot vectors. Tryna figure this out).
My idea for the callback is that you can use args and kwargs.
the args values you want passed at animation time to the callback (t value, curve info, delta_time, etc) while kwargs are constant values you want passed.
See issue #1869