public final class ColorUtils
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ColorUtils.RandomColor
随机颜色
|
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
colorToString(int color)
将 color 颜色值转换为十六进制字符串
|
static int |
computeColor(int fromColor,
int toColor,
float fraction)
根据比例,在两个color值之间计算出一个color值
注意该方法是ARGB通道分开计算比例的
|
static int |
darker(int color)
加深颜色
|
static int |
darker(int color,
float factor)
加深颜色
|
static int |
getRandomColor() |
static boolean |
isColorDark(int color)
是否是深色的颜色
|
static int |
lighter(int color)
变浅颜色
|
static int |
lighter(int color,
float factor)
变浅颜色
|
static int |
setColorAlpha(int color,
float alpha) |
static int |
setColorAlpha(int color,
float alpha,
boolean override)
设置颜色的alpha值
|
public static int setColorAlpha(int color,
float alpha)
public static int setColorAlpha(int color,
float alpha,
boolean override)
color - 需要被设置的颜色值alpha - 取值为[0,1],0表示全透明,1表示不透明override - 覆盖原本的 alphapublic static int computeColor(int fromColor,
int toColor,
float fraction)
fromColor - 开始的color值toColor - 最终的color值fraction - 比例,取值为[0,1],为0时返回 fromColor, 为1时返回 toColorpublic static java.lang.String colorToString(int color)
color - 颜色值public static int darker(int color)
color - 需要加深的颜色public static int darker(int color,
float factor)
color - 需要加深的颜色factor - The factor to darken the color.public static int lighter(int color)
color - 需要变浅的颜色public static int lighter(int color,
float factor)
color - 需要变浅的颜色factor - The factor to lighten the color. 0 will make the color unchanged. 1 will make the
color white.public static boolean isColorDark(int color)
color - public static int getRandomColor()