Module: Tween::Elastic::Out

Defined in:
lib/tween.rb

Class Method Summary collapse

Class Method Details

.ease(t, st, ch, d, a = 0.1, p = 0) ⇒ Object



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/tween.rb', line 325

def self.ease(t, st, ch, d, a = 0.1, p = 0)
  s = 0
  
  if t == 0
    return st
  elsif (t /= d.to_f) >= 1
    return st + ch
  end
  
  p = d * 0.3 if p == 0
  
  if (a == 0) || (a < ch.abs)
    a = ch
    s = p / 4.0
  else
    s = p / (2 * Math::PI) * Math.asin(ch / a.to_f)
  end
  
  a * (2 ** (-10 * t)) * Math.sin((t * d - s) * (2 * Math::PI) / p.to_f) + ch + st
end