Sha256: f5d34b61ef3968c6e587079b76524af9a1d756246b1a195268fe0b79c4cc7f76

Contents?: true

Size: 845 Bytes

Versions: 4

Compression:

Stored size: 845 Bytes

Contents

module Tsuku
  class Easing
    class << self
      def linear(t, b, c, d)
        c * t / d + b
      end

      def ease_in_quad(t, b, c, d)
        t /= d
        c * t * t + b
      end

      def ease_out_quad(t, b, c, d)
        t /= d
        -c * t * (t - 2) + b
      end

      def ease_in_out_quad(t, b, c, d)
        t /= d / 2
        return c / 2 * t * t + b if t < 1
        t -= 1
        -c / 2 * (t * (t - 2) - 1) + b
      end

      def ease_in_cubic(t, b, c, d)
        t /= d
        return c * t * t * t + b
      end

      def ease_out_cubic(t, b, c, d)
        t /= d
        t -= 1
        c * (t * t * t + 1) + b
      end

      def ease_in_out_cubic(t, b, c, d)
        t /= (d / 2)
        return c / 2 * t * t * t + b if t < 1
        t -= 2
        return c / 2 * (t * t * t + 2) + b
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tsuku-0.2.0 lib/tsuku/easing.rb
tsuku-0.1.2 lib/tsuku/easing.rb
tsuku-0.1.1 lib/tsuku/easing.rb
tsuku-0.1.0 lib/tsuku/easing.rb