Builtin Library
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, optionaleaseprefix) 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.resolveis permissive about casing:inQuad,easeInQuad,easeinquad,INQUADall 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.
outBounceis implemented as the canonical four-piece piecewise quadratic from the standard easing references;inBounceandinOutBounceare derived from it via mirror / fold.inElastic/outElasticuse the standardc4 = 2π/3constant for one-bounce overshoot; the inOut variant usesc5 = 2π/4.5for the shorter half-period.