-- Tweening functions
--
-- t = Time
-- b = Starting value
-- c = Change in value
-- d = Duration

function linear(t, b, c, d)
    return c * t/d + b
end

function ease_in_quad(t, b, c, d)
    t = t / d
    return c * t * t + b
end

function ease_out_quad(t, b, c, d)
    t = t / d
    return -c * t * (t-2) + b
end

function ease_in_out_quad(t, b, c, d)
    t = t / (d/2)
    if t < 1 then
        return c/2 * t * t + b
    else
        t = t - 1
        return -c/2 * (t * (t-2) - 1) + b
    end
end

function ease_in_cubic(t, b, c, d)
    return c * math.pow(t/d, 3) + b
end
function ease_out_cubic(t, b, c, d)
    return c * (math.pow(t/d-1, 3)+1) + b
end
function ease_in_out_cubic(t, b, c, d)
    t = t / (d/2)
    if t < 1 then
        return c/2 * math.pow(t, 3) + b
    else
        return c/2 * (math.pow(t-2, 3) + 2) + b
    end
end

function ease_in_sine(t, b, c, d)
    return c * (1 - math.cos(t/d * (math.pi/2))) + b
end
function ease_out_sine(t, b, c, d)
    return c * math.sin(t/d * (math.pi/2)) + b
end
function ease_in_out_sine(t, b, c, d)
    return c/2 * (1 - math.cos(math.pi * t/d)) + b
end