Skip to main content

Interpolation

The interpolator registry, keyed by value type. Linear interpolation ships for number, Vector2, Vector3, CFrame, Color3, UDim, UDim2, NumberRange, and Rect. Any other type is stepped: the earlier keyframe's value holds until the next keyframe.

A custom value type registers its interpolator here:

Flow.Interpolation.Register("NumberSequence", function(a, b, alpha)
	-- ...
end)

Types​

Interpolator​

type Interpolator = (
a: any,
b: any,
alpha: number
) → any

Returns the value alpha of the way from a to b. alpha is usually 0-1, but an overshooting keyframe curve can pass values outside that range.

Functions​

Register​

Interpolation.Register(
typeName: string,
interpolator: Interpolator
) → ()

Registers the interpolator for a typeof name, replacing any existing one.

Get​

Interpolation.Get(typeName: string) → Interpolator?

RegisterComponents​

Interpolation.RegisterComponents(
typeName: string,
components: {string},
blend: (
a: any,
b: any,
alphas: {[string]: number}
) → any
) → ()

Registers a blender that takes a separate alpha per named component, so a keyframe curve can address each component on its own. components lists them in display order.

GetComponentBlender​

Interpolation.GetComponentBlender(typeName: string) → ComponentBlender?

Returns the component blender registered for typeName, if any.

IsInterpolatable​

Interpolation.IsInterpolatable(value: any) → boolean

Whether value's type has a registered interpolator.

Interpolate​

Interpolation.Interpolate(
a: any,
b: any,
alpha: number
) → any

Interpolates between two values. Types without a registered interpolator are stepped: a holds until alpha reaches 1.

Show raw api
{
    "functions": [
        {
            "name": "Register",
            "desc": "Registers the interpolator for a `typeof` name, replacing any existing one.",
            "params": [
                {
                    "name": "typeName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "interpolator",
                    "desc": "",
                    "lua_type": "Interpolator"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 65,
                "path": "runtime/Interpolation.luau"
            }
        },
        {
            "name": "Get",
            "desc": "",
            "params": [
                {
                    "name": "typeName",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Interpolator?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 72,
                "path": "runtime/Interpolation.luau"
            }
        },
        {
            "name": "RegisterComponents",
            "desc": "Registers a blender that takes a separate alpha per named component, so a keyframe curve can address\neach component on its own. `components` lists them in display order.",
            "params": [
                {
                    "name": "typeName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "components",
                    "desc": "",
                    "lua_type": "{ string }"
                },
                {
                    "name": "blend",
                    "desc": "",
                    "lua_type": "(a: any, b: any, alphas: { [string]: number }) -> any\n"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 81,
                "path": "runtime/Interpolation.luau"
            }
        },
        {
            "name": "GetComponentBlender",
            "desc": "Returns the component blender registered for `typeName`, if any.",
            "params": [
                {
                    "name": "typeName",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ComponentBlender?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 93,
                "path": "runtime/Interpolation.luau"
            }
        },
        {
            "name": "IsInterpolatable",
            "desc": "Whether `value`'s type has a registered interpolator.",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 101,
                "path": "runtime/Interpolation.luau"
            }
        },
        {
            "name": "Interpolate",
            "desc": "Interpolates between two values. Types without a registered interpolator are stepped: `a` holds until\n`alpha` reaches 1.",
            "params": [
                {
                    "name": "a",
                    "desc": "",
                    "lua_type": "any"
                },
                {
                    "name": "b",
                    "desc": "",
                    "lua_type": "any"
                },
                {
                    "name": "alpha",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "any\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 110,
                "path": "runtime/Interpolation.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "Interpolator",
            "desc": "Returns the value `alpha` of the way from `a` to `b`. `alpha` is usually 0-1, but an overshooting keyframe\ncurve can pass values outside that range.",
            "lua_type": "(a: any, b: any, alpha: number) -> any",
            "source": {
                "line": 40,
                "path": "runtime/Interpolation.luau"
            }
        }
    ],
    "name": "Interpolation",
    "desc": "The interpolator registry, keyed by value type. Linear interpolation ships for `number`, `Vector2`,\n`Vector3`, `CFrame`, `Color3`, `UDim`, `UDim2`, `NumberRange`, and `Rect`. Any other type is stepped: the\nearlier keyframe's value holds until the next keyframe.\n\nA custom value type registers its interpolator here:\n\n```lua\nFlow.Interpolation.Register(\"NumberSequence\", function(a, b, alpha)\n\t-- ...\nend)\n```",
    "source": {
        "line": 30,
        "path": "runtime/Interpolation.luau"
    }
}