Android材质L图像过渡插值器 [英] Android material L image transition interpolator
问题描述
这更多是数学问题,而不是编程问题.
好吧,我想问一下id,您知道材料设计中描述的插值器是什么:
它看起来像是AccelerateDecelerateInterpolator
,但是减速效果衰减得更慢.
我最好的孵化方式是:
public class MaterialInterpolator implements Interpolator {
@Override
public float getInterpolation(float input) {
if(input<1./3f)
return new AccelerateInterpolator().getInterpolation(input);
else
return new DecelerateInterpolator().getInterpolation(input);
}
}
哪个会在两个值之间造成间隔:
Time / Value
...
0.3,0.09
0.317,0.100489
0.333,0.110889 <-- gap
0.35,0.57750005
0.367,0.599311
0.383,0.61931103
0.4,0.64
...
减速AccelerateDecelerateInterpolator:
output = accelerateDecelerateInterpolator(decelerateInterpolator(input));
private float accelerateDecelerateInterpolator(float input) {
return (float)(Math.cos((input + 1) * Math.PI) / 2.0f) + 0.5f;
}
private float decelerateInterpolator(float input) {
// return 1.0f - (1.0f - input) * (1.0f - input);
return (float)(1.0f - Math.pow((1.0f - input), 2 * mFactor)); // default factor =1.f
}
给予与以下内容相似的费用
:
值/时间曲线:</p>
不确定一开始是输出错误还是实际行为应该是输出错误
来源: http://www.google.com/design/spec/patterns/imagery-treatment.html
支持库现在具有用于棒棒糖之前设备的插值器:FastOutLinearInInterpolator, FastOutSlowInInterpolator ,LinearOutSlowInInterpolator和PathInterpolatorCompat.
文档: http://developer.android.com/reference/android/support/v4/view/animation/package-summary.html
This is more of a mathematics question rather than programming.
Well, I would like to ask id you know what is the interpolator described in Material design:
It looks to be an AccelerateDecelerateInterpolator
but the deceleration effect decays slower.
My best hatch is :
public class MaterialInterpolator implements Interpolator {
@Override
public float getInterpolation(float input) {
if(input<1./3f)
return new AccelerateInterpolator().getInterpolation(input);
else
return new DecelerateInterpolator().getInterpolation(input);
}
}
Which creates a gap between the values:
Time / Value
...
0.3,0.09
0.317,0.100489
0.333,0.110889 <-- gap
0.35,0.57750005
0.367,0.599311
0.383,0.61931103
0.4,0.64
...
Decelerating the AccelerateDecelerateInterpolator:
output = accelerateDecelerateInterpolator(decelerateInterpolator(input));
private float accelerateDecelerateInterpolator(float input) {
return (float)(Math.cos((input + 1) * Math.PI) / 2.0f) + 0.5f;
}
private float decelerateInterpolator(float input) {
// return 1.0f - (1.0f - input) * (1.0f - input);
return (float)(1.0f - Math.pow((1.0f - input), 2 * mFactor)); // default factor =1.f
}
Gives rates similar to:
And value/time curve:
not sure if at the beginning is an output error or the actual behavior should be an output error
Source: http://www.google.com/design/spec/patterns/imagery-treatment.html
The support library now has interpolators for pre-Lollipop devices: FastOutLinearInInterpolator, FastOutSlowInInterpolator, LinearOutSlowInInterpolator, and PathInterpolatorCompat.
Docs: http://developer.android.com/reference/android/support/v4/view/animation/package-summary.html
这篇关于Android材质L图像过渡插值器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!