[suggestion] Curve-Bezier
pablomayobre opened this issue · 3 comments
In CSS there are not many easing curves, 5 or so. Instead it is pretty normal to use Bezier Curves to descrive a easing curve.
Bezier Curves were added to LÖVE in 0.9.0 in the love.math module (see love.math.newBezierCurve)
So I thought this would be easy to implement, and so it is! Here is my little implementation:
cubicbezier = function (x1, y1, x2, y2)
local curve = love.math.newBezierCurve(0, 0, x1, y1, x2, y2, 1, 1)
return function (t, b, c, d) return c * curve:evaluate(t/d) + b end
end
The usage with tween.lua is simple:
local label = { x=200, y=0, text = "hello" }
local labelTween = tween.new(4, label, {y=300}, cubicbezier(.35, .97, .58, .61))
I know and understand that tween.lua is not a LÖVE library but a Lua library in general, but it will be nice if this possibility would be at least documented somewhere (since it is pretty simple and nice)
PS: If you dont know what those freaking numbers are (as I was also confused at first), check this
Hi again,
The easing functions are not limited to the ones present in tween.easing
. If you pass a function as easing parameter (instead of a string), it will be used by the tween directly.
I don't know love.math.newBezierCurve
in order to know how to do it, but I am sure it is possible. Please give it a try and reopen this issue if you need more help (I would also appreciate it if you could add a comment with an example if you manage to do it)
Regards, and happy new year!
The code up there actually works perfectly I just wanted to point this out for future referente, cause other users may find it useful.
Sorry, this is not actually a suggestion I guess, more like a note that you can implement curve bezier into tween.lua this easily
Thanks for your work Kikito, tour libs are always amazing and super useful
This is what happens when I read issues the day after new year's eve :)
I have added a new section to the Readme for custom functions and I have included your example. Thanks a lot! ^^