- class animator.Animator(fps=45, autostart)
The Animator Class lets you create and control the animation thread to manage your animations
- Arguments:
fps (number) – the fps to render animations; default: 33.33
autostart (boolean) – whether or not to call the init method after construction; default: true
- animator.Animator.Lambda(condition, callback)
Creates a new lambda animation with the given condition and callback. The callback is a function that is called when the condition is true. The callback is called with the value of the lerp animation that triggered the condition.
- Arguments:
condition (function) – A function that takes one argument, the value of the lerp animation and returns true if the condition is met.
callback (function) – A function that takes one argument, the value of the lerp animation that triggered the condition.
- Returns:
Lambda – The lambda animation that was created.
- animator.Animator.Lerp(args)
Creates a new Lerp object.
- animator.Animator.Matrix_Lerp(args)
Create a Matrix_Lerp object.
- animator.Animator.Timeline(args)
Creates a new Timeline object.
- animator.Animator.addTrigger(id, target, step, time)
Add a trigger to the animation with the given id.
- Arguments:
id (number) – the id of the animation to add the trigger to
target (number) – the target id of the trigger
step (number) – the step at which the trigger should trigger
time (number) – the time at which the trigger should trigger
- animator.Animator.constant(type, value, render_callback)
Constant.
- Arguments:
type (string) – the type of the constant can be number, matrix
value (number|list) – all lists will get merged to a map of float32 arrays, where numbers are one giant float32 array
render_callback (function) – a function that gets called when you call render_constant on the worker
- Returns:
dict – Constant - returns a instance of a Constant consisting of the id and value: {id:number, value:number|map}
- animator.Animator.init()
Initializes the animator and sends all data to the worker. If autostart is true, it also starts the animation. If the animator is already running, it will first stop the animation, reset the animations and then sends the data to the worker.
- animator.Animator.lambda_call(id, args)
Calls a lambda function with the given id and arguments. The lambda function must be added to the animator via the Lambda class, or Animator.Lambda().
- Arguments:
id (number) – The id of the lambda function that should be called.
args (*) – The arguments to pass to the lambda function.
- animator.Animator.removeTrigger(id, target, step, time)
Removes a trigger from the animation with the given id.
- Arguments:
id (number) – the id of the animation to remove the trigger from
target (number) – the target id of the trigger to remove
step (number) – the step at which the trigger to remove should trigger
time (number) – the time at which the trigger to remove should trigger
- animator.Animator.reset_animations(indices)
Reset animations.
- Arguments:
indices (number|Array.<number>) – the index or indices of the animations to reset. If set to “all”, resets all animations.
- animator.Animator.setFPS(fps)
Changes the framerate of the animation thread.
- Arguments:
fps (number) – the new framerate in frames per second
- animator.Animator.start()
Start the animation thread. This will continue any animation that was running before calling stop().
- animator.Animator.start_animations(indices)
Start animations.
- Arguments:
indices (number|Array.<number>) – the index or indices of the animations to start.
- animator.Animator.stop()
Stop the animation thread. This will pause all animations.
- animator.Animator.stop_animations(indices)
Stop animations.
- Arguments:
indices (number|Array.<number>) – the index or indices of the animations to stop. If set to “all”, stops all animations.
- animator.Animator.update_constant(data)
Update multiple constants at once.
- Arguments:
data (Array) – an array of objects containing the following properties: - type: the type of the constant (string) - id: the id of the constant to update (number) - value: the new value of the constant (number or list)
- animator.Animator.update_lerp(data)
Updates the values of the lerp animations. The data is an array of objects with the following properties: - id: The id of the lerp animation that should be updated. - values: The new values of the lerp animation.
- Arguments:
data (Array.<Object>) – An array of objects with the properties id and values.
- animator.Animator.update_matrix_lerp(data)
Updates the matrix lerp animations with new data. Sends a message to the worker to update animations of type 3.
- Arguments:
data (Array.<Object>) – An array of objects with the properties id and values for the matrix lerp animation.
- class animator.Constant(animator, options, type, value, render_callbacks, render_triggers)
Creates a new Constant instance.
- Arguments:
animator (Animator) – the Animator Instance
options (object) – options for the constant
type (string) – the type of the constant can be number, matrix
value (number|list) – all lists will get merged to a map of float32 arrays, where numbers are one giant float32 array
render_callbacks (function|list) – a function or list of functions that gets called when the constant value gets updated
render_triggers (function|list) – a function or list of functions that gets called when the constant value gets updated
- Returns:
dict – Constant - returns a instance of a Constant consisting of the id and value: {id:number, value:number|map} - RenderCallbacks: { id: number, args: string } - RenderTriggers: list(callback_id’s)
- class animator.Lerp(animator, options, render_callback, duration=10, render_interval=1, smoothstep=1, delay=0, animationTriggers, callback, steps, loop=false, steps_max_length)
Creates a new Lerp object.
- Arguments:
animator (Animator) – the animator object
options (Object) – options for the Lerp object
render_callback (function) – the callback function for when the animation is rendered
duration (number) – the duration of the animation in seconds
render_interval (number) – the interval in which the animation is rendered in seconds
smoothstep (number) – the smoothstep value for the animation
delay (number) – the delay before the animation starts
animationTriggers (Array) – the animation triggers
callback.callback (function|string) – the callback function for when the animation is finished
callback.animProps (dict|undefined) – the props used for the callback, when callback is not a string
steps (Array) – the steps of the animation
loop (boolean) – whether or not the animation should loop
steps_max_length (number) – the maximum length of the steps array
- class animator.Matrix_Lerp(animator, options, render_callback, duration=10, render_interval=1, smoothstep=1, delay=0, animationTriggers, callback, steps, loop=false, steps_max_length)
Creates a new MatrixLerp object.
- Arguments:
animator (Animator) – the animator object
options (Object) – options for the MatrixLerp object
render_callback (function) – the callback function for when the animation is rendered
duration (number) – the duration of the animation in seconds
render_interval (number) – the interval in which the animation is rendered in seconds
smoothstep (number) – the smoothstep value for the animation
delay (number) – the delay before the animation starts
animationTriggers (Array) – the animation triggers
callback.callback (function|string) – the callback function for when the animation is finished
callback.animProps (dict|undefined) – the props used for the callback, when callback is not a string
steps (Array) – the steps of the animation
loop (boolean) – whether or not the animation should loop
steps_max_length (number) – the maximum length of the steps array
- class animator.Timeline(animator, options, render_callback, duration=10, render_interval=1, delay=0, animationTriggers, callback, loop=false, length)
Creates a new Timeline object. A Timeline is a type of animation similar to Lerp, but it does not fire a callback after each animation frame. It is used to trigger and control other animations such as timelines, lerps, and matrixLerps.
- Arguments:
animator (Animator) – The animator instance.
options (Object) – Options for the Timeline object.
render_callback (function) – The function called when the animation renders.
duration (Number) – The duration of the animation.
render_interval (Number) – The interval at which the animation should render.
delay (Number) – The delay before the animation starts.
animationTriggers (Object) – Animation triggers.
callback.callback (function|string) – the callback function for when the animation is finished
callback.animProps (dict|undefined) – the props used for the callback, when callback is not a string
loop (Boolean) – Whether the animation should loop.
length (Number) – The amount of steps in the timeline. length of 1 equals steps.length=2. *This is a required parameter if steps is not defined*.
- Returns:
Lerp – The created Timeline object as a Lerp instance.
- class animator.Lambda(animator, callback, animProps)
- Arguments:
animator (Animator) – the Animator Instance
callback (string|function) – the type of the constant can be number, matrix
animProps (dict|undefined) – used to pass your animation properties. * *Only needed if you pass a function as a callback.* * The used props need to have this structure: `${prop}`
- Returns:
number – id - animator.lambda_map.size