android-various animation accelerators, various interpolator

Source: Internet
Author: User
Tags asin cos



import Android.view.animation.interpolator;public class Backinterpolator implements interpolator {private int type;private float overshot;public backinterpolator (int type, float overshot) {This.type = Type;this.overshot = overshot;} public float getinterpolation (float t) {if (type = = easingtype.in) {return in (t, overshot);} elseif (type = = Easingtype.ou T) {return out (t, overshot);} elseif (type = = Easingtype.inout) {return INOUT (t, overshot);} return 0;} Private float in (float T, float o) {if (o = = 0) {o = 1.70158f;} Return t*t* ((o+1) *t-o);} Private float out (float T, float o) {if (o = = 0) {o = 1.70158f;} Return ((T-=1) *t* ((o+1) *t + O) + 1);} Private float inout (float t, float o) {if (o = = 0) {o = 1.70158f;} T *= 2;if (T < 1) {return 0.5f* (t*t* (((o*= (1.525)) +1));} else {return *t-o ((0.5f*) t-=2 (((*t* (o*=)) +1) 1.525 + O) + 2);}}} 
</pre ><pre name= "code" class= "Java"; 
</pre ><p></p><p></p><p></p><p></p><p></p><pre Name = "Code" class= "Java" >public class Bounceinterpolator implements interpolator {private int type;public Bounceinterpolator (int type) {this.type = type;}  public float getinterpolation (float t) {if (type = = easingtype.in) {return in (t);} elseif (type = = Easingtype.out) {return Out (t);} ElseIf (type = = Easingtype.inout) {return INOUT (t);} return 0;} Private float out (float t) {if (T < (1/2.75)) {return 7.5625f*t*t;} elseif (T < 2/2.75) {return 7.5625f* (t-= (1.5/2.7 5)) *t +. 75f;} ElseIf (T < 2.5/2.75) {return 7.5625f* (t-= (2.25/2.75)) *t +. 9375f;} else {return 7.5625f* (t-= (2.625/2.75)) *t +. 984375f ;}} Private float in (float t) {return 1-out (1-T);} Private float inout (float t) {if (T < 0.5f) {return in (t*2) *. 5f,} else {return out (t*2-1) *. 5f +. 5f;}} 




public class Circinterpolator implements interpolator {private int type;public circinterpolator (int type) {This.type = Typ e;}  public float getinterpolation (float t) {if (type = = easingtype.in) {return in (t);} elseif (type = = Easingtype.out) {return Out (t);} ElseIf (type = = Easingtype.inout) {return INOUT (t);} return 0;} Private float in (float t) {return (float)-(MATH.SQRT (1-t*t)-1);} Private float out (float t) {return (float) math.sqrt (1-(t-=1) *t);} Private float inout (float t) {t *= 2;if (T < 1) {return (float) ( -0.5f * (MATH.SQRT (1-t*t)-1));} else {return (Floa T) (0.5f * (MATH.SQRT (1-(t-=2) *t) + 1);}}}



public class Cubicinterpolator implements interpolator {private int type;public cubicinterpolator (int type) {This.type = t ype;}  public float getinterpolation (float t) {if (type = = easingtype.in) {return in (t);} elseif (type = = Easingtype.out) {return Out (t);} ElseIf (type = = Easingtype.inout) {return INOUT (t);} return 0;} Private float in (float t) {return t*t*t;} Private float out (float t) {return (t-=1) *t*t + 1;} Private float inout (float t) {t *= 2;if (T < 1) {return 0.5f*t*t*t;} else {return 0.5f* ((t-=2) *t*t + 2);}}}


public class Elasticinterpolator implements interpolator {private int type;private float amplitude;private float period;p Ublic elasticinterpolator (int type, float amplitude, float period) {This.type = Type;this.amplitude = Amplitude;this.peri od = period;} public float getinterpolation (float t) {if (type = = easingtype.in) {return in (t, amplitude, period);} elseif (type = = Easi Ngtype.out) {return out (T, amplitude, period),} elseif (type = = Easingtype.inout) {return INOUT (T, amplitude, period);} return 0;} Private float in (float T, float A, float p) {if (t = = 0) {return 0;} if (t >= 1) {return 1;} if (p = = 0) {p = 0.3f;} Float s;if (A = = 0 | | A < 1) {a = 1;s = P/4;} else {s = (float) (p/(2*MATH.PI) * Math.asin (1/a));} return (float) (-(A*math.pow (2,10* (t-=1)) * Math.sin ((t-s) * (2*MATH.PI)/P))); Private float out (float t, float A, float p) {if (t = = 0) {return 0;} if (t >= 1) {return 1;} if (p = = 0) {p = 0.3f;} Float s;if (A = = 0 | | A < 1) {a = 1;s = P/4;} else {s = (float) (p/(2*math.pI) * Math.asin (1/a));} return (float) (A*math.pow (2,-10*t) * Math.sin ((t-s) * (2*MATH.PI)/p) + 1);} Private float inout (float t, float A, float p) {if (t = = 0) {return 0;} if (t >= 1) {return 1;} if (p = = 0) {p =. 3f*1.5f;} Float s;if (A = = 0 | | A < 1) {a = 1;s = P/4;} else {s = (float) (p/(2*MATH.PI) * Math.asin (1/a));} T *= 2;if (T < 1) {return (float) (-.5* (A*math.pow (2,10*)) * T-=1 ((t-s) * (Math.sin)/P));} else {return (float ) (A*math.pow (2,-10* (t-=1)) * Math.sin ((t-s) * (2*MATH.PI)/p) *.5 + 1);}}


public class Expointerpolator implements interpolator {private int type;public expointerpolator (int type) {This.type = Typ e;}  public float getinterpolation (float t) {if (type = = easingtype.in) {return in (t);} elseif (type = = Easingtype.out) {return Out (t);} ElseIf (type = = Easingtype.inout) {return INOUT (t);} return 0;} Private float in (float t) {return (float) ((t==0) 0:math.pow (2, t-1));} Private float out (float t) {return (float) (t>=1) 1: (-math.pow (2, -10 * t) + 1));} Private float inout (float t) {if (t = = 0) {return 0;} if (t >= 1) {return 1;}  T *= 2;if (T < 1) {return (float) (0.5f * MATH.POW (2, 2 * (t-1)));} else {return (float) (0.5f * (-MATH.POW (10 *) --T) + 2);}}}



public class Quadinterpolator implements interpolator {private int type;public quadinterpolator (int type) {This.type = Typ e;}  public float getinterpolation (float t) {if (type = = easingtype.in) {return in (t);} elseif (type = = Easingtype.out) {return Out (t);} ElseIf (type = = Easingtype.inout) {return INOUT (t);} return 0;} Private float in (float t) {return t*t;} Private float out (float t) {return-(t) * (T-2);} Private float inout (float t) {t *= 2;if (T < 1) {return 0.5f*t*t;} else {return-0.5f * ((--T) * (t-2)-1);}}}


public class Quartinterpolator implements interpolator {private int type;public quartinterpolator (int type) {This.type = t ype;}  public float getinterpolation (float t) {if (type = = easingtype.in) {return in (t);} elseif (type = = Easingtype.out) {return Out (t);} ElseIf (type = = Easingtype.inout) {return INOUT (t);} return 0;} Private float in (float t) {return t*t*t*t;} Private float out (float t) {return-((t-=1) *t*t*t-1);} Private float inout (float t) {t *= 2;if (T < 1) {return 0.5f*t*t*t*t;} else {return-0.5f * ((t-=2) *t*t*t-2);}}



public class Quintinterpolator implements interpolator {private int type;public quintinterpolator (int type) {This.type = t ype;}  public float getinterpolation (float t) {if (type = = easingtype.in) {return in (t);} elseif (type = = Easingtype.out) {return Out (t);} ElseIf (type = = Easingtype.inout) {return INOUT (t);} return 0;} Private float in (float t) {return t*t*t*t*t;} Private float out (float t) {return ((t-=1) *t*t*t*t + 1);} Private float inout (float t) {t *= 2;if (T < 1) {return 0.5f*t*t*t*t*t;} else {return 0.5f* ((t-=2) *t*t*t*t + 2);}}}


public class Sineinterpolator implements interpolator {private int type;public sineinterpolator (int type) {This.type = Typ e;}  public float getinterpolation (float t) {if (type = = easingtype.in) {return in (t);} elseif (type = = Easingtype.out) {return Out (t);} ElseIf (type = = Easingtype.inout) {return INOUT (t);} return 0;} Private float in (float t) {return (float) (-math.cos (T * (MATH.PI/2)) + 1);} Private float out (float t) {return (float) Math.sin (t * (MATH.PI/2));} Private float inout (float t) {return (float) ( -0.5f * (Math.Cos (math.pi*t)-1)}}

android-various animation accelerators, various interpolator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.