Easing
- class arcade.anim.easing.EasingFunction(*args, **kwargs)[source]
Bases:
ProtocolAny
callable()object which maps linear completion to a curve.If the built-in easing curves are not enough, you can define your own. Functions should match this pattern:
def f(t: float) -> t: ...
For advanced users, any object with a matching
__call__()method can be passed as an easing function.
- class arcade.anim.easing.Interpolatable(*args, **kwargs)[source]
Bases:
ProtocolMatches types with support for the following operations:
Method
Summary
Multiplication by a scalar
Addition
Subtraction
Important
The
pyglet.mathmatrix types are currently unsupported.Although vector types work, matrix multiplication is subtly different. It uses a separate
__matmul__()operator for multiplication.
- class arcade.anim.Easing[source]
Bases:
Built-in easing functions as static methods.
Each takes the following form:
def f(t: float) -> float: ...
Pass them into
ease()via thefunckeyword argument:from arcade.anim import ease, Easing value = ease( 1.0, 2.0, 2.0, 3.0, 2.4, func=Easing.SINE_IN)
- arcade.anim.norm(x: float, start: float, end: float) float[source]
Convert
xto a progress ratio fromstarttoend.The result will be a value normalized to between
0.0and1.0ifxis betweenstartandend`. It is not clamped, so the result may be less than ``0.0orgreater than ``1.0.- Parameters:
x – A value between
startandend.start – The start of the range.
end – The end of the range.
- Returns:
A range completion progress as a
float.
- arcade.anim.lerp(progress: float, minimum: A, maximum: A) A[source]
Get
progressof the way from``minimum`` tomaximum.- Parameters:
progress – How far from
minimumtomaximumto go from0.0to1.0.minimum – The start value along the path.
maximum – The maximum value along the path.
- Returns:
A value
progressof the way fromminimumtomaximum.
- arcade.anim.ease(minimum: A, maximum: A, start: float, end: float, t: float, func: EasingFunction = <function Easing.LINEAR>, clamped: bool = True) A[source]
Ease a value according to a curve function passed as
func.Override the default easing curve by passing any
EasingorEasingFunctionof your choice.The
maximumandminimummust be of compatible types. For example, these can include:Type
Value Example
Explanation
0.5Numbers such as volume or brightness.
Vec2(500.0, 200.0)A
pyglet.mathvector representing position.- Parameters:
minimum – any math-like object (a position, scale, value…); the “start position.”
maximum – any math-like object (a position, scale, value…); the “end position.”
start – a
floatdefining where progression begins, the “start time.”end – a
floatdefining where progression ends, the “end time.”t – a
floatdefining the current progression, the “current time.”func – Defaults to
Easing.LINEAR, but you can pass anEasingorEasingFunctionof your choice.clamped – Whether the value will be clamped to
minimumandmaximum.
- Returns:
An eased value for the given time
t.