/**
* Calculate a variant of the color to make it more suitable for overlaying information. Light
* colors will be lightened and dark colors will be darkened
*
* @param color the color to adjust
* @param isDark whether {@code color} is light or dark
* @param lightnessMultiplier the amount to modify the color e.g. 0.1f will alter it by 10%
* @return the adjusted color
*/
public static
@ColorInt
int scrimify(@ColorInt int color,
boolean isDark,
@FloatRange(from = 0f, to = 1f) float lightnessMultiplier) {
float[] hsl = new float[3];
android.support.v4.graphics.ColorUtils.colorToHSL(color, hsl);
if (!isDark) {
lightnessMultiplier += 1f;
} else {
lightnessMultiplier = 1f - lightnessMultiplier;
}
hsl[2] = constrain(0f, 1f, hsl[2] * lightnessMultiplier);
return android.support.v4.graphics.ColorUtils.HSLToColor(hsl);
}
ColorUtil.java 文件源码
java
阅读 43
收藏 0
点赞 0
评论 0
项目:AmenEye
作者:
评论列表
文章目录