android-各种动画加速器,各种插值器
来源:互联网 发布:微信淘宝链接转换 编辑:程序博客网 时间:2024/05/01 04:40
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.OUT) {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)*t - o));} else {return 0.5f*((t-=2)*t*(((o*=(1.525))+1)*t + 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.75))*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 = 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 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 (float) (0.5f * (Math.sqrt(1 - (t-=2)*t) + 1));}}}
public class CubicInterpolator implements Interpolator {private int type;public CubicInterpolator(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 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;public ElasticInterpolator(int type, float amplitude, float period) {this.type = type;this.amplitude = amplitude;this.period = period;}public float getInterpolation(float t) {if (type == EasingType.IN) {return in(t, amplitude, period);} elseif (type == EasingType.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)) * Math.sin((t-s)*(2*Math.PI)/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 = 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 in(float t) {return (float) ((t==0) ? 0 : Math.pow(2, 10 * (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, 10 * (t - 1)));} else {return (float) (0.5f * (-Math.pow(2, -10 * --t) + 2));}}}
public class QuadInterpolator implements Interpolator {private int type;public QuadInterpolator(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 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 = 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 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 = 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 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 = 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 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));}}
0 0
- android-各种动画加速器,各种插值器
- Android各种动画效果
- Android各种动画使用
- Android各种动画插值器的实例
- android的各种属性动画
- android 各种加载动画效果
- Android Animation各种动画详解
- 各种动画
- 各种动画
- 各种动画
- 各种动画
- 各种动画
- pp加速器各种问题官方最新回答
- Android中各种动画的使用
- Android Animation各种动画完全解析
- Android——各种动画Drawable
- Android Animation各种动画完全解析
- android动画加速器(插值器)interpolator和速度曲线
- Appium学习-IOS初窥
- java 内部类
- MIME类型大全
- Nodejs(八)
- [乐意黎原创] PHP的增加时间
- android-各种动画加速器,各种插值器
- 数据分析框架Pandas入门
- 面试之路(29)-合并两个排序的链表(递归和非递归)
- Eclipse常用快捷键
- HDU 1009 FatMouse' Trade 简单贪心,细节处理
- 最大上升子列
- Java并发(四)同步容器
- redis学习笔记(12)---server基本流程
- 在Windows环境下搭建DNS