📜  生成随机光色 android - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:47.246000             🧑  作者: Mango

代码示例1
final Random mRandom = new Random(System.currentTimeMillis());

public int generateRandomColor() {
    // This is the base color which will be mixed with the generated one
    final int baseColor = Color.WHITE;

    final int baseRed = Color.red(baseColor);
    final int baseGreen = Color.green(baseColor);
    final int baseBlue = Color.blue(baseColor);

    final int red = (baseRed + mRandom.nextInt(256)) / 2;
    final int green = (baseGreen + mRandom.nextInt(256)) / 2;
    final int blue = (baseBlue + mRandom.nextInt(256)) / 2;

    return Color.rgb(red, green, blue);
}