How can I convert this Ruby Code to JS?

Hey guys I had a Linear code where Galenmereth helped me to create for doing lineart movement more "easily" in Ace...

Now though I want to convert it to MV but I don't know how to properly convert it to JS

here the code

#---------------------------------------------------------------------------- # ○ new method: lineart #---------------------------------------------------------------------------- # * t = Current time (frame) # * b = Start value # * c = Target value # * d = Duration total (frames) # * Returns: Value modified by t def lineart(t, b, c, d) return c*t/d.to_f + b end thanks for any further answer 🙂
It's pretty much exactly the same.

Code:
Class_Name.prototype.lineart = function(t, b, c, d) {  return c * t / d + b;}
You don't need to_f because JS uses floats by default, and both the old and the new would return a float. The only thing you left out was what class this method belongs to.
It's pretty much exactly the same.

Class_Name.prototype.lineart = function(t, b, c, d) { return c * t / d + b;}You don't need to_f because JS uses floats by default, and both the old and the new would return a float. The only thing you left out was what class this method belongs to.
thanks shaz yeah well this method will be had directly to my Extended sprite class thanks for your answer 🙂
in regards to more complicated ruby code I wouldn't.  I would just re-write it from scratch There are tools out there to do this how ever the code they produce is often un readable and unmaintainable.
in regards to more complicated ruby code I wouldn't.  I would just re-write it from scratch There are tools out there to do this how ever the code they produce is often un readable and unmaintainable.
I approve although this little line's of code do the same's job both in Ruby in JS so no need to rewrite everything's lol

the only big difference would be is I don't need to convert to float
In this case, it's one of Robert Penner's easing functions, which have been translated in a whole bunch of languages, so you could just google for them ^^

Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-convert-this-ruby-code-to-js.52413/