libanim

diff src/track.c @ 49:fb9659ca5cf2

added ping-pong extrapolator
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 13 Apr 2013 07:27:32 +0300
parents b3312cf87715
children 821411647b40
line diff
     1.1 --- a/src/track.c	Sun Mar 10 18:52:57 2013 +0200
     1.2 +++ b/src/track.c	Sat Apr 13 07:27:32 2013 +0300
     1.3 @@ -14,6 +14,7 @@
     1.4  static anm_time_t remap_extend(anm_time_t tm, anm_time_t start, anm_time_t end);
     1.5  static anm_time_t remap_clamp(anm_time_t tm, anm_time_t start, anm_time_t end);
     1.6  static anm_time_t remap_repeat(anm_time_t tm, anm_time_t start, anm_time_t end);
     1.7 +static anm_time_t remap_pingpong(anm_time_t tm, anm_time_t start, anm_time_t end);
     1.8  
     1.9  /* XXX keep this in sync with enum anm_interpolator at track.h */
    1.10  static float (*interp[])(float, float, float, float, float) = {
    1.11 @@ -28,6 +29,7 @@
    1.12  	remap_extend,
    1.13  	remap_clamp,
    1.14  	remap_repeat,
    1.15 +	remap_pingpong,
    1.16  	0
    1.17  };
    1.18  
    1.19 @@ -304,3 +306,11 @@
    1.20  	}
    1.21  	return (tm - start) % interv + start;*/
    1.22  }
    1.23 +
    1.24 +static anm_time_t remap_pingpong(anm_time_t tm, anm_time_t start, anm_time_t end)
    1.25 +{
    1.26 +	anm_time_t interv = end - start;
    1.27 +	anm_time_t x = remap_repeat(tm, start, end + interv);
    1.28 +
    1.29 +	return x > end ? end + interv - x : x;
    1.30 +}