Easing curves¶
Cubic bezier curves for animating values, like CSS cubic-bezier.
Functions¶
Balltze.createBezierCurve¶
Balltze.createBezierCurve(x1, y1, x2, y2)
Balltze.createBezierCurve(preset)
Creates a curve that goes from (0, 0) to (1, 1) with the control points (x1, y1) and
(x2, y2). x1 and x2 must be between 0 and 1; y1 and y2 can go outside that range to
overshoot.
preset is one of "linear", "ease in", "ease out" or "ease in out".
Returns a BalltzeBezierCurve.
BalltzeBezierCurve:getPoint¶
curve:getPoint(initialValue, finalValue, t, reverse)
Returns the value between initialValue and finalValue at progress t, eased by the curve.
t goes from 0 to 1 and is clamped to that range. With reverse set to true, the curve is
evaluated from its end. Default is false.
Example¶
-- Zoom the camera in over half a second.
local curve = Balltze.createBezierCurve("ease out")
local start = os.clock()
Balltze.addEventListener("frame", function()
local t = (os.clock() - start) / 0.5
Engine.camera.setZoom(curve:getPoint(1, 3, t))
end)