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

ColorgetRandomColor()
get Random Color
return new Color((int) (random() * 255), (int) (random() * 255), (int) (random() * 255));
ColorgetRandomColor()
get Random Color
int red = random.nextInt(225);
int green = random.nextInt(225);
int blue = random.nextInt(225);
return new Color(red, green, blue);
StringgetRandomColor()
get Random Color
String col = Integer.toHexString(new Color((int) (Math.random() * 0xffffff)).darker().getRGB());
while (col.length() < 6) {
    col = "0" + col;
return col.substring(col.length() - 6);
ColorgetRandomColor()
get Random Color
if (COLOR_INVENTORY.size() == 0) {
    initializeColorInventory();
return COLOR_INVENTORY.get(r.nextInt(COLOR_INVENTORY.size()));
ColorgetRandomColor()
Random Color generator.
int transparency = (int) getRandomNumber(100, 375);
if (transparency > 255) {
    transparency = 255;
return new Color((int) getRandomNumber(255), (int) getRandomNumber(255), (int) getRandomNumber(255),
        transparency);
StringgetRandomColor()
get Random Color
Random rand = new Random();
float r = rand.nextFloat();
float g = rand.nextFloat();
float b = rand.nextFloat();
String hex = Integer.toHexString(new java.awt.Color(r, g, b).getRGB() & 0xffffff);
if (hex.length() < 6) {
    hex = "0" + hex;
hex = "#" + hex;
return hex;
ColorgetRandomColor()
Gets random RGB color
Random randomGenerator = new Random();
int r = randomGenerator.nextInt(256);
int g = randomGenerator.nextInt(256);
int b = randomGenerator.nextInt(256);
return new Color(r, g, b);
ColorgetRandomColor(boolean useTransparency)
returns a random color
float r = (float) Math.random();
float g = (float) Math.random();
float b = (float) Math.random();
float a = 0;
if (useTransparency) {
    a = (float) Math.random() / 1.5f;
return new Color(r, g, b, a);
...
ColorgetRandomColor(float offset, float alpha)
Returns a random color given the offset and alpha values.
final float max = 1.0f;
final float min = 0.0f;
if (offset > max)
    offset = min;
if (offset < min)
    offset = min;
float multiplier = max - offset;
float r = (float) Math.random() * multiplier + offset;
...
ColorgetRandomColor(int saturationRandom, float luminance)
get Random Color
final float hue = random.nextFloat();
final float saturation = (random.nextInt(saturationRandom) + (float) saturationRandom)
        / (float) saturationRandom + (float) saturationRandom;
return getHSBColor(hue, saturation, luminance);