ó
X–Tc           @   sî   d  Z  d d l Z d d d „ Z d d d „ Z d d d „ Z d d d „ Z d d d	 „ Z d d d
 „ Z d d d „ Z d d „ Z	 d d d e j
 d „ Z d d d „ Z d d d d e j
 d „ Z d d „  d d e j
 d „ Z d S(   sa  
This module provides a set of built-in easings which can be used by any 
game. Additionally, custom easings can be built. An easing should be a 
function (or callable) which takes in a sprite, and a time delta which 
is normalized to [0,1], and returns the state of easing at that time. 
See the source code of this module for some example implementations. 
Built-in easings are stateless, so the same animation can be used many 
times or on many different objects. Custom easings do not have to be 
stateless. 

Visualizations of these easings are available at 
`http://easings.net <http://easings.net>`_ .
iÿÿÿÿNg        g      ð?c            s   ‡  ‡ f d †  } | S(   s'   
    Linearly increasing: f(x) = x
    c            s   ˆ  ˆ | ˆ S(   N(    (   t   spritet   delta(   t   finisht   start(    s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   linear_easing   s    (    (   R   R   R   (    (   R   R   s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   Linear   s    c            s   ‡  ‡ f d †  } | S(   s@   
    Quadratically increasing, starts slower : f(x) = x ^ 2
    c            s   ˆ ˆ  ˆ | | S(   N(    (   R    R   (   R   R   (    s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   quadratic_easing   s    (    (   R   R   R   (    (   R   R   s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   QuadraticIn   s    c            s   ‡  ‡ f d †  } | S(   sC   
    Quadratically increasing, starts faster : f(x) = 2x - x^2
    c            s   ˆ ˆ  ˆ d | | | S(   Ng       @(    (   R    R   (   R   R   (    s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   quadratic_out_easing'   s    (    (   R   R   R   (    (   R   R   s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   QuadraticOut#   s    c            s   ‡  ‡ f d †  } | S(   sR   
    Quadratically increasing, starts and ends slowly but fast in the middle.
    c            sX   | d 9} | d k  r. ˆ d | | ˆ  ˆ S| d 8} ˆ | d | | d ˆ  ˆ S(   Ni   i   g      à?(    (   R    R   (   R   R   (    s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   quadratic_in_out_easing0   s
    

(    (   R   R   R
   (    (   R   R   s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   QuadraticInOut,   s    c            s   ‡  ‡ f d †  } | S(   s=   
    Cubically increasing, starts very slow : f(x) = x^3
    c            s   ˆ | | | ˆ  ˆ S(   N(    (   R    R   (   R   R   (    s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   cubic_in_easing=   s    (    (   R   R   R   (    (   R   R   s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   CubicIn9   s    c            s   ‡  ‡ f d †  } | S(   sE   
    Cubically increasing, starts very fast : f(x) = 1 + (x-1)^3
    c            s&   | d 8} ˆ | | | d ˆ  ˆ S(   Ng      ð?(    (   R    R   (   R   R   (    s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   cubic_out_easingF   s    
(    (   R   R   R   (    (   R   R   s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   CubicOutB   s    gš™™™™™¹?c            s   ‡  ‡ f d †  } | S(   s\   
    Cubically increasing, starts and ends very slowly but very fast in the
    middle.
    c            s`   | d 9} | d k  r2 ˆ d | | | ˆ  ˆ S| d 8} d d | | | ˆ  ˆ d ˆ S(   Ng       @g      ð?g      à?(    (   R    R   (   R   R   (    s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   cubic_in_out_easingQ   s    

(    (   R   R   R   (    (   R   R   s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt
   CubicInOutL   s    i   c            s   ‡  ‡ f d †  } | S(   s   
    Iterate over a list of items. This particular easing is very useful
    for creating image animations, e.g.::
    
        walk_images = [spyral.Image('f1.png'), spyral.Image('f2.png'), spyral.Image('f3.png')]
        walking_animation = Animation('image', easing.Iterate(walk_images), 2.0, loop=True)
        my_sprite.animate(walking_animation)
    
    :param list items: A list of items (e.g., a list of
                       :class:`Images <spyral.Image>`).
    :param int times: The number of times to iterate through the list.
    c            s2   t  | t ˆ  ƒ ˆ ƒ } ˆ  t | t ˆ  ƒ ƒ S(   N(   t   roundt   lent   int(   R    R   t   i(   t   itemst   times(    s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   iterate_easingi   s    (    (   R   R   R   (    (   R   R   s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   Iterate\   s    i    g       @c            s   ‡  ‡ f d †  } | S(   sc   
    Depending on the arguments, moves at a different pace according to the sine
    function.
    c            s$   ˆ  t  j ˆ | d t  j ˆ ƒ S(   Ng       @(   t   matht   sint   pi(   R    R   (   t	   amplitudet   phase(    s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt
   sin_easingv   s    (    (   R   R   t	   end_phaseR   (    (   R   R   s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   Sineq   s    c            s   ‡  ‡ f d †  } | S(   sF   
    Linearly increasing, but with two properites instead of one.
    c            s:   ˆ  d ˆ d | ˆ d ˆ  d ˆ d | ˆ d f S(   Ni    i   (    (   R    R   (   R   R   (    s1   /usr/lib/python2.7/site-packages/spyral/easing.pyR      s    (    (   R   R   R   (    (   R   R   s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   LinearTuple{   s    i   c            s   ‡  ‡ ‡ ‡ f d †  } | S(   sF   
    Increasing according to a circular curve for two properties.
    c            sB   ˆ ˆ | } ˆ  d ˆ t  j | ƒ ˆ  d ˆ t  j | ƒ f S(   Ni    i   (   R   t   cosR   (   R    R   t   theta(   t   centert   radiust	   theta_endt   theta_start(    s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt
   arc_easing‰   s    (    (   R%   R&   R(   R'   R)   (    (   R%   R&   R'   R(   s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   Arc…   s    c         C   s   d S(   Ng      ð?(    (   R$   (    (    s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   <lambda>‘   s    c            s   ‡  ‡ ‡ ‡ f d †  } | S(   sL   
    Similar to an Arc, except the radius should be a function of time.
    c            sN   ˆ ˆ | } ˆ  d ˆ | ƒ t  j | ƒ ˆ  d ˆ | ƒ t  j | ƒ f S(   Ni    i   (   R   R#   R   (   R    R   R$   (   R%   R&   R'   R(   (    s1   /usr/lib/python2.7/site-packages/spyral/easing.pyR)   —   s    (    (   R%   R&   R(   R'   R)   (    (   R%   R&   R'   R(   s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   Polar   s    (   i    i    (   i    i    (   i    i    (   i    i    (   t   __doc__R   R   R   R	   R   R   R   R   R   R   R!   R"   R*   R,   (    (    (    s1   /usr/lib/python2.7/site-packages/spyral/easing.pyt   <module>   s    				


