Easing

class arcade.anim.easing.EasingFunction(*args, **kwargs)[source]

Bases: Protocol

Any callable() object which maps linear completion to a curve.

Tip

See Easing for the most common easings.

Pass them to ease() via the func keyword argument.

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: Protocol

Matches types with support for the following operations:

Method

Summary

__mul__()

Multiplication by a scalar

__add__()

Addition

__sub__()

Subtraction

Important

The pyglet.math matrix 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 the func keyword argument:

from arcade.anim import ease, Easing

value = ease(
  1.0, 2.0,
  2.0, 3.0,
  2.4,
  func=Easing.SINE_IN)
static BACK(t: float) float[source]

http://easings.net/#easeInOutBack

static BACK_IN(t: float) float[source]

http://easings.net/#easeInBack

static BACK_IN_OUT(t: float) float

http://easings.net/#easeInOutBack

static BACK_OUT(t: float) float[source]

http://easings.net/#easeOutBack

static BOUNCE(t: float) float[source]

http://easings.net/#easeInOutBounce

static BOUNCE_IN(t: float) float[source]

http://easings.net/#easeInBounce

static BOUNCE_IN_OUT(t: float) float

http://easings.net/#easeInOutBounce

static BOUNCE_OUT(t: float) float[source]

http://easings.net/#easeOutBounce

static CIRC(t: float) float[source]

http://easings.net/#easeInOutCirc

static CIRC_IN(t: float) float[source]

http://easings.net/#easeInCirc

static CIRC_IN_OUT(t: float) float

http://easings.net/#easeInOutCirc

static CIRC_OUT(t: float) float[source]

http://easings.net/#easeOutCirc

static CUBIC(t: float) float[source]

http://easings.net/#easeInOutCubic

static CUBIC_IN(t: float) float[source]

http://easings.net/#easeInCubic

static CUBIC_IN_OUT(t: float) float

http://easings.net/#easeInOutCubic

static CUBIC_OUT(t: float) float[source]

http://easings.net/#easeOutCubic

static ELASTIC(t: float) float[source]

http://easings.net/#easeInOutElastic

static ELASTIC_IN(t: float) float[source]

http://easings.net/#easeInElastic

static ELASTIC_IN_OUT(t: float) float

http://easings.net/#easeInOutElastic

static ELASTIC_OUT(t: float) float[source]

http://easings.net/#easeOutElastic

static EXPO(t: float) float[source]

http://easings.net/#easeInOutExpo

static EXPO_IN(t: float) float[source]

http://easings.net/#easeInExpo

static EXPO_IN_OUT(t: float) float

http://easings.net/#easeInOutExpo

static EXPO_OUT(t: float) float[source]

http://easings.net/#easeOutExpo

static LINEAR(t: float) float[source]

Essentially the ‘null’ case for easing. Does no easing.

static QUAD(t: float) float[source]

http://easings.net/#easeInOutQuad

static QUAD_IN(t: float) float[source]

http://easings.net/#easeInQuad

static QUAD_IN_OUT(t: float) float

http://easings.net/#easeInOutQuad

static QUAD_OUT(t: float) float[source]

http://easings.net/#easeOutQuad

static QUART(t: float) float[source]

http://easings.net/#easeInOutQuart

static QUART_IN(t: float) float[source]

http://easings.net/#easeInQuart

static QUART_IN_OUT(t: float) float

http://easings.net/#easeInOutQuart

static QUART_OUT(t: float) float[source]

http://easings.net/#easeOutQuart

static QUINT(t: float) float[source]

http://easings.net/#easeInOutQint

static QUINT_IN(t: float) float[source]

http://easings.net/#easeInQint

static QUINT_IN_OUT(t: float) float

http://easings.net/#easeInOutQint

static QUINT_OUT(t: float) float[source]

http://easings.net/#easeOutQint

static SINE(t: float) float[source]

http://easings.net/#easeInOutSine

static SINE_IN(t: float) float[source]

http://easings.net/#easeInSine

static SINE_IN_OUT(t: float) float

http://easings.net/#easeInOutSine

static SINE_OUT(t: float) float[source]

http://easings.net/#easeOutSine

arcade.anim.norm(x: float, start: float, end: float) float[source]

Convert x to a progress ratio from start to end.

The result will be a value normalized to between 0.0 and 1.0 if x is between start and end`. It is not clamped, so the result may be less than ``0.0 or greater than ``1.0.

Parameters:
  • x – A value between start and end.

  • 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 progress of the way from``minimum`` to maximum.

Parameters:
  • progress – How far from minimum to maximum to go from 0.0 to 1.0.

  • minimum – The start value along the path.

  • maximum – The maximum value along the path.

Returns:

A value progress of the way from minimum to maximum.

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 Easing or EasingFunction of your choice.

The maximum and minimum must be of compatible types. For example, these can include:

Type

Value Example

Explanation

float

0.5

Numbers such as volume or brightness.

Vec2

Vec2(500.0, 200.0)

A pyglet.math vector 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 float defining where progression begins, the “start time.”

  • end – a float defining where progression ends, the “end time.”

  • t – a float defining the current progression, the “current time.”

  • func – Defaults to Easing.LINEAR, but you can pass an Easing or EasingFunction of your choice.

  • clamped – Whether the value will be clamped to minimum and maximum.

Returns:

An eased value for the given time t.