Creative ways to code this

I want to make an square that follows the mouse in a smoothly way, something like the ‘lerp’ function you can find on Construct 2:

local centerX, centerY = display.contentCenterX, display.contentCenterY local mySquare = display.newRoundedRect( centerX, centerY, 64, 64, 16 ) local moving = false local function onTouch(event) if (mySquare.x ~= event.x and mySquare.y ~= event.y and moving == false) then moving = true local myEasing = transition.to(mySquare, {x = event.x, y = event.y, time = 75, transition = easing.OutQuad, onComplete = function() moving = false end}) end end Runtime:addEventListener("touch", onTouch)

Any ideas? Show me your best code!