List of utility methods to do Random Color
Color | randomColor(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); |
Color | randomColor(Random r) random Color return new Color(r.nextInt(127) + 127, r.nextInt(127) + 127, r.nextInt(127) + 127); |
long | randomColorFactor() random Color Factor return Math.round(Math.random() * 255);
|
int | randomColorValue() random Color Value return (int) (Math.random() * 255); |
Color | randomColour(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); |
Color | randomDarkColor() return a random lighter color return new Color(0 + RND.nextInt(128), 0 + RND.nextInt(128), 0 + RND.nextInt(128)); |
Color | randomDesaturatedColor(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)); |