Module: Moon::Easing::ElasticIn

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

Class Method Summary collapse

Class Method Details

.call(k) ⇒ Object


165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/moon/packages/std/animation/easing.rb', line 165

def self.call(k)
  s = nil
  a = 0.1
  p = 0.4
  if (k == 0)
    0
  elsif (k == 1)
    1
  end
  if (!a || a < 1)
    a = 1
    s = p / 4
  else
    s = p * Math.asin(1 / a) / (2 * Math::PI)
  end
  -(a * (2 ** (10 * (k -= 1))) * Math.sin((k - s) * (2 * Math::PI) / p))
end