/**
* @param shadowColor The color of the shadow, e.g. 0x11000000.
*/
public FadingShadow(int shadowColor) {
final int n = SMOOTH_ALGORITHM_INTERPOLATION_POINTS_NUM;
float[] positions = new float[n];
int[] colors = new int[n];
int transparentShadowColor = shadowColor & 0x00FFFFFF;
int shadowAlpha = Color.alpha(shadowColor);
// Piece-wise linear interpolation of the smooth cubic function below.
for (int i = 0; i < n; ++i) {
float x = (float) i / (n - 1);
// Polynomial computation by Estrin's scheme.
float value = (1.0f - 2.2f * x) + (1.8f - 0.6f * x) * (x * x);
positions[i] = x;
colors[i] = (Math.round(shadowAlpha * value) << 24) | transparentShadowColor;
}
mShadowShader = new LinearGradient(0, 0, 0, 1, colors, positions, Shader.TileMode.CLAMP);
}
FadingShadow.java 文件源码
java
阅读 36
收藏 0
点赞 0
评论 0
项目:chromium-for-android-56-debug-video
作者:
评论列表
文章目录