Summary

Functions

Creates a tween, which gradually changes numeric fields of a table toward their target values.

Functions

tween.new(duration, subject, target, easing)

shared packages/tween/lib/tween.lua:379

Creates a tween, which gradually changes numeric fields of a table toward their target values. The tween only progresses when its update method is called.

local logo_data = { width = 512, height = 256 }
local logo_tween = Tween.new(1.5, logo_data, { width = 256, height = 128 }, 'inOutCubic')

function PANEL:Paint(w, h)
  logo_tween:update(FrameTime())
  draw.RoundedBox(0, 0, 0, logo_data.width, logo_data.height, color_white)
end

Parameters

  • duration Number how long the tween takes, must be positive
  • subject Map table (or userdata) whose fields are changed
  • target Map final values of the fields to change, which have to be numbers or nested tables of numbers
  • easing String/Function optional, defaults to 'linear' name of an easing function from Tween.easing (e.g. 'inOutCubic'), or a custom easing function

Returns

  • Map tween object with the set, reset and update methods

Defined in