我正在使用 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;
}
我的问题是我也得到亮度颜色(随机)。
那么如何避免只有亮度颜色呢?
我的输出:
最佳答案
您可能最好使用 HSB(色相、饱和度、亮度)颜色空间而不是 RGB。您可以使用getHSBColor()相反,对饱和度和亮度进行硬编码以保持它们相同,只是随机化颜色。
private Color getRandomColor() {
Random rnd = new Random();
return Color.getHSBColor(rnd.nextFloat(), 0.5f, 0.5f);
}
关于java - 降低Android中颜色的亮度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27229511/