Skip to main content

Rive Interpolator API

Use this reference to look up the Interpolator<T> callback signatures and fallback rules for custom easing in Rive Luau. For a worked quadratic ease-in, value table and exercise, follow the custom easing lesson.

Runtime baseline

This page reflects released Web 2.42.1 -> C++ runtime-v0.1.384, with source pins tracked in Runtime Compatibility Baseline.


Interpolator and the runtime class​

Interpolator<T> is the Luau interface name in the official Rive reference. ScriptedInterpolator names the underlying C++ runtime class; use Interpolator<MyType> in a script factory's return annotation.

The shape below documents the accepted runtime's optional-callback behavior. The public interface documentation lists transform and transformValue as required; the example defines both. Runtime fallback support does not establish an editor attachment workflow.

Callback contract​

export type Interpolator<T> = {
init: ((self: T, context: Context) -> boolean)?,
transform: ((self: T, factor: number) -> number)?,
transformValue: ((self: T, valueFrom: number, valueTo: number, factor: number) -> number)?,
} & T

Methods​

transform(self, factor)​

Remaps an interpolation factor and returns a number. The example clamps the factor to 0–1 before easing; this clamp belongs to the example, not the callback signature.

transform(self: T, factor: number): number

transformValue(self, valueFrom, valueTo, factor)​

Returns the blended value for valueFrom, valueTo and factor. The example explicitly calls transform here; implementing transform alone does not change this callback's missing-method fallback.

transformValue(self: T, valueFrom: number, valueTo: number, factor: number): number

Runtime fallback behavior​

The pinned runtime implementation provides these fallbacks when a callback is absent or its call fails:

  • transform falls back to the input factor unchanged.
  • transformValue falls back to linear interpolation (from + (to - from) * factor).

Example​

export type EaseInOut = {
strength: Input<number>,
}

local function smoothstep(t: number): number
return t * t * (3 - 2 * t)
end

function transform(self: EaseInOut, factor: number): number
local t = math.max(0, math.min(1, factor))
return smoothstep(t)
end

function transformValue(self: EaseInOut, valueFrom: number, valueTo: number, factor: number): number
local t = transform(self, factor)
return valueFrom + (valueTo - valueFrom) * t
end

return function(): Interpolator<EaseInOut>
return {
transform = transform,
transformValue = transformValue,
strength = 1,
}
end