Java Utililty Methods Random Color

List of utility methods to do Random Color

Description

The list of methods to do Random Color are organized into topic(s).

Method

ColorrandomColor(int seed)
random Color
Random rand = new Random();
rand.setSeed(seed);
float r = rand.nextFloat();
float g = rand.nextFloat();
float b = rand.nextFloat();
return new Color(r, g, b);
ColorrandomColor(Random r)
random Color
return new Color(r.nextInt(127) + 127, r.nextInt(127) + 127, r.nextInt(127) + 127);
longrandomColorFactor()
random Color Factor
return Math.round(Math.random() * 255);
intrandomColorValue()
random Color Value
return (int) (Math.random() * 255);
ColorrandomColour(Random random)
random Colour
while (true) {
    int red = random.nextBoolean() ? random.nextInt(255) : 0;
    int blue = random.nextBoolean() ? random.nextInt(255) : 0;
    int green = random.nextBoolean() ? random.nextInt(255) : 0;
    int sum = red + blue + green;
    if (sum > 75 && sum < (240 * 3)) {
        return new Color(red, blue, green);
ColorrandomDarkColor()
return a random lighter color
return new Color(0 + RND.nextInt(128), 0 + RND.nextInt(128), 0 + RND.nextInt(128));
ColorrandomDesaturatedColor(float alpha)
random Desaturated Color
float hue = (float) Math.random();
float brightenss = (float) (Math.random() * 0.7);
Color base = Color.getHSBColor(hue, 0, brightenss);
if (alpha >= 1)
    return base;
else
    return new Color(base.getRed(), base.getGreen(), base.getBlue(), (int) (alpha * 255));