util.easing.linear

Shared

Returns the progress value unchanged — a straight-line curve from 0 to 1


Syntax

local result = util.easing.linear(
    progress
)

util.easing.linear applies no easing — the output equals the input.

  • Constant speed — motion starts and ends at the same speed with no acceleration or deceleration.
  • Best for — mechanical or technical motion where a consistent rate of change is required.

Parameters

TypeNameDescription
floatprogressInterpolation factor, typically in the range [0, 1]

Returns

TypeNameDescription
floatresultThe same value as progress

Examples

Linear easing returns progress unchanged
core.engine.print("info", util.easing.linear(0.0))  -- 0.0
core.engine.print("info", util.easing.linear(0.25)) -- 0.25
core.engine.print("info", util.easing.linear(0.5))  -- 0.5
core.engine.print("info", util.easing.linear(0.75)) -- 0.75
core.engine.print("info", util.easing.linear(1.0))  -- 1.0
Animate a value at constant speed
local resolution = core.engine.get_resolution()
local duration = 2.0
local start_tick = core.engine.get_tick()

util.event.on("sandbox:draw", function()
    local elapsed = (core.engine.get_tick() - start_tick) / 1000.0
    local t = math.min(elapsed / duration, 1.0)
    local x = util.easing.lerp(0, resolution[1], util.easing.linear(t))

    core.engine.draw_circle({x, resolution[2]*0.5}, 16, {1, 1, 1, 1})
end)

On this page