Module: Moon::Easing::ElasticOut

Defined in:
lib/moon/packages/std/animation/easing.rb

Class Method Summary collapse

Class Method Details

.call(k) ⇒ Object


185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/moon/packages/std/animation/easing.rb', line 185

def self.call(k)
  s = nil
  a = 0.1
  p = 0.4
  if k == 0
    0
  elsif k == 1
    1
  end

  if a == 0 || a < 1
    a = 1
    s = p / 4
  else
    s = p * Math.asin(1 / a) / (2 * Math::PI)
  end
  (a * (2 ** (-10 * k)) * Math.sin((k - s) * (2 * Math::PI) / p) + 1)
end