Margrete RPC
Advanced

Easings

Easings describe how a value moves from 0 to 1 across a time range.

from margrete_rpc.chart.util import Curve, timing_easing

slide = Curve(t=(0, 0), x=0).to(t=(1, 0), x=12, ease_x="in_out_sine").to_slide(w=4)

speed_events = timing_easing(
    t0=(4, 0),
    t1=(8, 0),
    start_speed=0.5,
    end_speed=2.0,
    count=16,
    easing="out_cubic",
)

Which name to use

Each easing family has three directions:

DirectionMeaning
in_*Starts slowly and changes more near the end.
out_*Changes quickly first and slows near the end.
in_out_*Starts slowly, moves faster in the middle, then slows again.

Common choices:

NameGood for
linearConstant movement or equal speed steps.
in_quadA simple acceleration into the target.
out_quadA simple deceleration into the target.
in_out_sineSmooth, natural movement between two points.
out_cubicA stronger ease-out than out_quad.
in_out_expoA dramatic slow-fast-slow movement.

Built-in names

FamilyNames
Linearlinear
Sinein_sine, out_sine, in_out_sine
Quadin_quad, out_quad, in_out_quad
Cubicin_cubic, out_cubic, in_out_cubic
Quartin_quart, out_quart, in_out_quart
Quintin_quint, out_quint, in_out_quint
Expoin_expo, out_expo, in_out_expo
Circin_circ, out_circ, in_out_circ

Custom easings

Anywhere an easing name is accepted, you can also pass an Easing object or a callable from 0..1 to 0..1.

import math
from margrete_rpc.chart.util import Curve

def stepped_4(t: float) -> float:
    return math.floor(t * 4) / 4 if t < 1 else 1.0

slide = (
    Curve(t=(0, 0), x=0)
    .to(t=(1, 0), x=12, ease_x=stepped_4)
    .to_slide(w=4)
)

Custom easings should usually return 0 at input 0 and 1 at input 1. That keeps generated curves and speed ramps landing exactly on their start and end values.

On this page