Module: Tween::Elastic::In

Defined in:
lib/tween.rb

Class Method Summary collapse

Class Method Details

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



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/tween.rb', line 302

def self.ease(t, st, ch, d, a = 5, 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 -= 1))) * Math.sin( (t * d - s) * (2 * Math::PI) / p)) + st
end