java降低安卓中颜色的亮度?
我正在与AChart Engine合作
并在运行时动态设置颜色
这是我的代码,
private int getRandomColor() {
Random rnd = new Random();
int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
return color;
}
我的问题是我也(随机)得到了亮度颜色
那么如何避免只使用亮度颜色呢
我的输出:
# 1 楼答案
使用HSB(色调、饱和度、亮度)颜色空间可能比使用RGB更好。你可以用getHSBColor()代替,并对饱和度和亮度进行硬编码,使它们保持一致,只需随机化颜色即可
# 2 楼答案
如果我理解正确,你想避免鲜艳的颜色,你必须改变这一行:
对于这些台词:
这将导致只生成较暗的颜色
如果你只想要浅色,就这样做: