Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit3bb1da2647

README.md

easing

30+ easing functions — pure math, zero allocations. Each easing function takes a normalized t in [0, 1] and returns the eased value. Used by the tween core to shape interpolation curves. User code normally reaches these via tween.easing.<name> or by passing the name as a string to tween.to / tween.fromTo.

Exports

Easing curves ((t: number) -> number):

  • Linear: Easing.linear.
  • Polynomial: Easing.{in, out, inOut}{Quad, Cubic, Quart, Quint}.
  • Trig: Easing.{in, out, inOut}Sine.
  • Exp / circ: Easing.{in, out, inOut}{Expo, Circ}.
  • Overshoots / oscillations: Easing.{in, out, inOut}{Elastic, Back, Bounce}.

Name lookup:

  • Easing.resolve(easing: string | EasingFn) -> EasingFn — name (case-insensitive, optional ease prefix) or function in, easing function out. Raises on unknown name.
  • Easing.list() -> { string } — canonical camelCase names for UI / picker use.

Types:

  • EasingFn = (number) -> number — every easing function's shape.

Usage

-- Via the tween namespace (most common):
tween.to(id, "scale", target, 0.6, "easeInOutCubic")

-- Direct lookup:
local fn = tween.easing.resolve("outElastic")
local v = fn(0.5)

-- Custom curve passed directly:
tween.to(id, "tint", colour, 0.4, function(t) return 1 - (1 - t) ^ 4 end)

-- Enumerate names:
for _, name in ipairs(tween.easings()) do
    print(name)
end

Notes

  • Easing.resolve is permissive about casing: inQuad, easeInQuad, easeinquad, INQUAD all map to the same function. The aliases "ease" and "none" map to linear.
  • Functions are pure and stateless — safe to call any number of times per frame, no caching needed.
  • outBounce is implemented as the canonical four-piece piecewise quadratic from the standard easing references; inBounce and inOutBounce are derived from it via mirror / fold.
  • inElastic / outElastic use the standard c4 = 2π/3 constant for one-bounce overshoot; the inOut variant uses c5 = 2π/4.5 for the shorter half-period.