Easing¶
keyed.easing
¶
Easing functions.
EasingFunctionT
module-attribute
¶
Type alias for easing functions.
Functions should take a normalized time parameter, t, and return a value determining animation progress.
Typically, f(0) = 0 and f(1) = 1.
in_out
module-attribute
¶
in_out = compose_easing
easing_function
¶
Create a reactive easing function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start
|
int
|
Starting frame |
required |
end
|
int
|
Ending Frame |
required |
ease
|
EasingFunctionT
|
Easing function |
required |
frame
|
ReactiveValue[int]
|
The frame counter, as a reactive value. |
required |
Returns:
Type | Description |
---|---|
Computed[float]
|
Easing function as a reactive value. |
Source code in src/keyed/easing.py
linear_in_out
¶
quad_in_out
¶
quad_in
¶
quad_out
¶
cubic_in
¶
cubic_out
¶
cubic_in_out
¶
quartic_in
¶
quartic_out
¶
quartic_in_out
¶
quintic_in
¶
quintic_out
¶
quintic_in_out
¶
sine_in
¶
sine_out
¶
sine_in_out
¶
circular_in
¶
circular_out
¶
circular_in_out
¶
Ease in and out according to a circular function.
expo_in
¶
expo_out
¶
expo_in_out
¶
Ease in and out according to an exponential function.
Source code in src/keyed/easing.py
elastic_in
¶
elastic_out
¶
elastic_in_out
¶
Ease in and out like an elastic band.
Source code in src/keyed/easing.py
back_in
¶
back_out
¶
back_in_out
¶
Ease in and out by overshooting slightly.
Source code in src/keyed/easing.py
bounce_in
¶
bounce_out
¶
Ease out by bouncing.
Source code in src/keyed/easing.py
bounce_in_out
¶
discretize
¶
Create a discretized version of the given easing function with n steps.
This will still need to be made "reactive" by calling easing_function(...)
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
easing_func
|
EasingFunctionT
|
The easing function to discretize. |
required |
n
|
int
|
The number of discrete steps. |
10
|
Returns:
Type | Description |
---|---|
EasingFunctionT
|
The discretized easing function. |
Source code in src/keyed/easing.py
compose_easing
¶
Create a composite easing function that uses one easing for the first half and another for the second half.
Note
Composite easing functions will almost surely not be smooth at t = 0.5
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ease_in
|
EasingFunctionT
|
The easing function to use for t < 0.5 |
required |
ease_out
|
EasingFunctionT
|
The easing function to use for t >= 0.5 |
required |
Returns:
Type | Description |
---|---|
EasingFunctionT
|
A new easing function that combines both input functions |
Example
Source code in src/keyed/easing.py
mix_easing
¶
Create an easing function that is a weighted mix of two easing functions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ease1
|
EasingFunctionT
|
First easing function |
required |
ease2
|
EasingFunctionT
|
Second easing function |
required |
mix
|
float
|
Mix factor between 0 and 1. 0 means all ease1, 1 means all ease2. |
0.5
|
Returns:
Type | Description |
---|---|
EasingFunctionT
|
A new easing function that mixes both input functions |